Skip to Content
Soundor Skills

Lifecycle, layouts, MIDI and timing

A reference of the soundor-plugin-architecture skill.

soundor-plugin-architecture reads this reference when a task needs it. Source on GitHub

The processor's lifecycle

  1. Construct: Default::default(), outside the audio callback.
  2. prepare(ctx): sample rate, maximum block size, the negotiated layout (ctx.layout.inputs(), outputs(), name()), the current parameters and audio state. Allocate buffers, build filters and FFT plans, publish resources. Runs again whenever the configuration changes; it may follow process() calls at another sample rate.
  3. process(ctx): every block. Block sizes vary, up to the prepared maximum (adapters split larger host blocks), and may be zero.
  4. reset(): clear signal history (delay lines, filter memory, envelopes, voices) and keep capacity. Called between blocks, for example after a transport jump or a MIDI overflow.
  5. Drop: outside the audio callback.

A panic in native code is caught at the boundary and silences the instance until it is prepared again; in WebAssembly it traps the instance. Never use a panic as control flow.

The controller and the editor

  • The controller lives as long as the instance. On Linux in the VST3 runtime, its scheduled work runs while an editor is open, or when the host lends its run loop: do not depend on it for audio.
  • The editor (and the UI's JavaScript) exists only while open. During soundor dev, every UI rebuild replaces the JavaScript runtime: timers, subscriptions and open gestures end.
  • The UI must render from current parameter and state values when it opens, not assume it saw every change.

Channel layouts and buses

Declared in audio: buses (direction, name, optional), the layouts the plugin supports (each giving every bus an arrangement: 'mono', 'stereo', '5.1', '7.1', or 'disabled' for optional buses), and a defaultLayout. The first bus of each direction is the main one. Without audio, a plugin has a stereo input and output (and mono with mono).

  • Declare only layouts the DSP handles; the host negotiates among them.
  • Main outputs start holding the main input, so in-place processing works; extra output channels start silent; disabled optional inputs have zero channels.
  • Read inputs before writing outputs that alias them.
  • The web runtime supports one main input at most, one main output, mono or stereo; no sidechain or surround.

MIDI

midi: { input, output } declares host MIDI. Events arrive in ctx.midi.input() with a sample_offset within the block; render each at its offset. Output goes through ctx.midi.output().push(event). Buffers hold 1024 events; an overflow requests reset(), so reset() must stop all voices. MIDI 1.0 channel messages only (no SysEx, no MIDI 2.0).

Latency and tail

  • audio.latency declares latency: { mode: 'fixed', samples } is reported to hosts for compensation. { mode: 'dynamic' } is currently reported to VST3 hosts as zero, so a plugin whose latency changes cannot be compensated yet: prefer a fixed worst-case latency.
  • Report latency that matches what the DSP actually delays (lookahead, linear-phase filters, FFT blocks), and test it: the VST3 host's getLatency() returns what a host sees.
  • audio.tail says how long output continues after silent input (reverbs, delays): fixed seconds, or dynamic with ctx.report_tail_seconds().
  • The web runtime has no host compensation; latency there is audible.

Bypass

Hosts may bypass by stopping calls, or by the role: 'bypass' parameter. When the plugin implements bypass, keep the dry signal delayed by the declared latency, crossfade over a few milliseconds, and keep internal state running or reset it deliberately.

Threads

ThreadRunsMay blockMay allocate
Audioprocess(), reset()nono
Controlcontroller methods, scheduled callbacksbrieflyyes
Workerasync controller futuresvia soundor::unblockyes
UIJavaScript, React, renderingno (it janks)yes

JavaScript never runs on the audio thread, and the audio thread never waits for the others.

On this page