fix: _playNoteFluid else branch leaked other track's SF program 0

When a track has no instrument configured, _playNoteFluid called
program_change(ch, 0). FluidSynth searches ALL loaded SoundFonts
to resolve program 0 — if only another track's SoundFont is loaded,
that SF's program 0 gets applied to the wrong track.

Fix: use oscillator fallback directly instead of program_change.
This commit is contained in:
2026-07-27 21:26:52 +07:00
parent e38391ac7d
commit 6dec171af7
+7 -4
View File
@@ -393,10 +393,13 @@
_fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg); _fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg);
} catch (e) {} } catch (e) {}
} else { } else {
if (ch === undefined) ch = 0; // No instrument configured: use oscillator fallback directly.
try { // Do NOT call program_change(ch, 0) — FluidSynth would pick
_fluidModule._fluid_synth_program_change(_synthPtr, ch, 0); // program 0 from whatever SoundFont is loaded (could be
} catch (e) {} // another track's SF), causing cross-track instrument leak.
var ctx = getCtx();
self._playNoteFallback(note, velocity, durationMs, startTime, undefined, null, channel, undefined);
return;
} }
if (ch === undefined) ch = (usedBank === 128 ? 9 : 0); if (ch === undefined) ch = (usedBank === 128 ? 9 : 0);
var ctx = getCtx(); var ctx = getCtx();