State, presets and compatibility
A reference of the soundor-plugin-architecture skill.
soundor-plugin-architecture reads this reference when a task needs it. Source on GitHub
What a host saves, how it comes back, and how to change a plugin people already use.
What a session holds
A DAW saves each plugin instance's parameters (as plain values, constrained
to the current range and step when restored) and declared state, and
restores both when the project opens, often before or without an editor.
Not saved: streams, resources, controller stores, React state, History.
soundor:storage is per machine and shared by all instances, never per
session.
On restore:
- every state field is installed, then subscribers hear the changes, then
state.onRestoredcallbacks run; - History is cleared;
- the processor sees restored parameters and audio state from its next block;
- resources are not restored: republish them in
prepare()(or from the controller) from what was restored.
Design so that a restore arriving at any time, with or without an editor,
leaves the plugin consistent. Do not run expensive work for every field
notification during a restore; react to onRestored instead.
Presets
- Factory presets are
presetsin the config: an id, a name, and the parameter and state values that differ from the defaults. Each preset id is stable; their order is the VST3 program order. - Load them from the UI with
soundor:presets, or from the controller. Loading is one History step when History is enabled. - A DAW saves and loads its own presets (including
.vstpreset) as full plugin state. Saving user presets to files of the plugin's own is not a built-in feature: usesoundor:fsif the plugin needs it.
History
The plugin has one History, shared by the UI and the controller: parameter and state edits with History enabled record entries; a gesture records one entry for the whole drag; transactions group several edits. Automation and restores never record. It holds up to 100 entries by default.
Changing a released plugin
| Change | Effect on existing sessions | Do instead |
|---|---|---|
| Rename a parameter id or state field | value lost, automation lost | keep the id; change the label |
Change plugin.id | DAWs see a different plugin | never |
| Reorder or remove choice options | saved index means another option | append new options; keep old ones (label them "legacy") |
| Change a range, mapping or step | automation (normalized) means other values; saved values outside the range are clamped | add a new parameter; leave the old one declared and ignored |
| Change a default | affects new instances only | fine; say so in the changelog |
| Add a parameter or state field | old sessions get its default | choose a default that sounds like the old behavior |
| Remove a parameter | automation of it disappears | keep it declared, ignore it, and hide it from the UI |
| Change the processing | old sessions sound different | gate it behind a new mode or parameter whose default is old |
Keep a test that restores a session saved by the previous release (an
end-to-end test can save getState() output as a fixture) and checks
what it sounds and shows like.
Instances
Two instances in one DAW share nothing but soundor:storage and the
filesystem. Never keep mutable plugin data in Rust statics or module-level
JavaScript variables that outlive an instance; use the controller's stores
(per instance) or state.