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.
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 >> 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. Construct with MidiTrack("name"); choose its output with >>, as in track >> MidiOutput("synth", 2). A new track has no output until then.
Constructor
Section titled “Constructor”fn MidiTrack(name: String) -> MidiTrackCreates a MIDI track with the given name.
Every track has a name; there is no unnamed track. The name is the track’s identity: asking for a name that already has a live track returns that track, with its output, input, velocity and CC intact. Re-executing the line therefore talks to the same track instead of building a second one. Two tracks need two names.
A new track has no output — Live’s “No Output” — and sends nothing until >> routes it: track >> MidiOutput("synth", 2).
Example:
MidiTrack("bass")
Parameters:
name(String) — the track’s name and identity (not empty)
Returns: MidiTrack — the track with that name, created if it does not exist yet
set_input
Section titled “set_input”fn set_input(alias: String, channel: Number?) -> 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: String) -> MidiTrackSet the monitor mode (“auto”, “in”, “off”).
Example:
track.set_monitor("in")
Parameters:
mode(String) — monitor mode: “auto”, “in”, or “off”
Returns: MidiTrack — the track, for chaining
set_velocity
Section titled “set_velocity”fn set_velocity(vel: Number or Signal or Pattern) -> MidiTrackSet the default velocity for this track.
Example:
track.set_velocity(80) or track.set_velocity([100 60 80 120])
Parameters:
vel(Number | Signal | Pattern) — note velocity (0-127), or a signal or pattern read as each note fires
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?) -> 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?, zone_lo: Number?, zone_hi: Number?) -> 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 or String or Scale, root: Note or Number?) -> 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. 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 | Number) — root note (e.g. C4 or a MIDI number); omit when passing a Key
Returns: MidiTrack — the track, for chaining
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_connected
Section titled “midi_connected”fn midi_connected() -> DictChecks 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_ports
Section titled “midi_input_ports”fn midi_input_ports() -> ArrayLists all available MIDI input ports.
Returns: Array — the available input port names as Strings
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_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_ports
Section titled “midi_ports”fn midi_ports() -> ArrayLists all available MIDI output ports.
Returns: Array — the available output port names as Strings
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_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 — recording takes a lock on the audio thread, so turn it on with set_midi_trace(true) for a measurement and off again. Report while the transport still rolls: STOP drains the buffer 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: String) -> NULSets how outgoing MIDI is aligned with the audio output. "auto" (the default) timestamps MIDI for the moment the audio reaches the DAC, including plugin delay compensation, so hardware stays in step with what you hear. "manual" disables that and leaves only the per-port trims.
Example:
set_midi_latency("manual")
Parameters:
mode(String) —"auto"or"manual"
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