fix: preserve playhead session position across dropdown switch
handleSwitchMidiItem now computes new currentTime from the delta between old and new renderBeatOffset, keeping the playhead at the same session-absolute time instead of resetting to bar 0.
This commit is contained in:
@@ -4644,6 +4644,10 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
var match = allMidiItems.find(function(m) { return m.id === itemId; });
|
||||
if (!match) return;
|
||||
var trk = (activeTracks || []).find(function(t) { return t.id === match._trackId; });
|
||||
var newBeatOff = (match.startTime / secondsPerBar) * timeSigNum;
|
||||
var spb = 60.0 / (parseInt(bpm) || 120);
|
||||
var deltaSec = (renderBeatOffset - newBeatOff) * spb;
|
||||
var newTime = Math.max(0, (st.currentTime || 0) + deltaSec);
|
||||
setSubTabs(function(prev) {
|
||||
return prev.map(function(s) {
|
||||
if (s.id !== st.id) return s;
|
||||
@@ -4656,7 +4660,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
instrumentProgram: trk ? trk.instrumentProgram : undefined,
|
||||
instrumentName: trk ? trk.instrumentName : undefined,
|
||||
note_selection: [],
|
||||
currentTime: 0
|
||||
currentTime: newTime
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user