fix: add try-catch + nextMetronomeBeatRef init to startPianoRollRecording

This commit is contained in:
2026-07-25 19:56:19 +07:00
parent d858628a8f
commit 97855f47d1
2 changed files with 59 additions and 48 deletions
+11
View File
@@ -9850,9 +9850,12 @@ const App = () => {
};
const startPianoRollRecording = (tab) => {
try {
const context = getAudioContext();
const secondsPerBeat = 60.0 / (parseInt(bpm) || 120);
const startTime = currentTime;
const startBeat = startTime / secondsPerBeat;
nextMetronomeBeatRef.current = Math.ceil(startBeat);
const midiRec = new ClientMIDIRecorder(context, parseInt(bpm) || 120, 4);
midiRec.tempTabId = tab.id;
midiRec.selectedMidiInputId = selectedMidiInputId || 'ALL';
@@ -9896,7 +9899,15 @@ const App = () => {
s.id === tab.id ? { ...s, currentTime: startTime + sec, isDirty: true } : s
));
};
if (!tab._recordingStarted) {
tab._recordingStarted = true;
}
showToast('Recording MIDI to Piano Roll...', 'info');
} catch (err) {
console.error('startPianoRollRecording error:', err);
showToast('Lỗi khi bắt đầu ghi âm Piano Roll: ' + err.message, 'warning');
setRecordingState('IDLE');
}
};
const startRecordingTake = async (armedTracks) => {
File diff suppressed because one or more lines are too long