feat(midi): play selected instrument on armed main track via MIDI keyboard

When MIDI note-on received and no PIANO_ROLL sub-tab is armed,
fallback to armed track in main session. Read its synth_engine and
instrumentProgram to route audio through correct instrument.
Route to track gainNode if available.
This commit is contained in:
2026-07-26 17:19:51 +07:00
parent ef6fe0e718
commit 443e09b592
2 changed files with 16 additions and 1 deletions
+10 -1
View File
@@ -6658,7 +6658,16 @@ const App = () => {
try {
const ar = activeTabRef && subTabsRef && subTabsRef.current.find(s => s.id === activeTabRef.current && s.type === 'PIANO_ROLL' && s.isArmed);
if (ar && window.SonicSF) {
window.SonicSF.playNote(pitch, velocity, 500, undefined, ar.instrumentProgram, null);
window.SonicSF.playNote(pitch, velocity, 500, undefined, ar.instrumentProgram, null, undefined, ar.synth_engine);
} else if (window.SonicSF) {
// No armed PIANO_ROLL tab check main session for armed track
const armedTrack = activeTracksRef.current ? activeTracksRef.current.find(t => t.isArmed) : null;
if (armedTrack) {
const prog = armedTrack.instrumentProgram;
const se = armedTrack.synth_engine;
const dest = activeTrackNodesRef.current[armedTrack.id]?.gainNode || null;
window.SonicSF.playNote(pitch, velocity, 500, undefined, prog, dest, undefined, se);
}
}
} catch (e) {}
} else if (cmd === 0x8 || (cmd === 0x9 && velocity === 0)) {