FIX: ensureMasteringRouting gọi getAudioContext() trước — preview đầu tiên cũng sync mastering routing

This commit is contained in:
2026-08-10 06:04:32 +00:00
parent 025e0f03a2
commit 75795653c5
3 changed files with 12 additions and 6 deletions
+3 -1
View File
@@ -1290,7 +1290,9 @@ const _b=effMidiBypass(t);node.sfRouteGain.gain.value=_b?0:1;node.sfDryGain.gain
// chạy khi bắt đầu preview. Hàm này ép đồng bộ 3 lớp (graph theo trạng thái
// hiện tại — early-return nếu đã đúng; tham số module; route SF + route
// gains) — gọi tại mọi điểm preview → âm preview LUÔN qua mastering khi bật.
const ensureMasteringRouting=()=>{try{const _s=window.currentMasteringSettings;if(!_s||!masterBus||!audioCtx)return;toggleMasteringOnMaster(!!_s.masterConnected,!!_s.isBypassed);applyMasteringSettings(_s);updateSfRouting();}catch(e){console.warn('ensureMasteringRouting error:',e);}};const ensureMasteringRoutingRef=useRef(null);ensureMasteringRoutingRef.current=ensureMasteringRouting;window.__ensureMasteringRouting=ensureMasteringRouting;// ── MIDI preview cache (bounce nhanh offline) ──
const ensureMasteringRouting=()=>{try{const _s=window.currentMasteringSettings;if(!_s)return;// Đảm bảo audioCtx + masterBus đã tồn tại trước khi sync (lần preview
// đầu tiên audio chưa init → getAudioContext tạo ngay)
getAudioContext();if(!masterBus||!audioCtx)return;toggleMasteringOnMaster(!!_s.masterConnected,!!_s.isBypassed);applyMasteringSettings(_s);updateSfRouting();}catch(e){console.warn('ensureMasteringRouting error:',e);}};const ensureMasteringRoutingRef=useRef(null);ensureMasteringRoutingRef.current=ensureMasteringRouting;window.__ensureMasteringRouting=ensureMasteringRouting;// ── MIDI preview cache (bounce nhanh offline) ──
// Khi preview: capture tiếng đàn (SF output — pre track-FX) vào cache theo
// track. Khi export: nếu cache đủ độ dài → render OFFLINE NHANH bằng cache
// (qua FX Rack + Mastering như playback) — không cần chờ bounce realtime.