Skip to content

Sync to a MIDI Clock

Resonon either sends MIDI clock and leads, or follows a clock from elsewhere — one or the other. Clock runs with the transport of a live session; a file run ends, and its clock with it, after its last statement. The functions are in the MIDI reference; Clock & Alignment explains how both work.

To sync with a DAW on the same machine, share a virtual port. On macOS, open Audio MIDI Setup, choose Window → Show MIDI Studio, double-click IAC Driver and check Device is online. resonon --list-ports then shows IAC Driver Bus 1.

  1. Mark each port that should receive clock with send_clock = true in its entry in ~/.resonon/preferences.toml, and run reload_preferences():

    [[midi.outputs]]
    alias = "daw"
    port = "IAC Driver Bus 1"
    send_clock = true
  2. Turn clock on and play:

    set_midi_clock_send(true);
    set_bpm(120);
    PLAY;
  3. In the DAW, set the transport to follow external MIDI clock from that port.

The port receives clock ticks plus Start, Stop and Continue. Ports without send_clock get none. midi_routing_report() marks each port that receives clock with [clock].

You can turn clock on — for everything, or for one more port — while the music plays: the port is sent the current position and picks up in place. set_midi_clock_send(false), or taking send_clock out, sends it Stop.

  1. Declare the port the clock arrives on as an input:

    [[midi.inputs]]
    alias = "daw"
    port = "IAC Driver Bus 1"
  2. Follow it:

    set_midi_clock_source("daw");
  3. If the piece sends patterns from on_cycle callbacks, run them once for the first cycle — the DAW’s start, not PLAY, starts the transport:

    prime_cycles();
  4. Start the DAW. Resonon takes its tempo, and starts, stops and continues with it.

Turn it off with set_midi_clock_source(). Following turns sending off, and sending turns following off.

Resonon allows for its own output latency and plugin delay, so what you hear lands on the source’s clock. If it still sounds early or late against the source — the source’s own sound comes out after the clock it sends — add clock_trim_ms to the input’s entry and run reload_preferences(). Positive plays resonon later, negative earlier:

[[midi.inputs]]
alias = "drums"
port = "TR-8S"
clock_trim_ms = 3 # the drum machine sounds 3 ms after its clock

The trim can be up to ±500 ms; a value further out is reported and ignored. A reload applies it without closing the port, and the play head moves onto it without a jump.

midi_clock_report(); // source, tempo, transport, and when following: phase, output delay, trim
midi_routing_report(); // the clock mode, and which ports receive clock

If a device gets no clock, check that [clock] appears next to its port. If the tempo won’t lock, check that the source is actually sending clock on the port you follow.