std/midi
Always in scope — no import required.
MIDI output: tracks, control-change lanes, and port management.
CcOutput
Section titled “CcOutput”send_rate
Section titled “send_rate”fn 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).send_rate(60) << Sine(0.5).range(0, 127)
Parameters:
hz(Number) — send rate in Hz
Returns: CcOutput — the CC output handle, for chaining
MidiTrack
Section titled “MidiTrack”A MIDI track: routes a pattern to a hardware or virtual MIDI port. Construct with MidiTrack(channel); connect a port with .output(alias).
Constructor
Section titled “Constructor”fn MidiTrack(channel: Number, velocity: Number = NUL, port_alias: String = NUL, name: String = NUL) -> MidiTrackCreates a MIDI track on the given channel.
Example:
MidiTrack(1), MidiTrack(1, 100, "daw")
Parameters:
channel(Number) — MIDI channel 1-16velocity(Number) — note velocity 0-127port_alias(String) — output port alias (for multi-port setups)name(String) — track name for logging
Returns: MidiTrack — the new MIDI track
output
Section titled “output”fn output(alias: String, channel: Number?) -> MidiTrackSet the MIDI output port and optional channel.
Example:
track.output("synth"), track.output("synth", 2)
Parameters:
alias(String) — output port aliaschannel(Number) — MIDI channel 1-16 (optional)
Returns: MidiTrack — the track, for chaining
fn input(alias: String, channel: Number?) -> MidiTrackSet the MIDI input port and optional channel.
Example:
track.input("keys"), track.input("keys", 1)
Parameters:
alias(String) — input port aliaschannel(Number) — MIDI channel 1-16 (optional)
Returns: MidiTrack — the track, for chaining
monitor
Section titled “monitor”fn monitor(mode: String) -> MidiTrackSet the monitor mode (“auto”, “on”, “off”).
Example:
track.monitor("on")
Parameters:
mode(String) — monitor mode: “auto”, “on”, or “off”
Returns: MidiTrack — the track, for chaining
velocity
Section titled “velocity”fn velocity(vel: Number) -> MidiTrackSet the default velocity for this track.
Example:
track.velocity(80)
Parameters:
vel(Number) — default note velocity (0-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 <<
tuning
Section titled “tuning”fn tuning(bend_range: Number?) -> MidiTrackEnable microtonal pitch bend output. Uses the MIDI default ±2 semitone range (works with any synth).
Example:
track.tuning(), track.tuning(48)
Parameters:
bend_range(Number) — pitch-bend range in semitones (optional; default ±2)
Returns: MidiTrack — the track, for chaining
fn mpe(range: Number?, zone_lo: Number?, zone_hi: Number?) -> MidiTrackEnable MPE (per-note channel allocation) for polyphonic microtonal output.
Example:
track.mpe(), track.mpe(24), track.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
fn 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.key(Key(C4, "minor")) or track.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_follow
Section titled “midi_clock_follow”fn midi_clock_follow(source: String or Boolean) -> BooleanEnable/disable MIDI clock follow (follower mode). When enabled, resonon syncs tempo and transport to an external MIDI clock source.
Example:
midi_clock_follow("daw"), midi_clock_follow(false)
Parameters:
source(String | Boolean) — input port alias to follow, orfalseto disable
Returns: Boolean — true when enabled, false when disabled
midi_clock_send
Section titled “midi_clock_send”fn midi_clock_send(enabled: Boolean) -> BooleanEnable/disable MIDI clock output (master mode). Sends 24 PPQ clock ticks plus Start/Continue/Stop to every output port that has opted in with midi_port_clock. This is the master switch; ports opt in separately.
Example:
midi_clock_send(true)
Parameters:
enabled(Boolean) —trueto enable,falseto disable
Returns: Boolean — the resulting enabled state
midi_clock_status
Section titled “midi_clock_status”fn midi_clock_status() -> NULPrint MIDI clock status: source, BPM, transport state, and PLL diagnostics.
Example:
midi_clock_status()
Returns: NUL — nothing; prints the status
midi_connected
Section titled “midi_connected”fn midi_connected() -> Boolean or String or DictChecks the current MIDI connection status.
Returns: Boolean | String | Dict — false if no ports connected, the port name String if one default port is connected, or a {alias: port_name} Dict for multiple ports
midi_disconnect
Section titled “midi_disconnect”fn midi_disconnect() -> NULfn midi_disconnect(alias: String) -> NULDisconnects the MIDI output port with the given alias.
Example:
midi_disconnect("synth")
Parameters:
alias(String) — port alias to disconnect
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) — the alias used when connecting
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
Section titled “midi_latency”fn midi_latency() -> NULfn midi_latency(mode: String) -> StringSets 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:
midi_latency("manual")
Parameters:
mode(String) —"auto"or"manual"
Returns: String — the mode just set
midi_port_clock
Section titled “midi_port_clock”fn midi_port_clock(alias: String) -> Booleanfn midi_port_clock(alias: String, enabled: Boolean) -> BooleanOpts a MIDI output port in or out of receiving clock.
Example:
midi_port_clock("daw", false)
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entryenabled(Boolean) —trueto send clock to this port,falseto stop
Returns: Boolean — the resulting opt-in state
midi_port_clock_trim
Section titled “midi_port_clock_trim”fn midi_port_clock_trim(alias: String) -> Numberfn midi_port_clock_trim(alias: String, ms: Number) -> NumberSets a MIDI output port’s clock-only trim in milliseconds. Added on top of midi_port_trim, and applied only to clock and transport messages. For gear whose clock input settles differently from its note input.
Example:
midi_port_clock_trim("cv", -2.5)
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entryms(Number) — trim in milliseconds, within ±500
Returns: Number — the trim value just set
midi_port_trim
Section titled “midi_port_trim”fn midi_port_trim(alias: String) -> Numberfn midi_port_trim(alias: String, ms: Number) -> NumberSets a MIDI output port’s timing trim in milliseconds. Applies to notes and clock alike. Use it to correct one device that responds late or early — positive sends later, negative earlier. Alignment with the audio output is already automatic; this is the per-device correction on top.
Example:
midi_port_trim("cv", -2.5)
Parameters:
alias(String) — port alias, from its[[midi.outputs]]entryms(Number) — trim in milliseconds, within ±500
Returns: Number — the trim value just set
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
Section titled “midi_routing”fn midi_routing() -> 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() -> NULfn midi_trace(on: Boolean) -> BooleanStart or stop the MIDI timing trace. true clears the buffer and begins recording; false stops and prints what was captured.
Example:
midi_trace(true)
Parameters:
on(Boolean) —trueto start recording,falseto stop and report
Returns: Boolean — whether the trace is now recording