Phase 2: BuiltinFxChain C++ (8 DSP) + control ring SET_PARAM/REPORT_LATENCY

- native_bridge/src/BuiltinFxChain.{h,cpp}: 8 builtin DSP port 1:1 từ
  Python _apply_builtin_fx_chain (eq/eqpro/compressor/limiter/exciter/rebalance)
  và JS MASTER_MODULE_IO (imager/maximizer). Biquad RBJ DF2T, block-wise
  stateful. createBuiltinFx trả nullptr cho gain/normalize (legacy).
- RenderFxJob: FxSlot thêm bfx, parse builtin 8 loại, runBuiltinSlotSafe SEH,
  realtimeRunChain nhánh builtin, chainGen()/entryLatencies(), setParam
  áp live lên bfx; Vst3Fx latencySamples từ getLatencySamples().
- RealtimeFxLoop: drain ctrl ring (SET_PARAM -> chain.setParam, drop cũ khi
  đầy) + REPORT_LATENCY khi gen đổi (ipc->lat[] ring, lastGen).
- FxRealtimeIPC.h: header 18 u32 (72B), ctrl/lat slots 8, FxCtrlCmd 24B,
  FxLatReport 8B, static_asserts.
- app/core/fx_realtime.py: mirror header 72B (ctrl_write/read, lat_write/read,
  slots), set_param ghi ctrl ring qua _ctrl_enqueue_locked (guard shm),
  get_latencies drain lat ring qua _lat_drain.
- tests/test_builtin_fx_golden.py: golden SNR C++ vs Python (8 cases, ngưỡng
  30dB) + order test eq/compressor xen kẽ.
- TASKS_DAW_A.md: tick 2.1-2.9.

Test: 136 passed (4 fx_realtime_chain + 8 builtin golden + regression).
This commit is contained in:
2026-08-22 19:55:08 +07:00
parent fd790c1dc6
commit 1390ad545b
10 changed files with 980 additions and 29 deletions
+10
View File
@@ -5,6 +5,7 @@
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
// Offline FX render mode (Phase 0 of PLAN_MASTERBUS_FX_RACK_VST.md):
// `daw_vst_bridge --render-fx <job.json> --in <input.wav> --out <output.wav>`
@@ -72,6 +73,15 @@ public:
// JSON: [{"path":"...","bypass":true|false},...] — chain entries replace
// the previous chain atomically. May be called from any thread.
void setChain(const std::string& json, double sampleRate, int32_t blockSize);
// SET_PARAM (Phase 2.8): áp dụng live vào builtin slot (slot index theo
// chain JSON). Gọi từ loop thread.
void setParam(int slot, const std::string& key, double value);
// Phase 2.8 (SHM control ring): chain generation — tăng mỗi lần worker
// swap chain; RealtimeFxLoop so gen → báo lại latency qua lat ring.
uint64_t chainGen();
// Per-slot latency samples (thứ tự khớp chain JSON): builtin = 0 (IIR
// zero-latency), VST3 = getLatencySamples (đọc lúc load) — PDC Phase 3.
std::vector<uint32_t> entryLatencies();
// Audio thread only: run the chain in-place over one stereo block.
void process(float* inL, float* inR, uint32_t n);
void shutdown();