feat(persist): persist BankBook under banks key, retire legacy bank_index, route capture to active bank (B2)

This commit is contained in:
2026-07-23 20:26:15 -04:00
parent 5b19525ec0
commit 85993ebc3e
6 changed files with 218 additions and 55 deletions
+12 -8
View File
@@ -111,9 +111,10 @@ static int g_cmdCancelRealtime = 0;
// The persistence session (M4): owns the in-memory BankIndex and bridges it to
// project ext state. A timer tick drives g_session.poll() to detect project
// load / Save-As; capture adds Samples to g_session.bank(); after a capture we
// serialize the bank back into the active project's ext state so it travels with
// the .rpp. Replaces the M3 session-only g_bank.
// load / Save-As; capture adds Samples to g_session.bank() — which (B2) resolves to
// the ACTIVE bank's index inside the session's BankBook; after a capture we serialize
// the book back into the active project's ext state (the `banks` key) so it travels
// with the .rpp. Replaces the M3 session-only g_bank.
static reasampler::ReaSamplerSession g_session;
// --- M8 in-flight realtime capture (async, timer-driven) --------------------
@@ -133,8 +134,9 @@ static reasampler::RealtimeCaptureHandle g_rtCapture;
static ReaProject* g_rtCaptureProject = nullptr;
// Commit a finished realtime capture (a Done tick/abort with an Ok result): add the
// Sample to the bank, persist + MarkProjectDirty, log. Shared by the tick-completion
// path and the abort paths. On a non-Ok result, logs the failure only.
// Sample to the ACTIVE bank (g_session.bank() resolves to book.activeIndex() — B2),
// persist + MarkProjectDirty, log. Shared by the tick-completion path and the abort
// paths. On a non-Ok result, logs the failure only.
static void CommitRealtimeResult(const reasampler::CaptureResult& res)
{
if (res.status != reasampler::CaptureStatus::Ok)
@@ -547,10 +549,12 @@ static void RunCapture(const reasampler::CaptureActionDef& def)
return;
}
// Add to the ACTIVE bank: g_session.bank() resolves to book.activeIndex() (B2).
reasampler::AddResult added = g_session.bank().add(res.sample);
// Persist the updated bank into the active project's ext state so the capture
// survives Save / close+reopen (M4) and travels with the .rpp. saveToActiveProject
// also calls MarkProjectDirty. Non-destructive: writes only our own ext-state key.
// Persist the updated book into the active project's ext state (the `banks` key)
// so the capture survives Save / close+reopen (M4) and travels with the .rpp.
// saveToActiveProject also clears the retired legacy key and calls MarkProjectDirty.
// Non-destructive: writes only our own ext-state keys.
g_session.saveToActiveProject();
std::string log = "ReaSampler: " + res.message + "\n";