fix: MIDI tab real-time instrument change - restart playback

This commit is contained in:
2026-07-26 11:07:37 +07:00
parent 5b500ebdf3
commit e57f6d96d9
3 changed files with 17 additions and 1 deletions
+11
View File
@@ -6445,6 +6445,17 @@ const App = () => {
if (s.trackId !== trackId) return s;
return { ...s, instrumentProgram: programNumber !== undefined ? programNumber : undefined, instrumentName: displayName, instrumentId };
}));
const playingSub = subTabs.find(s => s.trackId === trackId && s.type === 'PIANO_ROLL' && s.isPlaying);
if (playingSub) {
stopAllPlayback();
setTimeout(() => {
const context = getAudioContext();
startOffsetTimeRef.current = playingSub.currentTime || 0;
startAudioTimeRef.current = context.currentTime;
schedulePianoRollMidi(playingSub, playingSub.currentTime || 0);
startSubTabPlayback(playingSub, playingSub.currentTime || 0);
}, 50);
}
setTimeout(() => lucide.createIcons(), 50);
};
const setTrackInstrument = (trackId, instrumentId, displayName) => {