Γ-W1-T2: the master bus — a true-peak limiter whose ceiling is a theorem, the meter's published half, and the plugin's first PDC report

This commit is contained in:
2026-08-01 19:05:57 -04:00
parent 4fa021edae
commit 3baf4ee50b
17 changed files with 1187 additions and 65 deletions
+41 -2
View File
@@ -12,6 +12,7 @@
#include <vector>
#include "pluginterfaces/base/ibstream.h"
#include "pluginterfaces/vst/ivsteditcontroller.h" // RestartFlags::kLatencyChanged
#include "core/instrument/engine/master_gain.h" // masterGainMaxLinear (post-mixer gain clamp)
#include "core/instrument/map/component_state_io.h" // the ComponentState codec
@@ -148,8 +149,46 @@ InstrumentParams ReaSamplerProcessor::instrumentParams() {
}
void ReaSamplerProcessor::setInstrumentParams(const InstrumentParams& params) {
std::lock_guard<std::mutex> lock(paramsMutex_);
params_ = params;
{
std::lock_guard<std::mutex> lock(paramsMutex_);
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.
publishLimiterEnabled(params.limiterEnabled);
}
void ReaSamplerProcessor::publishLimiterEnabled(bool on) {
limiterEnabled_.store(on, std::memory_order_relaxed);
limiter_.setEnabled(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);
}
MasterBusMeter ReaSamplerProcessor::masterBusMeter() const {
MasterBusMeter m;
m.peakL = meterPeakL_.load(std::memory_order_relaxed);
m.peakR = meterPeakR_.load(std::memory_order_relaxed);
m.minGain = meterMinGain_.load(std::memory_order_relaxed);
m.clip = meterClip_.load(std::memory_order_relaxed);
return m;
}
void ReaSamplerProcessor::clearMasterBusClip() {
meterClip_.store(false, std::memory_order_relaxed);
}
void ReaSamplerProcessor::publishLiveParams() {