From 2e996af1024acaf860cab6830326b8ccf89001b2 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Wed, 26 Aug 2026 18:40:15 +0700 Subject: [PATCH] fix(cc11): unmute realtime dung effective list thay vi ref stale --- app/static/js/app.jsx | 13 ++++++++++++- app/static/js/app.precompiled.js | 7 ++++++- app/templates/index.html | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/static/js/app.jsx b/app/static/js/app.jsx index ba1a09e..5d0fa7a 100644 --- a/app/static/js/app.jsx +++ b/app/static/js/app.jsx @@ -18775,7 +18775,18 @@ const App = () => { startAudioTimeRef.current = ctx.currentTime; startBufferOffsetRef.current = resumeAt; setIsPlaying(true); - startTrackPlayback(resumeAt); + // V22: activeTracksRef.current vẫn STALE (React chưa re-render trong + // click handler) → track vừa unmute vẫn thấy muted=true → bị skip ở + // startTrackPlayback (isPlayable) → câm + CC11 không chạy. Dùng + // `effective` (đã patch mute/solo) làm nguồn restart; ref tự phục hồi + // ở render kế tiếp (activeTracksRef.current = activeTracks). + const _prevActiveTracks = activeTracksRef.current; + activeTracksRef.current = effective; + try { + startTrackPlayback(resumeAt); + } finally { + activeTracksRef.current = _prevActiveTracks; + } } catch (e) { console.warn('mute/solo resume error:', e); } diff --git a/app/static/js/app.precompiled.js b/app/static/js/app.precompiled.js index 4e536c0..3143d30 100644 --- a/app/static/js/app.precompiled.js +++ b/app/static/js/app.precompiled.js @@ -1273,7 +1273,12 @@ if(isMidiSoundTrack(t)){try{sendMidiVolumeCC7(t,effective,audible);}catch(e){}}i // from the current playhead — the same approach toggleTrackSoloEvaluate // already uses for solo. if(becameAudible&&isPlaying&&recordingStateRef.current!=='RECORDING'&&activeTracksRef.current&&activeTracksRef.current.length){try{fxRtKeepForRestart=true;// restart/resume — giữ session FX realtime -stopAllPlayback();const ctx=getAudioContext();const resumeAt=currentTimeRef.current||0;startOffsetTimeRef.current=resumeAt;startAudioTimeRef.current=ctx.currentTime;startBufferOffsetRef.current=resumeAt;setIsPlaying(true);startTrackPlayback(resumeAt);}catch(e){console.warn('mute/solo resume error:',e);}}updateSfRouting();};window.__applyTrackMuteSolo=applyAllTrackMuteSolo;window.__toggleMediaExplorerRef=function(){setShowMediaExplorer(function(p){const next=!p;if(next)setShowMixerRef.current(false);return next;});};const[mixerHeight,setMixerHeight]=useState(function(){var saved=localStorage.getItem('studio_mixer_height');return saved?parseInt(saved):200;}());const[mediaExplorerPanelHeight,setMediaExplorerPanelHeight]=useState(function(){var saved=localStorage.getItem('studio_media_explorer_height');return saved?parseInt(saved):240;}());const[masterVolume,setMasterVolume]=useState(0);// dB (legacy single fader) +stopAllPlayback();const ctx=getAudioContext();const resumeAt=currentTimeRef.current||0;startOffsetTimeRef.current=resumeAt;startAudioTimeRef.current=ctx.currentTime;startBufferOffsetRef.current=resumeAt;setIsPlaying(true);// V22: activeTracksRef.current vẫn STALE (React chưa re-render trong +// click handler) → track vừa unmute vẫn thấy muted=true → bị skip ở +// startTrackPlayback (isPlayable) → câm + CC11 không chạy. Dùng +// `effective` (đã patch mute/solo) làm nguồn restart; ref tự phục hồi +// ở render kế tiếp (activeTracksRef.current = activeTracks). +const _prevActiveTracks=activeTracksRef.current;activeTracksRef.current=effective;try{startTrackPlayback(resumeAt);}finally{activeTracksRef.current=_prevActiveTracks;}}catch(e){console.warn('mute/solo resume error:',e);}}updateSfRouting();};window.__applyTrackMuteSolo=applyAllTrackMuteSolo;window.__toggleMediaExplorerRef=function(){setShowMediaExplorer(function(p){const next=!p;if(next)setShowMixerRef.current(false);return next;});};const[mixerHeight,setMixerHeight]=useState(function(){var saved=localStorage.getItem('studio_mixer_height');return saved?parseInt(saved):200;}());const[mediaExplorerPanelHeight,setMediaExplorerPanelHeight]=useState(function(){var saved=localStorage.getItem('studio_media_explorer_height');return saved?parseInt(saved):240;}());const[masterVolume,setMasterVolume]=useState(0);// dB (legacy single fader) const[masterVolL,setMasterVolL]=useState(0);// dB - master L fader const[masterVolR,setMasterVolR]=useState(0);// dB - master R fader const[masterLink,setMasterLink]=useState(true);// LINK L/R diff --git a/app/templates/index.html b/app/templates/index.html index d3bddbc..de8295a 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -51,7 +51,7 @@ - +