Files
SonicForgeStudio/TASKS_DAW_A.md
T
admin 1390ad545b 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).
2026-08-22 19:55:08 +07:00

58 lines
3.7 KiB
Markdown

# 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
- [ ] 3.1 `render_engine.py`: track/master đọc chain hợp nhất; Python DSP giữ làm fallback (RENDER_ENGINE≠bridge).
- [ ] 3.2 Bỏ bất đối xứng imager/maximizer (offline master chain đầy đủ 8 loại qua bridge).
- [ ] 3.3 PDC: nối REPORT_LATENCY → align track (render_engine.py:286+333).
- [ ] 3.4 Pytest: render offline có imager/maximizer master giống live.
## Phase 4 — Frontend: WebAudio chỉ I/O
- [ ] 4.1 Chain model 1 mảng duy nhất (builtin+vst3 theo UI order); migration project cũ vstFxChain.
- [ ] 4.2 Master: bỏ MASTER_MODULE_IO graph + rebuildMasteringGraph node-web; 1 worklet master; fader SAU worklet.
- [ ] 4.3 Track: bỏ fxMods/sfMods WebAudio builtin; 1 worklet track; gain/pan giữ.
- [ ] 4.4 `fxRtChain()`/`fxRtTrackChain()` đọc chain hợp nhất; chainKey so toàn chain.
- [ ] 4.5 applyMastering param → SET_PARAM push.
- [ ] 4.6 Worklet: forward SET_PARAM; queue drop → adaptive (ponytail).
## Phase 5 — Verify (chuẩn DAW checklist)
- [ ] 5.1 Build frontend `node build.mjs`.
- [ ] 5.2 Pytest toàn bộ.
- [ ] 5.3 Golden live=export (record masterBus vs offline WAV) diff ngưỡng.
- [ ] 5.4 Order test: [eq, vst3-delay, limiter] — impulse xác nhận delay sau EQ.
- [ ] 5.5 Fader test: chain active, fader -6dB → đỉnh giảm, chain input không đổi.
- [ ] 5.6 PDC test: plugin latency 1024 → xuyên pha hết.
- [ ] 5.7 Smoke server + render master imager+maximizer+vst3.
- [ ] 5.8 Commit + push standalone-shm-bridge.
## Review DAW-standard (sau Phase 5, bổ sung nếu thiếu)
- [ ] R1 Track insert chain serial đúng thứ tự UI (builtin+VST xen kẽ).
- [ ] R2 Gain/pan sau track chain, trước sum.
- [ ] R3 Master chain serial đúng thứ tự trên mix tổng.
- [ ] R4 Master fader cuối cùng trước metering/out.
- [ ] R5 Live = Export (cùng engine, cùng chain, cùng DSP).
- [ ] R6 PDC.
- [ ] R7 Gain staging rõ.
- [ ] R8 Mono/Stereo xử lý đúng.