T13: NativeMixer mirror server pipeline (track gain/pan constant-power + brickwall limiter tanh, wired VST2/VST3 bridge, golden test 0.0001dB)

This commit is contained in:
2026-08-11 16:53:15 +07:00
parent 8f1e89ce50
commit b9817e1aed
7 changed files with 404 additions and 3 deletions
+27 -1
View File
@@ -33,6 +33,7 @@
#include "pluginterfaces/vst/ivstevents.h"
#include "AudioEngine.h"
#include "NativeMixer.h"
#include <atomic>
@@ -99,6 +100,7 @@ struct Instance
ComponentHandler handler;
sonicforge::AudioEngine audio; // T12: native audio loop (SPSC + WASAPI)
std::atomic<bool> audioRunning {false};
sonicforge::NativeMixer mixer; // T13: track gain/pan + master limiter
};
// T12: IEventList cố định (không cấp phát trên audio thread).
@@ -189,7 +191,9 @@ bool vst3AudioProcess (const sonicforge::MidiEvent* events, int32 eventCount,
data.outputs = &outBus;
data.inputEvents = &list;
return proc->process (data) == kResultOk;
const tresult res = proc->process (data);
inst->mixer.processInPlace (outL, outR, frames); // T13: gain/pan + limiter
return res == kResultOk;
}
std::mutex g_mutex;
@@ -547,4 +551,26 @@ __declspec (dllexport) int32 SF_VST3_SendNoteOff (int32 handle, int32 channel, i
return it->second->audio.pushMidi (ev) ? 0 : -2;
}
// T13: track gain/pan + master limiter (NativeMixer). Set truoc AudioStart;
// audio thread doc state nay (khong lock).
__declspec (dllexport) int32 SF_VST3_SetTrackGainPan (int32 handle, float gainDb, float pan)
{
std::lock_guard<std::mutex> lock (g_mutex);
auto it = g_instances.find (handle);
if (it == g_instances.end ())
return -1;
it->second->mixer.setTrack (sonicforge::TrackGainPan::fromDbPan (gainDb, pan));
return 0;
}
__declspec (dllexport) int32 SF_VST3_SetMasterLimiter (int32 handle, int32 active, float thresholdDb)
{
std::lock_guard<std::mutex> lock (g_mutex);
auto it = g_instances.find (handle);
if (it == g_instances.end ())
return -1;
it->second->mixer.setLimiter (active != 0, thresholdDb);
return 0;
}
} // extern "C"