fix: MIDI item playback respects visual duration + scale flicker guard
This commit is contained in:
@@ -5221,6 +5221,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
const ids = draggedNote.selectedNoteIds || [];
|
const ids = draggedNote.selectedNoteIds || [];
|
||||||
const firstStart = draggedNote.firstStart;
|
const firstStart = draggedNote.firstStart;
|
||||||
const notesBefore = notesBeforeDragRef.current;
|
const notesBefore = notesBeforeDragRef.current;
|
||||||
|
if (!notesBefore) return;
|
||||||
setNotes(prev => prev.map(n => {
|
setNotes(prev => prev.map(n => {
|
||||||
if (!ids.includes(n.id)) return n;
|
if (!ids.includes(n.id)) return n;
|
||||||
const orig = notesBefore ? notesBefore.find(o => o.id === n.id) : null;
|
const orig = notesBefore ? notesBefore.find(o => o.id === n.id) : null;
|
||||||
@@ -9428,10 +9429,12 @@ const App = () => {
|
|||||||
const bpmVal = parseInt(bpm) || 120;
|
const bpmVal = parseInt(bpm) || 120;
|
||||||
const secondsPerBeat = 60.0 / bpmVal;
|
const secondsPerBeat = 60.0 / bpmVal;
|
||||||
midiItems.forEach(item => {
|
midiItems.forEach(item => {
|
||||||
|
const itemEndSec = item.startTime + (item.duration || 4);
|
||||||
const notes = item.notes || [];
|
const notes = item.notes || [];
|
||||||
notes.forEach(note => {
|
notes.forEach(note => {
|
||||||
// note start/duration is in beats (for MIDI items)
|
// note start/duration is in beats (for MIDI items)
|
||||||
const noteStartSec = item.startTime + (note.start_beat || 0) * secondsPerBeat;
|
const noteStartSec = item.startTime + (note.start_beat || 0) * secondsPerBeat;
|
||||||
|
if (noteStartSec >= itemEndSec) return; // skip notes outside item's visual duration
|
||||||
const noteDurSec = (note.duration_beats || 1) * secondsPerBeat;
|
const noteDurSec = (note.duration_beats || 1) * secondsPerBeat;
|
||||||
const noteEndSec = noteStartSec + noteDurSec;
|
const noteEndSec = noteStartSec + noteDurSec;
|
||||||
if (offsetTime < noteEndSec) {
|
if (offsetTime < noteEndSec) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user