fix: MIDI auto-play đọc nhầm file cũ, canvas/audio không đồng bộ

This commit is contained in:
2026-08-02 17:26:35 +07:00
parent 7000529d8d
commit ba5883951d
4 changed files with 12 additions and 2 deletions
+3
View File
@@ -9334,6 +9334,9 @@ const MediaExplorerPanel = ({ height }) => {
if (synthInst && window.SonicSF.selectInstrument) {
try { await window.SonicSF.selectInstrument(0, bank, program, sfId); } catch (e2) {}
}
// Re-check token after the async await stale playMidiPreview (older file)
// must not schedule notes over the newly selected file.
if (selectTokenRef.current !== (token || selectTokenRef.current)) return;
const prog = (synthInst && synthInst.program !== undefined) ? synthInst.program : undefined;
const eng = synthInst ? { soundfont_id: sfId, soundfont_bank: bank, soundfont_program: prog !== undefined ? prog : 0 } : undefined;
midiResult.forEach(track => {