state_bag.h
State a plugin has beyond its parameters.
#include <sonore/state_bag.h>- 1type
- Guides: Getting started, Parameters and state, Presets
On this page
Design notes
The versioned SNRS blob every format shares stores the parameter values and the bypass flag. That is all a filter or a saturator has. But the moment a plugin loads a FILE (a sampler, a convolution reverb, an IR-based cabinet), its state includes something no float array can express: which file, at what offset, with which loop points, plus whatever curve the user drew.
A plugin whose session reopens with an empty sample slot is a plugin the user does not trust twice, so this is not a nicety.
The design is deliberately dull: an ordered list of key/value pairs where values are bytes. Not JSON, not a tree. A tree invites a schema, a schema invites migrations, and the one thing this must never do is fail to load a session saved by a slightly older build.
Types 1
Key/value state, serialised as part of the plugin's blob.
Reading a key that was never written returns the fallback rather than failing: a plugin gaining a new setting must still open every session saved before that setting existed, and the fallback IS the migration.