V45.32: fix (1) latency preview MIDI keyboard - flush ring bridge sink (bridgeAudioWorklet _MAX 32 ~170ms audio cu render truoc) tai idle->active live note-on trong __clearMasterFxQueue (cung dieu kien V45.26: _liveHeldCount===0 && im lang >500ms) de note moi nghe ngay; guard _timelinePlaying (khong flush khi timeline dang play); (2) crackle VST2 tremolo/loop - overrun crossfade tich luy moi block drop cong 256 mau cap 1024 (~21ms) thay vi co dinh 64 mau (1.3ms qua ngan -> blip/wow khi drop loat block o chord nhieu voice) (tai lap tu V45.28, giu ring 32 de latency thap). v=202608311858

This commit is contained in:
2026-08-31 19:00:24 +07:00
parent 21cc8421a5
commit 5f8844637e
5 changed files with 30 additions and 11 deletions
+8
View File
@@ -293,9 +293,15 @@ window.__dbgWorkletState = _dbgWorkletState;
window.__restorePendingFadeSession = restorePendingFadeSession;
// V31: live note (ARM keyboard) — xoa backlog outQueue master FX truoc khi
// note preview render (idle block ~341ms lam ARM lag ~0.3s).
// V45.32: preview latency — flush ring bridge sink (audio cu render truoc
// ~170ms) tai idle->active note-on de note moi nghe ngay, khong phai cho
// backlog cu chay het. Guard: khong flush khi timeline dang play (tranh gap
// audio playback dang phat).
let _timelinePlaying = false;
window.__clearMasterFxQueue = function () {
_dbgLastClearMs = performance.now();
try { if (fxRt && fxRt.node && fxRt.node.port) fxRt.node.port.postMessage({ type: 'clear_queue', mode: 'live' }); } catch (e) {}
try { if (!_timelinePlaying && window.BridgeAudioNode && window.BridgeAudioNode.flush) window.BridgeAudioNode.flush(); } catch (e) {}
};
// V32: queueLen master FX worklet hien tai (midi_push log — ARM latency).
window.__fxRtQueueLen = function () {
@@ -15637,6 +15643,7 @@ const MediaExplorerPanel = ({ height, clipboardRef, active }) => {
midiTotalBeatsRef.current = midiTotalBeats;
midiFileBpmRef.current = midiFileBpm;
isPlayingRef.current = isPlaying;
_timelinePlaying = isPlaying;
isPausedRef.current = isPaused;
folderRef.current = folder;
tempoRef.current = tempo;
@@ -18526,6 +18533,7 @@ const App = () => {
// khi hết âm).
const isPlayingRef = useRef(false);
isPlayingRef.current = isPlaying;
_timelinePlaying = isPlaying;
// Bounce realtime = project đang phát thật; guardPlay (scheduleMidiNoteDispatch)
// phải cho note fire dù isPlayingRef bị render ghi đè =false khi bounce setState.
// (Không sync từ state ở đây — isExporting khai báo sau; bounce set true/false