Γ-W1-T2 review: one restart funnel, tighter ceiling proof, effective-gain meter

Fold setLimiterEnabled's restart request into setInstrumentParams so every writer
keeps the host's latency report in sync. Pin the window-sizing identity, drop the
per-sample modulo, tighten the ceiling tolerance, publish the blended gain.
This commit is contained in:
2026-08-01 19:34:08 -04:00
parent 3baf4ee50b
commit 0612abbddb
5 changed files with 77 additions and 26 deletions
+17 -12
View File
@@ -149,14 +149,25 @@ InstrumentParams ReaSamplerProcessor::instrumentParams() {
}
void ReaSamplerProcessor::setInstrumentParams(const InstrumentParams& params) {
bool limiterFlagChanged = false;
{
std::lock_guard<std::mutex> lock(paramsMutex_);
limiterFlagChanged = (params_.limiterEnabled != params.limiterEnabled);
params_ = params;
}
// Every writer of the parameter set — setState, the editor's commits, the bake's adopt —
// funnels through here, so mirroring the limiter flag at this one point is what keeps the
// audio thread's copy and the latency report from ever lagging what is persisted.
// audio thread's copy and the latency report from ever lagging what is persisted, and
// requesting the restart here (not just from setLimiterEnabled) is what keeps the host's
// PDC from lagging it too. Coalesced: writing the value already held requests nothing.
publishLimiterEnabled(params.limiterEnabled);
if (limiterFlagChanged && componentHandler) {
// The SDK requires this on the UI thread and answers getLatencySamples only after the
// host's own deactivate/reactivate — so the flag above is already committed by the time
// the host asks. This is a kLatencyChanged restart with the bus untouched, NOT the
// retired per-mode kIoChanged bus renegotiation (see initialize()); do not conflate.
componentHandler->restartComponent(kLatencyChanged);
}
}
void ReaSamplerProcessor::publishLimiterEnabled(bool on) {
@@ -165,17 +176,11 @@ void ReaSamplerProcessor::publishLimiterEnabled(bool on) {
}
void ReaSamplerProcessor::setLimiterEnabled(bool on) {
{
std::lock_guard<std::mutex> lock(paramsMutex_);
if (params_.limiterEnabled == on) return; // no change: no restart to request
params_.limiterEnabled = on;
}
publishLimiterEnabled(on);
// The SDK requires this on the UI thread and answers getLatencySamples only after the host's
// own deactivate/reactivate — so the flag above is already committed by the time the host
// asks. This is a kLatencyChanged restart with the bus untouched, NOT the retired per-mode
// kIoChanged bus renegotiation (see initialize()); do not conflate the two.
if (componentHandler) componentHandler->restartComponent(kLatencyChanged);
// Thin wrapper: setInstrumentParams is the one funnel that mirrors the flag AND requests
// the restart, so every writer of the parameter set — this one included — agrees.
InstrumentParams params = instrumentParams();
params.limiterEnabled = on;
setInstrumentParams(params);
}
MasterBusMeter ReaSamplerProcessor::masterBusMeter() const {
+4 -3
View File
@@ -232,9 +232,10 @@ public:
void setMasterGainLinear(double linear); // clamped to [0, masterGainMaxLinear()]
// The master-bus limiter's single enable (persisted in the parameter set). UI thread only:
// the setter requests the host's kLatencyChanged restart, which the SDK requires be issued
// from the UI thread and which process() must therefore never trigger. Setting the value it
// already holds is a no-op, so repeated clicks on one segment cost no restart.
// a thin wrapper over setInstrumentParams, the one funnel that both mirrors the flag and
// requests the host's kLatencyChanged restart, which the SDK requires be issued from the UI
// thread and which process() must therefore never trigger. Setting the value it already
// holds is a no-op, so repeated clicks on one segment cost no restart.
bool limiterEnabled() const {
return limiterEnabled_.load(std::memory_order_relaxed);
}