Files
reasampler/src/ext_keys.h
T

85 lines
4.4 KiB
C++

#pragma once
// ext_keys — the SINGLE SOURCE OF TRUTH for the "reasampler" project ext-state
// namespace + key names, shared by the extension (writer, via shell/persist) and the
// VST3 instrument (reader, via the bridge), so the wire contract cannot drift
// between the two artifacts.
//
// PURE HEADER: NO REAPER/VST3/SWELL/vendor types. Key spellings are string
// constants; the namespace is channel-derived (delegates to app_version, also SDK-free).
//
// FOREVER-STABLE once shipped: these strings key every already-saved project's
// stored state. Changing any of them orphans that state. See
// shell/persist/ext_state_io.h for per-key retirement/migration semantics.
#include "core/version/app_version.h"
namespace reasampler {
// Channel-derived so the extension (writer) and the VST3 instrument (reader)
// resolve the SAME namespace per channel ("reasampler" / "reasampler_beta") —
// without this a beta instrument would read the stable namespace and see nothing.
inline const char* kProjExtNamespace() { return version::extStateNamespace().c_str(); }
// The whole serialized BankBook (pool + named banks) — read-only by the VST3
// instrument. ext_state_io documents the legacy-key migration around it.
inline constexpr const char* kProjExtBanksKey = "banks";
// The retired legacy single-bank key (read once on load to migrate into the pool).
inline constexpr const char* kProjExtIndexKey = "bank_index";
// The Design-View model key.
inline constexpr const char* kProjExtViewKey = "view_state";
// The docked panel's tail-setting key.
inline constexpr const char* kProjExtTailKey = "tail_setting";
// The per-project minted-GUID identity key.
inline constexpr const char* kProjExtGuidKey = "project_guid";
// The EXTENSION stamps a monotonic counter here, bumped on every bank-content
// mutation that changes what a live instance would PLAY. The VST3 instrument reads
// it on a UI-timer cadence and calls reloadInstrument() on a change; it never
// writes this key. Additive: an absent stamp reads as generation 0 (pre-existing
// projects). FOREVER-STABLE — changing the spelling resets every shipped instance's
// change-detection baseline (a one-time spurious reload).
inline constexpr const char* kProjExtBankGenKey = "bank_generation";
// The EXTENSION writes an assignment request here after an ingest-with-assign:
// "the active sampler instance should now play THIS sample." Value is the pure
// assignment_request wire format ("rsassign1" + bankId + sampleId + generation).
// The instrument reads it to update its own selection and reload; it never writes
// it. FOREVER-STABLE — changing the spelling strands any pending request an
// already-shipped instrument watches.
inline constexpr const char* kProjExtAssignKey = "assign_request";
// The INSTRUMENT writes one key per instance — "rsusage_<instanceGuid>" — carrying
// the sample_usage wire record of every capture that instance holds; the EXTENSION
// enumerates the prefix at prune-scan time so a held capture can never be pruned.
// This is one of the TWO sanctioned instrument-side ext-state writes (the bake
// request below is the other; neither mutates banks/view/tail/assign, and the
// bridge's write entry points structurally accept only these two prefixes). The
// "rs" qualifier keeps a future "usage_*"-prefixed key from being
// swept into the FX-liveness fold. FOREVER-STABLE — changing the prefix strands
// every saved project's usage records (prune falls back to bank-references-only
// until instances republish).
inline constexpr const char* kProjExtUsageKeyPrefix = "rsusage_";
// Shared by the instrument's writer and the extension's enumerator.
inline std::string usageKeyFor(const std::string& instanceGuid) {
return std::string(kProjExtUsageKeyPrefix) + instanceGuid;
}
// The resample bake's one key per asking instance — "rsbake_<instanceGuid>". The
// INSTRUMENT writes the request here and the EXTENSION writes its outcome back over the
// same key, within one synchronous action invocation; the instrument then clears it. The
// second of the two prefixes the instrument may write (the guard itself lives in
// reaper_bridge.h). Nothing durable is keyed off this spelling, but a stale value from a
// crashed session must still decode or be ignored — so treat it as fixed anyway.
inline constexpr const char* kProjExtBakeKeyPrefix = "rsbake_";
inline std::string bakeKeyFor(const std::string& instanceGuid) {
return std::string(kProjExtBakeKeyPrefix) + instanceGuid;
}
} // namespace reasampler