Skip to content

std/midi

Always in scope — no import required.

MIDI output: tracks, control-change lanes, and port management.

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.

fn set_send_rate(hz: Number) -> CcOutput

Set 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: a MIDI output port and channel, a destination for >> — Live’s “MIDI To”. Made by MidiOutput(alias, channel); it can only end a >> chain.

fn MidiOutput(alias: String, channel: Number? = NUL) -> MidiOutput

A 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 it
  • channel (Number?) — MIDI channel 1-16 (optional; default 1)

Returns: MidiOutput — the port and channel, to route to with >>

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.

fn MidiTrack(name: String) -> MidiTrack

Creates 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, and audio and MIDI tracks share them: a name a live AudioTrack has is an error. So changing a line from AudioTrack("x") to MidiTrack("x") and running it again fails while the old track is still bound; rename it, or let it go first.

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

fn set_input(alias: String, channel: Number? = NUL) -> MidiTrack

Set 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 input
  • channel (Number?) — MIDI channel 1-16 (optional)

Returns: MidiTrack — the track, for chaining

fn set_monitor(mode: Monitor) -> MidiTrack

Set 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

fn set_velocity(vel: Number | Signal | Pattern) -> MidiTrack

Set 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 (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) -> CcOutput

Get 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 <<

fn set_tuning(bend_range: Number? = NUL) -> MidiTrack

Enable 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

fn set_mpe(range: Number? = NUL, zone_lo: Number? = NUL, zone_hi: Number? = NUL) -> MidiTrack

Enable 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

fn set_key(scale: Key | String | Scale, root: Note? = NUL) -> MidiTrack

Set 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 value
  • root (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() -> MidiTrack

Mutes 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

fn unmute() -> MidiTrack

Unmutes the track. Its pattern is heard again from its next note.

Returns: MidiTrack — the track, for chaining

fn is_muted() -> Boolean

Returns whether the track is muted.

Returns: Boolean — true if the track is muted

fn solo() -> MidiTrack

Solos 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

fn add_solo() -> MidiTrack

Adds 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

fn unsolo() -> MidiTrack

Releases the track’s solo. When no track is soloed, every track is heard.

Returns: MidiTrack — the track, for chaining

fn is_soloed() -> Boolean

Returns whether the track is soloed.

Returns: Boolean — true if the track is soloed

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.
fn midi_clock_report() -> NUL

Print MIDI clock status: source, BPM, transport state, and PLL diagnostics.

Example:

midi_clock_report()

Returns: NUL — nothing; prints the status

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

fn midi_disconnect(alias: String) -> NUL

Disconnects 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

fn midi_input_disconnect(alias: String) -> NUL

Disconnects 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

fn midi_input_ports() -> Array<String>

Lists all available MIDI input ports.

Returns: Array — the available input port names as Strings

fn midi_latency_report() -> NUL

Print 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

fn midi_port_clock(alias: String) -> Boolean

Returns 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

fn midi_port_clock_trim(alias: String) -> Number

Returns 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

fn midi_port_trim(alias: String) -> Number

Returns 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

fn midi_ports() -> Array<String>

Lists all available MIDI output ports.

Returns: Array — the available output port names as Strings

fn midi_routing_report() -> NUL

Displays the current MIDI routing: connected output/input ports and active slots.

Returns: NUL — nothing; prints the routing

fn midi_trace_report() -> NUL

Print 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

fn set_midi_clock_send(enabled: Boolean) -> NUL

Enable/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) — true to enable, false to disable

Returns: NUL — nothing

fn set_midi_clock_source(alias: String? = NUL) -> NUL

Sets 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

fn set_midi_latency(mode: MidiLatency) -> NUL

Sets how outgoing MIDI is aligned with the audio output.

Example:

set_midi_latency(MidiLatency.manual)

Parameters:

  • mode (MidiLatency) — the alignment; MidiLatency.auto is the default

Returns: NUL — nothing

fn set_midi_trace(on: Boolean) -> NUL

Start 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) — true to start recording, false to stop and report

Returns: NUL — nothing