// native_bridge/include/BuiltinFxChain.h // Builtin DSP chain (PLAN_DAW_A.md Phase 2): 8 custom FX được port từ Python // (render_engine.py `_apply_builtin_fx_chain`) + JS WebAudio (imager/maximizer, // MASTER_MODULE_IO). Serial, in-place, stereo — engine xử lý TOÀN chain; chạy // xen kẽ VST3 đúng thứ tự UI trong RenderFxJob (offline) + RealtimeFxChain. #pragma once #include #include #include #include // Forward: sheredom JSON object (params). Khai báo để factory dùng. struct json_object_s; // Một FX builtin — stateful giữa các block (biquad z1/z2, env compressor...). class BuiltinFx { public: virtual ~BuiltinFx() = default; // Xử lý 1 block stereo in-place (L/R song song, interleaved-wise). virtual void process(float* L, float* R, uint32_t n) = 0; // SET_PARAM (SHM control ring, Phase 2.8): cập nhật tham số live. // Trả false nếu slot không có param này (gọi từ realtime loop thread, // cùng thread process → không cần lock). virtual bool setParam(const std::string& key, double value) { (void)key; (void)value; return false; } }; // Chain serial các BuiltinFx — giữ NGUYÊN thứ tự thêm vào. class BuiltinFxChain { public: explicit BuiltinFxChain(double sampleRate) : sampleRate_(sampleRate) {} void add(std::unique_ptr fx, bool bypass); // Chạy toàn chain serial, in-place. void process(float* L, float* R, uint32_t n); bool setParam(int slot, const std::string& key, double value); size_t size() const { return entries_.size(); } private: struct Entry { std::unique_ptr fx; bool bypass = false; }; std::vector entries_; double sampleRate_; }; // Factory: id ∈ eq|eqpro|imager|maximizer|compressor|limiter|exciter|rebalance // |gain|normalize (gain/normalize legacy giữ ở RenderFxJob — factory trả // nullptr cho 2 loại này). params = JSON object (sheredom), có thể null. std::unique_ptr createBuiltinFx(const std::string& id, const json_object_s* params, double sampleRate);