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)) {
+6
View File
@@ -1,3 +1,9 @@
### [2026-07-26 17:20] Task: MIDI keyboard plays selected instrument on armed main track
- **Tóm tắt thay đổi:** Khi ARM track trong MAIN SESSION/SECTION-TAB, nhấn MIDI Keyboard sẽ play note với instrument đã chọn (synth_engine/instrumentProgram). Fallback: nếu không có sub-tab PIANO_ROLL nào đang armed, tìm track đã ARM trong main session và dùng instrument của nó. Audio routing qua track's gainNode nếu có.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`
- **Ghi chú/Test (nếu có):** ARM track → chọn SF instrument → bấm MIDI keyboard → nghe âm thanh instrument đã chọn.
---
### [2026-07-26 17:10] Task: Add Drum channel toggle on track panel
- **Tóm tắt thay đổi:** Thêm button 🥁 trên track panel (giữa Solo và Record) để chuyển track sang drum channel 9. Khi active: set `is_percussion=true`, `soundfont_bank=128`. Thêm 🥁 indicator cho percussion presets (bank=128) trong instrument selector.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`