std/midi
Always in scope — no import required.
MIDI output: tracks, control-change lanes, and port management.
CcOutput
Section titled “CcOutput”A MIDI track’s CC lane, from track.cc(number). Takes a value, a pattern or a signal via <<, and sends on wherever the track is routed.
send_rate
Section titled “send_rate”fn send_rate() -> NumberThe CC send rate in Hz.
set_send_rate
Section titled “set_send_rate”fn set_send_rate(hz: Number) -> CcOutputSet the CC send rate in Hz (default 30). Higher values produce smoother automation but more MIDI traffic.
Example:
track.cc(74).set_send_rate(60) << Sine(0.5).range(0, 127)
Parameters:
hz(Number) — send rate in Hz
Returns: CcOutput — the CC output handle, for chaining
MidiOutput
Section titled “MidiOutput”MidiOutput: a MIDI output port and channel, a destination for >> — Live’s “MIDI To”. Made by MidiOutput(alias, channel); it can only end a >> chain.
Constructor
Section titled “Constructor”fn MidiOutput(alias: String, channel: Number? = NUL) -> MidiOutputA MIDI output port and channel, as a destination for >> — Live’s “MIDI To”. track >> MidiOutput("synth", 2) sends the track there; a playing pattern, its CC and its input thru move from the next cycle, with no << needed. track >> session.nowhere sets it back to no output.
Example:
bass >> MidiOutput("synth"), lead >> MidiOutput("daw", 2)
Parameters:
alias(String) — output port alias, as a[[midi.outputs]]entry declares itchannel(Number?) — MIDI channel 1-16 (optional; default 1)
Returns: MidiOutput — the port and channel, to route to with >>
MidiTrack
Section titled “MidiTrack”A MIDI track: plays patterns and CC to a hardware or virtual MIDI port. Create with session.create_midi_track("name") in fn setup(); look it up with session.midi_track("name"). Choose its output with >>, as in track >> MidiOutput("synth", 2). A new track has no output until then.
Implements: Json, whose json it inherits
delete
Section titled “delete”fn delete() -> NULDeletes the track and disconnects its input and output.
set_name
Section titled “set_name”fn set_name(name: String) -> MidiTrackChanges the track name. Existing handles keep following this track.
Parameters:
name(String) — unique track name
Returns: MidiTrack — the track, for chaining
set_color
Section titled “set_color”fn set_color(index: Number) -> MidiTrackSets the track colour. It shows on the track’s header, clips and Mixer strip.
Parameters:
index(Number) — palette index from 0 to 23: 12 bright hues, then the same muted
Returns: MidiTrack — the track, for chaining
fn color() -> NumberThe track colour. A new track takes the next free palette colour.
Returns: Number — palette index from 0 to 23
fn name() -> StringThe track name.
output
Section titled “output”fn output() -> Dict<String | Number, Any>?The output port and channel, or NUL for no output.
fn input() -> Dict<String | Number, Any>?The input port and channel (NUL for all channels), or NUL when unset.
monitor
Section titled “monitor”fn monitor() -> MonitorThe input monitoring mode.
velocity
Section titled “velocity”fn velocity() -> Number | Signal | PatternThe configured velocity source; 100 until set_velocity changes it.
tuning
Section titled “tuning”fn tuning() -> Number?The pitch-bend range in semitones, or NUL when disabled.
fn mpe() -> Dict<String | Number, Any>?The MPE range and member channel bounds, or NUL when disabled.
fn key() -> Key?The track key, or NUL when unset.
set_input
Section titled “set_input”fn set_input(alias: String, channel: Number? = NUL) -> MidiTrackSet the MIDI input port and optional channel.
Example:
track.set_input("keys"), track.set_input("keys", 1)
Parameters:
alias(String) — input port alias, as a[[midi.inputs]]entry declares it, or"all"for every inputchannel(Number?) — MIDI channel 1-16 (optional)
Returns: MidiTrack — the track, for chaining
set_monitor
Section titled “set_monitor”fn set_monitor(mode: Monitor) -> MidiTrackSet the monitor mode: whether what is played on the input passes through to the output. Monitor.auto passes it while the track is not playing its own material: the transport is stopped, or it has no pattern.
Example:
track.set_monitor(Monitor.input)
Parameters:
mode(Monitor) — when the input passes through
Returns: MidiTrack — the track, for chaining
set_velocity
Section titled “set_velocity”fn set_velocity(vel: Number | Signal | Pattern) -> MidiTrackSet the default velocity for this track. A new track plays at 100. A note with its own velocity keeps it.
Example:
track.set_velocity(80) or track.set_velocity([100 60 80 120])
Parameters:
vel(Number | Signal | Pattern) — note velocity (1-127), or a signal or pattern read as each note fires; a value from a signal or pattern is held to 1-127
Returns: MidiTrack — the track, for chaining
fn cc(cc_number: Number) -> CcOutputGet a CC output handle for the given controller number. Use << to assign values, patterns, or signals.
Example:
track.cc(74) << Sine(0.5).range(0, 127)
Parameters:
cc_number(Number) — CC controller number (0-127)
Returns: CcOutput — a CC output handle, assignable with <<
set_tuning
Section titled “set_tuning”fn set_tuning(bend_range: Number? = NUL) -> MidiTrackEnable microtonal pitch bend output. Uses the MIDI default ±2 semitone range (works with any synth).
Example:
track.set_tuning(), track.set_tuning(48)
Parameters:
bend_range(Number?) — pitch-bend range in semitones (optional; default ±2)
Returns: MidiTrack — the track, for chaining
set_mpe
Section titled “set_mpe”fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> MidiTrackEnable MPE (per-note channel allocation) for polyphonic microtonal output.
Example:
track.set_mpe(), track.set_mpe(24), track.set_mpe(48, 2, 9)
Parameters:
range(Number?) — pitch-bend range in semitones (optional, defaults to 48)zone_lo(Number?) — low member channel (optional, defaults to 2)zone_hi(Number?) — high member channel (optional, defaults to 16)
Returns: MidiTrack — the track, for chaining
set_key
Section titled “set_key”fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> MidiTrackSet a track-level key for degree resolution and auto-quantization. Degrees (^1, ^2, …) resolve from this key without .in_key(), and absolute notes are quantized to the nearest scale tone. A change is heard from the next cycle, on a pattern already playing. Pass a Key value, or a scale name/Scale with a root note.
Example:
track.set_key(Key(C4, "minor")) or track.set_key("minor", C4)
Parameters:
scale(Key | String | Scale) — a Key value, or a scale name/Scale valueroot(Note?) — root note (e.g. C4, or a MIDI number such as 60); omit when passing a Key
Returns: MidiTrack — the track, for chaining
fn mute() -> MidiTrackMutes the track, like Live’s Track Activator: its notes and CC stop at once, and the notes it holds get their note-offs. MIDI coming in through the track is muted too.
Returns: MidiTrack — the track, for chaining
unmute
Section titled “unmute”fn unmute() -> MidiTrackUnmutes the track. Its pattern is heard again from its next note.
Returns: MidiTrack — the track, for chaining
is_muted
Section titled “is_muted”fn is_muted() -> BooleanReturns whether the track is muted.
Returns: Boolean — true if the track is muted
fn solo() -> MidiTrackSolos the track, and only this track: every other solo is released and every other track — audio and MIDI — falls silent, as a plain click on Live’s Solo button.
Returns: MidiTrack — the track, for chaining
add_solo
Section titled “add_solo”fn add_solo() -> MidiTrackAdds the track to the soloed tracks and keeps the others soloed, as a Cmd-click on Live’s Solo button.
Returns: MidiTrack — the track, for chaining
unsolo
Section titled “unsolo”fn unsolo() -> MidiTrackReleases the track’s solo. When no track is soloed, every track is heard.
Returns: MidiTrack — the track, for chaining
is_soloed
Section titled “is_soloed”fn is_soloed() -> BooleanReturns whether the track is soloed.
Returns: Boolean — true if the track is soloed
MidiLatency
Section titled “MidiLatency”How outgoing MIDI is aligned with the audio output.
MidiLatency.auto— MIDI is timestamped for the moment the audio reaches the DAC, including plugin delay compensation, so hardware stays in step with what you hear. The default.MidiLatency.manual— Only the per-port trims apply.
midi_clock_report
Section titled “midi_clock_report”fn midi_clock_report() -> NULPrint MIDI clock status: source, BPM, transport state, and PLL diagnostics.
Example:
midi_clock_report()
Returns: NUL — nothing; prints the status
midi_clock_send
Section titled “midi_clock_send”fn midi_clock_send() -> BooleanWhether outgoing MIDI clock is enabled.
midi_clock_source
Section titled “midi_clock_source”fn midi_clock_source() -> String?The followed input alias, or NUL for the internal clock.
midi_connected
Section titled “midi_connected”fn midi_connected() -> Dict<String, String>Checks the current MIDI connection status.
Returns: Dict — {alias: port_name} for every connected output port; empty when none is connected
midi_disconnect
Section titled “midi_disconnect”fn midi_disconnect(alias: String) -> NULDisconnects a MIDI output port. Tracks routed to it keep their output, and are heard again once reload_preferences() reconnects it.
Example:
midi_disconnect("synth")
Parameters:
alias(String) — output port alias, as a[[midi.outputs]]entry declares it
Returns: NUL — nothing
midi_input_disconnect
Section titled “midi_input_disconnect”fn midi_input_disconnect(alias: String) -> NULDisconnects a MIDI input port by alias.
Example:
midi_input_disconnect("kb")
Parameters:
alias(String) — input port alias, as a[[midi.inputs]]entry declares it
Returns: NUL — nothing
midi_input_events
Section titled “midi_input_events”fn midi_input_events(limit: Number = 100, port: String? = NUL) -> Array<Dict<String | Number, Any>>Recent input messages, oldest first, from connected input ports. Reads do not consume messages or wait. At most 2000 messages are retained; the input service publishes within 100 ms. Each entry has port (alias), message (raw MIDI bytes), channel (1-16, or NUL for system messages), and age_ms since hardware receipt. Messages contain up to three bytes; complete SysEx payloads are not retained.
Parameters:
limit(Number) — maximum messages, a whole number from 0 to 2000 (default 100)port(String?) — exact input alias filter, or NUL for all inputs
midi_input_ports
Section titled “midi_input_ports”fn midi_input_ports() -> Array<String>Lists all available MIDI input ports.
Returns: Array — the available input port names as Strings
midi_latency
Section titled “midi_latency”fn midi_latency() -> MidiLatencyThe outgoing MIDI alignment mode.
midi_latency_report
Section titled “midi_latency_report”fn midi_latency_report() -> NULPrint the MIDI output alignment report. Shows where the automatic offset comes from — audio buffer, device latency, plugin delay compensation — and what each port ends up with after its trims.
Example:
midi_latency_report()
Returns: NUL — nothing; prints the report
midi_output_ports
Section titled “midi_output_ports”fn midi_output_ports() -> Array<String>Lists all available MIDI output ports.
Returns: Array — the available output port names as Strings
midi_port_clock
Section titled “midi_port_clock”fn midi_port_clock(alias: String) -> BooleanReturns whether a MIDI output port is opted in to receiving clock. Set by send_clock in the port’s [[midi.outputs]] entry.
Example:
midi_port_clock("cv")
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entry
Returns: Boolean — true if the port receives clock
midi_port_clock_trim
Section titled “midi_port_clock_trim”fn midi_port_clock_trim(alias: String) -> NumberReturns a MIDI output port’s clock-only trim in milliseconds. Set by clock_trim_ms in the port’s [[midi.outputs]] entry, and added to midi_port_trim for clock and transport messages only.
Example:
midi_port_clock_trim("cv")
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entry
Returns: Number — the current clock trim in milliseconds
midi_port_trim
Section titled “midi_port_trim”fn midi_port_trim(alias: String) -> NumberReturns a MIDI output port’s timing trim in milliseconds. Set by trim_ms in the port’s [[midi.outputs]] entry, and applied to notes and clock alike, on top of the automatic alignment.
Example:
midi_port_trim("cv")
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entry
Returns: Number — the current trim in milliseconds
midi_routing_report
Section titled “midi_routing_report”fn midi_routing_report() -> NULDisplays the current MIDI routing: connected output/input ports and active slots.
Returns: NUL — nothing; prints the routing
midi_trace
Section titled “midi_trace”fn midi_trace() -> BooleanWhether MIDI timing trace recording is enabled.
midi_trace_report
Section titled “midi_trace_report”fn midi_trace_report() -> NULPrint the MIDI timing trace: clock tick spacing, note dispatch, phase errors. Prints and clears what has been captured so far; recording continues. A bench instrument, off by default: turn it on with set_midi_trace(true) for a measurement. Report while the transport still rolls: STOP drains the trace to stderr.
Example:
midi_trace_report()
Returns: NUL — nothing; prints the trace
set_midi_clock_send
Section titled “set_midi_clock_send”fn set_midi_clock_send(enabled: Boolean) -> NULEnable/disable MIDI clock output (master mode). Sends 24 PPQ clock ticks plus Start/Continue/Stop to every output port whose [[midi.outputs]] entry says send_clock = true. This is the master switch; ports opt in separately.
Example:
set_midi_clock_send(true)
Parameters:
enabled(Boolean) —trueto enable,falseto disable
Returns: NUL — nothing
set_midi_clock_source
Section titled “set_midi_clock_source”fn set_midi_clock_source(alias: String? = NUL) -> NULSets where the tempo and transport come from: an external MIDI clock on an input port (follower mode), or resonon’s own clock.
Example:
set_midi_clock_source("daw"), set_midi_clock_source()
Parameters:
alias(String?) — input port alias to follow, as a[[midi.inputs]]entry declares it; omit for resonon’s own clock
Returns: NUL — nothing
set_midi_latency
Section titled “set_midi_latency”fn set_midi_latency(mode: MidiLatency) -> NULSets how outgoing MIDI is aligned with the audio output.
Example:
set_midi_latency(MidiLatency.manual)
Parameters:
mode(MidiLatency) — the alignment;MidiLatency.autois the default
Returns: NUL — nothing
set_midi_trace
Section titled “set_midi_trace”fn set_midi_trace(on: Boolean) -> NULStart or stop the MIDI timing trace. true clears the buffer and begins recording; false stops and prints what was captured.
Example:
set_midi_trace(true), set_midi_trace(false)
Parameters:
on(Boolean) —trueto start recording,falseto stop and report
Returns: NUL — nothing