user_settings.h
Settings that belong to the USER, not to the session.
#include <sonore/user_settings.h>- 1type
- 3other declarations
- Guides: Testing your plugin
On this page
Design notes
A plugin has two kinds of persistent state and hosts only understand one of them. The session blob is per-instance: this reverb, on this track, in this project. But a plugin also accumulates things that belong to the person using it: where their sample folder is, what scale their editor should open at, which one-time notice they have already dismissed, which output device the standalone last used.
Putting any of that in the session blob gets it wrong in both directions. It travels to whoever the project is sent to, carrying a path that does not exist on their machine; and it is absent from every NEW instance, so the preference the user set five minutes ago does not apply to the next plugin they add.
A properties file, and here it is the same StateBag the session uses, written to a per-user file: deliberately the same, because a second key/value format is a second parser to get wrong, and this one is already exercised by every state round-trip in the suite.
MAIN THREAD ONLY. It opens files.
Types 1
A plugin's per-user settings, loaded from and saved to one file.
Every instance of a plugin shares the file, and nothing coordinates them: two editors open at once, both saving, and the last writer wins. That is the right trade for preferences (the alternative is a lock held across a file write in a process that must never block), but it means this is for things a user SETS, not for anything a plugin accumulates continuously.
Functions 3
- fn
inline std::string userDataRoot()Where this machine keeps per-user application data.user_settings.h:62 - fn
inline bool ensureDirectory(const std::string& path)Make a directory and its parents. Existing is success, which is the whole reason this is not one call: mkdir -p is not in the standard library and every caller writes a slightly different version of it.user_settings.h:85 - fn
inline std::string userSettingsPath(const char* pluginId, const char* leaf = "settings")One plugin's settings file. Named by the plugin id, which is the only identifier guaranteed stable across versions and renames.user_settings.h:118