How the layers communicate
A reference of the soundor-plugin-architecture skill.
soundor-plugin-architecture reads this reference when a task needs it. Source on GitHub
What each Soundor mechanism carries, between which threads, and what it is part of. Based on Soundor 0.21; confirm details in the installed version.
| Mechanism | From → to | Saved with session | DAW automation | Presets | History (undo) | Real-time safe on the audio side |
|---|---|---|---|---|---|---|
| Parameter | UI, controller, host → processor | yes | unless manual | yes | yes | yes (ctx.params, per block) |
| Read-only parameter | processor → host, UI | no | shown only | no | no | yes (ctx.publish) |
| State | UI, controller → UI, controller | yes | no | yes | yes | not read by the processor |
State, audio: true | UI, controller → processor | yes | no | yes | yes | yes (ctx.state, snapshot) |
| Native stream | processor (or controller) → UI | no | no | no | no | yes (ctx.streams, latest wins) |
| Audio resource | prepare(), controller → processor | no | no | no | no | yes (ctx.resources, swapped) |
| Native method | UI → controller | no | no | no | no | never on the audio thread |
| Native event | controller → UI | no | no | no | no | never on the audio thread |
soundor:storage | UI ↔ disk (per plugin, all instances) | no (per machine) | no | no | no | no |
Parameters
Declared in soundor.config.ts, typed everywhere: soundor:parameters in
the UI, ctx.params (a generated struct, snake_case fields) in the
processor, ctx.params.<id> with get()/set() in the controller. The
processor sees one value per block. Writes from any source are clamped and
snapped to the step; subscribers hear changes, not repeated writes.
State
Typed application data, declared under state with a default per field,
using the native type registry (structs, enums, arrays, nullable values).
The UI reads it with soundor:state (useStateValue in React); the
controller with ctx.state. Fields with audio: true (numbers, booleans,
and arrays of them with a maxLength) also reach the processor as a
coherent snapshot at the start of the next block; all audio fields together
may take at most 8 MiB.
Streams
Declared under native.streams: one number, or a buffer<T> with a
maxLength. The processor publishes with ctx.streams.<name>.publish(v),
or for buffers writes buffer_mut() then commit(len), without locks or
allocation. The UI gets the latest value at most once a frame
(useNativeStream for markup; subscribe in an effect for drawing).
Values in between are skipped, never queued, so a stream cannot carry
events that must all arrive.
Resources
Declared under native.resources as buffer<T>. Published whole from
prepare() or the controller (ctx.processor.resources().<name>.publish),
read in process() with ctx.resources.<name>.get() as a slice that does
not change during a block. A replaced resource is freed off the audio
thread. Not saved: republish them in prepare() from state, parameters and
the sample rate.
Native methods and events
Declared under native.methods and native.events; implemented in Rust by
the controller (impl NativeMethods), and called from the UI as typed
functions in soundor:native. Synchronous methods run inside the UI's call
and must be quick; slow work is an async: true method, whose future runs
on the controller's worker. Blocking work inside it goes to
soundor::unblock. Callbacks that touch parameters, state or History are
scheduled back onto the control thread with ctx.schedule.
There are no arbitrary message queues between the UI and the processor: everything the processor reads arrives as a parameter, audio state, or a resource.
Choosing between close options
- Parameter or state? If a host should see, automate or show it, it is a parameter. If it is structured, a list, text, or has no single numeric range, it is state.
- Read-only parameter or stream? A read-only parameter is one value the host also shows (gain reduction). A stream is for the UI only, and can be a buffer (a spectrum).
- Audio state or resource? Audio state is session data the user edits (bounded, saved). A resource is derived data (computed tables, loaded audio) the processor reads, rebuilt rather than saved.
- Method or state write? Write state directly from the UI when it is a plain edit; call a method when Rust must compute, load or validate something.