From edc647ded6ce4267dad24eb49f5ebcc54e581142 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Sat, 22 Aug 2026 16:13:10 +0700 Subject: [PATCH] fix(rt): restart fxRt khi chain VST doi trong luc realtime dang chay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - masteringSettings effect goi fxRtStart() khong dieu kien: early-return khi active + cung chainKey, stop+start lai khi chain doi (insert/remove/ bypass/reorder VST trong MASTER FX CHAIN) — truoc day nhanh chainKey chet vi branch chi chay khi !fxRt.active - test list_scan_all: path plugin phai ton tai tren dia (loc entry chet truoc cache); dung _scan_json helper voi file that trong tmp_path - bump cache-bust app.precompiled.js -> 202608212300 --- app/static/js/app.jsx | 2 +- app/static/js/app.precompiled.js | 2 +- app/templates/index.html | 2 +- tests/test_vst_engine.py | 18 +++++++++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/static/js/app.jsx b/app/static/js/app.jsx index 0a939ec..9ec39d1 100644 --- a/app/static/js/app.jsx +++ b/app/static/js/app.jsx @@ -18793,7 +18793,7 @@ const App = () => { // Đồng bộ realtime VST master với PWR/Bypass: WebAudio graph đã đổi theo // masterConnected nhưng fxRt không tự dừng → tắt PWR mà âm không đổi. try { - if (fxRtChain().length) { if (!fxRt.active) fxRtStart(); } + if (fxRtChain().length) { fxRtStart(); } else if (fxRt.active) { fxRtStop(); } } catch (e) { console.warn('[FX RT] resync fail:', e); } // Re-sync live track routes: mastering ON → mọi track qua chain (♪ bị diff --git a/app/static/js/app.precompiled.js b/app/static/js/app.precompiled.js index a5296b5..e68dd5a 100644 --- a/app/static/js/app.precompiled.js +++ b/app/static/js/app.precompiled.js @@ -1239,7 +1239,7 @@ const[fxRackTarget,setFxRackTarget]=useState(null);window.__openFxRack=(trackId, window.__renderProjectPreview=async()=>{const schema=serializeProjectToSchema(currentProjectId||'temp_project',projectName||'Dự án tạm chưa lưu',bpm,tracks,subTabs,sessionTabs,masteringSettings,masterVolume);try{const res=await window.SonicAPI.renderProject(schema,'preview_'+Date.now()+'.wav');return res;}catch(e){window.showToast&&window.showToast('Render preview lỗi: '+(e.message||e),'error');throw e;}};const[masteringSettings,setMasteringSettings]=useState({masterConnected:true,// ⚠️ FIX: bật ON mặc định — MIDI item/preview PHẢI được xử lí qua mastering FX ngay khi chạy app (không cần bật/tắt power) activeModule:null,imagerActive:true,maximizerActive:true,eqLowGain:1.5,eqMid1Gain:-1.0,eqMid2Gain:2.0,eqHighGain:1.8,w1:0,w2:115,w3:135,w4:150,imagerScale:'v2',maxGain:5.4,maxUpward:2.0,maxSoftClip:15,maxTransient:25,ceiling:-0.1,isBypassed:false,chain:[],compActive:false,compThreshold:-16,compRatio:3,compMakeup:0,limActive:false,limThreshold:-1.0,excActive:false,excDrive:40,rebalActive:false,rebalMid:0,rebalSide:0,vstFxChain:[],vstBypass:false});useEffect(()=>{window.currentMasteringSettings=masteringSettings;if(audioCtx&&masterBus){toggleMasteringOnMaster(masteringSettings.masterConnected,masteringSettings.isBypassed);applyMasteringSettings(masteringSettings);// Đồng bộ realtime VST master với PWR/Bypass: WebAudio graph đã đổi theo // masterConnected nhưng fxRt không tự dừng → tắt PWR mà âm không đổi. -try{if(fxRtChain().length){if(!fxRt.active)fxRtStart();}else if(fxRt.active){fxRtStop();}}catch(e){console.warn('[FX RT] resync fail:',e);}// Re-sync live track routes: mastering ON → mọi track qua chain (♪ bị +try{if(fxRtChain().length){fxRtStart();}else if(fxRt.active){fxRtStop();}}catch(e){console.warn('[FX RT] resync fail:',e);}// Re-sync live track routes: mastering ON → mọi track qua chain (♪ bị // override bởi effMidiBypass/effAudioBypass) — nút PWR bật/tắt phải áp // ngay lên node đang phát (không chờ tracks effect). try{const _list=activeTracksRef.current&&activeTracksRef.current.length?activeTracksRef.current:tracks;_list.forEach(_t=>{const _n=activeTrackNodesRef.current[_t.id];if(_n){if(_n.sfRouteGain&&_n.sfDryGain){const _b=effMidiBypass(_t);_n.sfRouteGain.gain.value=_b?0:1;_n.sfDryGain.gain.value=_b?1:0;}if(_n.route&&_n.route.routeGain&&_n.route.dryGain){const _ab=routeBypassFor(_t);_n.route.routeGain.gain.value=_ab?0:1;_n.route.dryGain.gain.value=_ab?1:0;}}});// Sub-nodes (section tabs, key '_sub_'): PWR master ON → diff --git a/app/templates/index.html b/app/templates/index.html index a9dd86f..21d7fd4 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -51,7 +51,7 @@ - +