From 75795653c58aa1a44ece5966c704bcd2be192570 Mon Sep 17 00:00:00 2001 From: locpham Date: Mon, 10 Aug 2026 06:04:32 +0000 Subject: [PATCH] =?UTF-8?q?FIX:=20ensureMasteringRouting=20g=E1=BB=8Di=20g?= =?UTF-8?q?etAudioContext()=20tr=C6=B0=E1=BB=9Bc=20=E2=80=94=20preview=20?= =?UTF-8?q?=C4=91=E1=BA=A7u=20ti=C3=AAn=20c=C5=A9ng=20sync=20mastering=20r?= =?UTF-8?q?outing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/app.jsx | 6 +++++- app/static/js/app.precompiled.js | 4 +++- app/templates/index.html | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/static/js/app.jsx b/app/static/js/app.jsx index 011d2d8..15b64f1 100644 --- a/app/static/js/app.jsx +++ b/app/static/js/app.jsx @@ -20867,7 +20867,11 @@ const App = () => { const ensureMasteringRouting = () => { try { const _s = window.currentMasteringSettings; - if (!_s || !masterBus || !audioCtx) return; + 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(); diff --git a/app/static/js/app.precompiled.js b/app/static/js/app.precompiled.js index 2962a84..889012e 100644 --- a/app/static/js/app.precompiled.js +++ b/app/static/js/app.precompiled.js @@ -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. diff --git a/app/templates/index.html b/app/templates/index.html index 9b218c6..dc32e5a 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -31,12 +31,12 @@ - - + + - + @@ -44,7 +44,7 @@ - +