fix: ARM nhiều track phát sai instrument - synth_engine của track là nguồn quyết định thay vì channel state (bỏ che mask khi channel giữ instrument cũ/trùng)

This commit is contained in:
2026-08-03 10:33:40 +07:00
parent d8227904b6
commit 0dc95386f2
3 changed files with 12 additions and 10 deletions
+6 -9
View File
@@ -424,18 +424,15 @@
var finalProg = usedProg;
var finalSfId = synthEngine ? synthEngine.soundfont_id : undefined;
var cachedCh = _channels[ch];
// A channel explicitly configured with a soundfont (via
// selectInstrument) is authoritative. But the default channel
// state (bank 0, program 0, no soundfont) must NOT mask the
// track's synth engine or the note's program — otherwise notes
// on a freshly-picked instrument are silently dropped.
if (cachedCh && cachedCh.sfId !== undefined) {
// The note's own synth engine (track instrument) is
// authoritative. Channel state is only a cache: it must never
// mask the track's instrument, otherwise multi-track ARM or a
// re-picked instrument plays the wrong soundfont. Without an
// engine, fall back to the soundfont configured on the channel.
if (!synthEngine && cachedCh && cachedCh.sfId !== undefined) {
finalBank = cachedCh.bank;
finalProg = cachedCh.program;
finalSfId = cachedCh.sfId;
} else if (!synthEngine && program !== undefined && cachedCh && cachedCh.program !== undefined && cachedCh.program !== 0 && cachedCh.program !== null) {
finalBank = cachedCh.bank;
finalProg = cachedCh.program;
}
// Ensure the soundfont is actually loaded before the note plays.
// Quick instrument pick on a track does not pre-load it, so load
+1 -1
View File
@@ -16,7 +16,7 @@
<script src="/static/js/services/audioEngine.js?v=202607271016"></script>
<script src="/static/js/services/storage.js?v=202607271016"></script>
<script src="/static/js/services/soundfontStorage.js?v=202607271016"></script>
<script src="/static/js/services/soundfontPlayer.js?v=202608031015"></script>
<script src="/static/js/services/soundfontPlayer.js?v=202608031030"></script>
<script src="/static/js/services/aiGateway.js?v=202607271016"></script>
<script src="/static/js/services/dawCommandDispatcher.js?v=202607271016"></script>
<script src="/static/js/services/pianoRollTabService.js?v=202607272044"></script>