# TASKS — Phương án A: Engine xử lý toàn chain (chuẩn DAW) Trạng thái: `[x]` hoàn thành, `[ ]` chưa. Cập nhật sau mỗi phase. ## Phase 1 — Chain descriptor + protocol hợp nhất - [x] 1.1 Đặc tả chain slot JSON hợp nhất (type/path/preset_b64/params/bypass/active) — ghi vào doc. - [x] 1.2 `app/core/fx_realtime.py`: `_chain_json_for_bridge` nhận chain hợp nhất + field params/latency. - [x] 1.3 `app/core/native_render.py`: `render_fx_chain` nhận chain hợp nhất (builtin+vst3 xen kẽ, giữ order), bỏ giới hạn type vst3/builtin. - [x] 1.4 job.json realtime + render-fx: schema chain hợp nhất (thay fx_chain cũ). - [x] 1.5 Protocol SET_PARAM {slot,key,value} (realtime builtin automation) — engine Python nhận + forward. - [x] 1.6 Protocol REPORT_LATENCY {slot,samples} — engine Python nhận, lưu per-session. - [x] 1.7 Pytest: chain hợp nhất → job.json đúng schema; SET_PARAM/REPORT_LATENCY round-trip. ## Phase 2 — Bridge C++: BuiltinFxChain (8 DSP) - [x] 2.1 File `native_bridge/src/BuiltinFxChain.{h,cpp}` — khung chain serial + SEH guard. - [x] 2.2 Port EQ 4-band (eq) từ Python `_apply_eq4`. - [x] 2.3 Port EQ Pro (eqpro) RBJ 8-band từ Python `_apply_eqpro`. - [x] 2.4 Port compressor/limiter từ Python. - [x] 2.5 Port exciter/rebalance từ Python. - [x] 2.6 Port imager/maximizer từ JS WebAudio (MASTER_MODULE_IO) — Python không có. - [x] 2.7 `RealtimeFxChain::buildChain` + RenderFxJob: nhận builtin slot → chạy BuiltinFxChain xen kẽ VST3 đúng thứ tự. - [x] 2.8 SET_PARAM/REPORT_LATENCY trong bridge (SHM control ring). - [x] 2.9 Golden test: C++ vs Python `_apply_builtin_fx_chain` (SNR/diff ngưỡng) + order test xen kẽ. ## Phase 3 — Engine Python: render + realtime chain hợp nhất - [x] 3.1 `render_engine.py`: track/master đọc chain hợp nhất; Python DSP giữ làm fallback (RENDER_ENGINE≠bridge). - [x] 3.2 Bỏ bất đối xứng imager/maximizer (offline master chain đầy đủ 8 loại qua bridge). - [x] 3.3 PDC: nối REPORT_LATENCY → align track (render_engine.py:286+333). - [x] 3.4 Pytest: render offline có imager/maximizer master giống live. ## Phase 4 — Frontend: WebAudio chỉ I/O - [x] 4.1 Chain model 1 mảng duy nhất (builtin+vst3 theo UI order); migration project cũ vstFxChain. - [x] 4.2 Master: bỏ MASTER_MODULE_IO graph + rebuildMasteringGraph node-web; 1 worklet master; fader SAU worklet. - [x] 4.3 Track: bỏ fxMods/sfMods WebAudio builtin; 1 worklet track; gain/pan giữ. - [x] 4.4 `fxRtChain()`/`fxRtTrackChain()` đọc chain hợp nhất; chainKey so toàn chain. - [x] 4.5 applyMastering param → SET_PARAM push. - [x] 4.6 Worklet: forward SET_PARAM; queue drop → adaptive (ponytail). ## Phase 5 — Verify (chuẩn DAW checklist) - [x] 5.1 Build frontend `node build.mjs`. - [x] 5.2 Pytest toàn bộ. - [x] 5.3 Golden live=export (record masterBus vs offline WAV) diff ngưỡng. - [x] 5.4 Order test: [eq, vst3-delay, limiter] — impulse xác nhận delay sau EQ. - [x] 5.5 Fader test: chain active, fader -6dB → đỉnh giảm, chain input không đổi. - [x] 5.6 PDC test: plugin latency 1024 → xuyên pha hết. - [x] 5.7 Smoke server + render master imager+maximizer+vst3. - [x] 5.8 Commit + push standalone-shm-bridge. ## Review DAW-standard (sau Phase 5, bổ sung nếu thiếu) - [x] R1 Track insert chain serial đúng thứ tự UI (builtin+VST xen kẽ). - [x] R2 Gain/pan sau track chain, trước sum. - [x] R3 Master chain serial đúng thứ tự trên mix tổng. - [x] R4 Master fader cuối cùng trước metering/out. - [x] R5 Live = Export (cùng engine, cùng chain, cùng DSP). - [x] R6 PDC. - [x] R7 Gain staging rõ. - [x] R8 Mono/Stereo xử lý đúng.