feat: piano roll shows all same-track MIDI items notes as active

This commit is contained in:
2026-07-31 09:46:55 +07:00
parent 9b25766fca
commit eb370319cb
3 changed files with 17 additions and 9 deletions
+7 -2
View File
@@ -23,6 +23,7 @@
if (!track.midiItems || !track.midiItems.length) continue;
if (track.muted) continue;
var isSameTrack = track.id === targetTrackId;
var trackGhostNotes = [];
for (var j = 0; j < track.midiItems.length; j++) {
@@ -32,7 +33,10 @@
var itemStartBeat = item.startTime / secondsPerBeat;
var itemEndBeat = (item.startTime + item.duration) / secondsPerBeat;
if (itemStartBeat >= windowEndBeat || itemEndBeat < windowStartBeat) continue;
// Same-track items always contribute notes (show whole track); cross-track only when overlapping the window
if (itemStartBeat >= windowEndBeat || itemEndBeat < windowStartBeat) {
if (!isSameTrack) continue;
}
var notes = item.notes || [];
for (var k = 0; k < notes.length; k++) {
@@ -40,7 +44,7 @@
var noteAbsStart = itemStartBeat + (note.start_beat || 0);
var noteAbsEnd = noteAbsStart + (note.duration_beats || 1);
if (noteAbsStart >= windowEndBeat) continue;
if (noteAbsStart >= windowEndBeat && !isSameTrack) continue;
trackGhostNotes.push({
id: 'ghost_' + (note.id || Math.random().toString(36).substr(2, 9)),
@@ -59,6 +63,7 @@
track_id: track.id,
track_name: track.name,
track_color: track.color || '#6b7280',
isSameTrack: isSameTrack,
notes: trackGhostNotes
});
}