fix: realtime note display + MIDI key sound via refs
This commit is contained in:
@@ -6287,10 +6287,12 @@ const App = () => {
|
||||
setLastMidiNote({ pitch, velocity, length: 0, time: Date.now() });
|
||||
activeMidiPitchesRef.current.add(pitch);
|
||||
setActiveMidiPitches(new Set(activeMidiPitchesRef.current));
|
||||
const activeTabInfo = subTabs.find(s => s.id === activeTab && s.type === 'PIANO_ROLL' && s.isArmed);
|
||||
if (activeTabInfo && window.SonicSF) {
|
||||
try { window.SonicSF.playNote(pitch, velocity, 500, undefined, activeTabInfo.instrumentProgram, null); } catch (e) {}
|
||||
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);
|
||||
}
|
||||
} catch (e) {}
|
||||
} else if (cmd === 0x8 || (cmd === 0x9 && velocity === 0)) {
|
||||
activeMidiPitchesRef.current.delete(pitch);
|
||||
setActiveMidiPitches(new Set(activeMidiPitchesRef.current));
|
||||
@@ -9867,8 +9869,6 @@ const App = () => {
|
||||
midiRec.onNoteOn = (pitch, currentBeat) => {
|
||||
const elapsedBeats = Math.max(0, currentBeat);
|
||||
const sec = elapsedBeats * (60.0 / (parseInt(bpm) || 120));
|
||||
setSubTabs(prev => prev.map(s => {
|
||||
if (s.id !== tab.id) return s;
|
||||
const activeNotes = Array.from(midiRec.activeNotes.values()).map(n => ({
|
||||
id: 'rec_' + n.pitch + '_' + currentBeat,
|
||||
pitch: n.pitch,
|
||||
@@ -9888,8 +9888,9 @@ const App = () => {
|
||||
const allNotes = [...rec, ...activeNotes];
|
||||
setRecTempMidiNotes(allNotes);
|
||||
setCanvasRedrawCount(n => n + 1);
|
||||
return { ...s, currentTime: startTime + sec, isDirty: true };
|
||||
}));
|
||||
setSubTabs(prev => prev.map(s =>
|
||||
s.id === tab.id ? { ...s, currentTime: startTime + sec, isDirty: true } : s
|
||||
));
|
||||
};
|
||||
showToast('Recording MIDI to Piano Roll...', 'info');
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user