- calibrate: probe sandbox (jbridge) theo real-time pacing — child render qua SHM
consumer-sync, probe µs-speed chỉ đo được silence/attack → makeup=1.0 mọi channel.
Thêm virtual probeNeedsRealtime() (SandboxVst2Host → true), calibrate() Sleep
~1 block/5.8ms để child kịp nhận MIDI + render steady-state → makeup đo peak thật
(3 channel Qin ≈ 2.6, trước đây = 1.0 → âm lượng đồng đều giữa các track/VSTi).
- OPEN_GUI: SetWindowPos(HWND_TOPMOST) + SetForegroundWindow + BringWindowToTop
→ GUI VSTi hiển thị ở top window, tương tác ngay.
- /api/v1/plugins/available: filter vst_instruments + extra theo is_fx của
fx_vst_bridge --scan (trước merge entry) — modal Select Instrument chỉ còn
soundfont + VSTi, không hiện VST FX (90 → 33).
Root cause: child plugin_host render ~50x real-time (9323 blocks/s), bridge
đọc slot đang bị child ghi đè (torn read) và mỗi segment của 1 DAW block
đọc từ nhiều child block khác nhau -> discontinuity -> tạch thay vì âm thật.
- SandboxHostIPC: thêm bridgeConsumed[2] cuối struct (append-only, offsets
cũ giữ nguyên) — child đếm publish/slot, bridge đếm consume/slot.
- plugin_host_main.cpp: sau khi publish 1 block, chờ bridge consume xong
block đó mới render block kế (wait-sau-publish, không phải wait-trước-
render — wait-trước vẫn cho phép publish 2 block liên tiếp giữa 2 lần
consume -> bridge đọc latest sẽ bỏ block). Child giờ publish đúng 1
block/DAW block = real-time; bridge không bao giờ stall (main loop DAW
render + pace mọi iteration) nên không deadlock; nếu bridge chết,
parent_alive break wait.
- SandboxVst2Host: copy full 256 mẫu vào local buffer khi slot đổi, serve
mọi segment của 1 DAW block từ 1 child block nhất quán.
Verify: child pace 371 blocks/2s (real-time 375, trước 18647); domFreq của
waveform = 257.8Hz đúng nốt C4 (note 60) — âm thật, không phải noise;
correlation giữa các block liên tiếp âm đều ~-0.4 (waveform tuần hoàn);
GUI open path không deadlock (pace vẫn real-time, jBridge dialog + Qin_VST_
Window hiện đủ); GUI đóng -> child idle delta 0; silence_all master peak
0.000016.
- plugin_host_main.cpp WM_CLOSE: destroy host window (sau effEditClose
jBridge dialog cũ vẫn sống trong host; mở lại trên cùng window tạo
jBridge dialog thứ 2 chồng lên -> nền trắng, editor không load). Mở lại
tạo window mới sạch, đúng 1 jBridge dialog + Qin_VST_Window.
- plugin_host_main.cpp: bỏ idle-skip khi editor đang attach — preview phím
MIDI trong GUI là âm nội bộ plugin, không qua host MIDI; vòng loop idle
không gọi processAudioBlock nên voice nội bộ không bao giờ render (câm).
GUI mở -> render liên tục; GUI đóng vẫn idle như cũ.
- Verify: mở/đóng/mở lại GUI ch1 -> host mới, đúng 1 editor, âm ch1 peak
0.13 (GUI mở) / 0.10 (sau đóng); bridgeWrite tăng liên tục khi GUI mở.
- plugin_host_main.cpp: chặn WM_CLOSE (đóng GUI nhưng giữ window sống, hide
thay vì destroy), WM_DESTROY reset hwnd; dùng g_hostHwnd toàn cục thay
hwnd local để control OPEN_GUI/CLOSE_GUI tái sử dụng đúng window.
- main.cpp: bỏ qua dedupe hasAttachedView cho instrument child-own
(SandboxVst2Host) — bridge guiOpen_ stale sau khi child tự đóng nên
OPEN_GUI lặp lại phải forward control 4; child tự chặn double-open.
- Verify: WM_CLOSE -> window ẩn còn sống; OPEN_GUI lần 2 -> window hiện lại,
âm ch1 vẫn kêu (peak 0.15), không câm.
1) wavesynth tự phát khi mở app: probe calibrate() render vào live mix
(renderAll process cùng instance) -> thêm calibratingCh_[16], renderAll
bỏ qua channel đang calibrate; plugin_host panic (sustain off + all
notes off + 128 noteOff) ngay sau preset apply để startup im lặng.
2) bấm GUI mở 2 cửa sổ Qin: sandbox VST2 child tự sở hữu top-level window
-> ownsGuiWindow() + main.cpp forward OPEN_GUI control, không tạo native
parent / không registry double-open.
3) play phát nhạc cụ sai: restore clobber — seed preset đè patch thật trong
state file (ch3 63ba3667 -> 7f07473c) do saveStateJob chạy lúc child còn
seed. Fix: queuePreset(waitApply=true) chờ child apply xong (presetOut
memcmp), consume-before-apply (zero presetInLen trước khi apply), deferred
double-load re-check trong main.cpp skip assign trùng path, watchdog
respawn re-queue lastPreset_.