FIX: sửa lỗi hiển thị animation của VU meter khi play MIDI

This commit is contained in:
2026-08-07 15:57:49 +07:00
parent 9e269d3b79
commit 4f34491f3e
5 changed files with 95 additions and 8 deletions
+29 -3
View File
@@ -6984,10 +6984,16 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
}, [activeTracks]);
const ghostLayers = React.useMemo(function() {
// Đang play (main/section) B ghost: extractGhostLayers duyt TOÀN B
// project (tracks + notes) block main thread 100-500ms noteon
// FluidSynth (scheduled qua setTimeout) TR âm b lag 1-2 ln khi m
// piano roll tab lúc đang play (user bug 06:30). Ghost ch là hin th
// tham chiếu không cn khi âm đang chy tính li khi dng.
if (isPlaying) return [];
if (!activeTracks || !st || !st.target_id) return [];
var fn = window.SonicGhost && window.SonicGhost.extractGhostLayers;
return fn ? fn(activeTracks, st.trackId, st.target_id, parseInt(bpm) || 120) : [];
}, [activeTracks, st.trackId, st.target_id, bpm]);
}, [activeTracks, st.trackId, st.target_id, bpm, isPlaying]);
const secondsPerBar = (60.0 / (parseInt(bpm) || 120)) * 4;
const activeTargetItem = React.useMemo(function() {
@@ -18627,7 +18633,12 @@ const App = () => {
const isSubTab = subTabsRef.current.some(sub => sub.id === activeTabRef.current);
if (isSubTab) {
const st = subTabsRef.current.find(s => s.id === activeTabRef.current);
if (!st || !st.buffer) return;
if (!st) return;
// PIANO ROLL KHÔNG cn buffer: tab restored t phiên trưc AudioBuffer
// KHÔNG serialize st.buffer undefined return cũ làm playhead ĐNG IM
// (user bug 06:15 m li piano roll đã m phiên trưc khi đang play).
// startSubTabPlayback t to silent buffer khi play (18103).
if (!st.buffer && st.type !== 'PIANO_ROLL') return;
if (!st.isPlaying) {
// PIANO ROLL / sub-tab KHÔNG play: playhead theo MAIN/SECTION nếu đang
// play ĐNG B 2 CHIU: v trí play (section/main) v trí TRONG
@@ -19038,7 +19049,22 @@ const App = () => {
// audible (bình thưng rơi v masterBus.input, mt FX track).
const _activeTabId = activeTabRef.current;
const _activeSub = subTabsRef.current ? subTabsRef.current.find(s => s.id === _activeTabId) : null;
if (_activeSub && _activeSub.type === 'PIANO_ROLL') {
// MAIN/SECTION đang play + đang SUB-TAB (piano roll/audio): KHÔNG đi
// SF destination âm đang phát thuc MAIN context (route đã set ĐÚNG
// lúc schedule masterBus.input qua mastering). Đi đích khi âm đang
// phát gây: (a) swap _gainNode LAG ~1s (bug 06:20); (b) route vào node
// MAIN trùng id (midiAudible nhánh) sfEntry/sfRouteGain theo main
// âm dry NH/không rõ (bug 06:25 fix 0620). Gi nguyên route hin ti.
if (isPlayingRef.current && _activeTabId && _activeTabId !== 'main' && !_activeTabId.startsWith('session_')) {
return;
}
// MAIN/SECTION đang play (isPlayingRef) B QUA nhánh PIANO_ROLL:
// đi SF destination (setOutputDestination disconnect/reconnect
// _gainNode FluidSynth) khi âm đang phát âm MIDI b NGT ~1s (user
// bug 06:20 m li piano roll tab restored lúc main play lag 1s
// ri mi phát tiếp). Ch route vào node piano roll khi KHÔNG play
// (preview tab) handlePlayPause sub-tab t stopAllPlayback trưc.
if (_activeSub && _activeSub.type === 'PIANO_ROLL' && !isPlayingRef.current) {
// PIANO ROLL ca track TRONG SECTION (parent_tab_id = session_*): id
// track trùng main track id lookup key = id trúng node MAIN (route
// theo main sai context MIDI b kéo dry). ƯU TIÊN SUB-NODE