fix: playhead at bar 0 when opening MIDI item in session mode
- Removed st.currentTime >= 0 check from playhead rendering - handleEditMidiInTab: currentTime = -beatOff * beatSec so phBeat=0 - handleSwitchMidiItem: same logic for dropdown switches - Playhead draws at x=0 (bar 0) when item opens, moves right during playback from the initial negative position
This commit is contained in:
@@ -4646,8 +4646,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
var trk = (activeTracks || []).find(function(t) { return t.id === match._trackId; });
|
var trk = (activeTracks || []).find(function(t) { return t.id === match._trackId; });
|
||||||
var newBeatOff = (match.startTime / secondsPerBar) * timeSigNum;
|
var newBeatOff = (match.startTime / secondsPerBar) * timeSigNum;
|
||||||
var spb = 60.0 / (parseInt(bpm) || 120);
|
var spb = 60.0 / (parseInt(bpm) || 120);
|
||||||
var deltaSec = (renderBeatOffset - newBeatOff) * spb;
|
var newTime = -newBeatOff * spb;
|
||||||
var newTime = Math.max(0, (st.currentTime || 0) + deltaSec);
|
|
||||||
setSubTabs(function(prev) {
|
setSubTabs(function(prev) {
|
||||||
return prev.map(function(s) {
|
return prev.map(function(s) {
|
||||||
if (s.id !== st.id) return s;
|
if (s.id !== st.id) return s;
|
||||||
@@ -4986,7 +4985,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw playhead
|
// Draw playhead
|
||||||
if (st.currentTime !== undefined && st.currentTime !== null && st.currentTime >= 0) {
|
if (st.currentTime !== undefined && st.currentTime !== null) {
|
||||||
const phBeat = renderBeatOffset + st.currentTime / (60.0 / (parseInt(bpm) || 120));
|
const phBeat = renderBeatOffset + st.currentTime / (60.0 / (parseInt(bpm) || 120));
|
||||||
const phX = phBeat * pixelsPerBeat;
|
const phX = phBeat * pixelsPerBeat;
|
||||||
if (phX >= 0 && phX <= viewWidth) {
|
if (phX >= 0 && phX <= viewWidth) {
|
||||||
@@ -8287,6 +8286,10 @@ const App = () => {
|
|||||||
const tabLabel = `Piano Roll: ${midiItem.name || 'MIDI'}`;
|
const tabLabel = `Piano Roll: ${midiItem.name || 'MIDI'}`;
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
const silentBuffer = ctx.createBuffer(1, 128, ctx.sampleRate);
|
const silentBuffer = ctx.createBuffer(1, 128, ctx.sampleRate);
|
||||||
|
var bpmVal = parseInt(bpm) || 120;
|
||||||
|
var beatSec = 60.0 / bpmVal;
|
||||||
|
var secPerBar = beatSec * 4;
|
||||||
|
var beatOff = (midiItem.startTime / secPerBar) * 4;
|
||||||
const newTab = {
|
const newTab = {
|
||||||
id: tabId,
|
id: tabId,
|
||||||
label: tabLabel,
|
label: tabLabel,
|
||||||
@@ -8299,7 +8302,7 @@ const App = () => {
|
|||||||
buffer: silentBuffer,
|
buffer: silentBuffer,
|
||||||
instrumentProgram: track.instrumentProgram,
|
instrumentProgram: track.instrumentProgram,
|
||||||
instrumentName: track.instrumentName,
|
instrumentName: track.instrumentName,
|
||||||
currentTime: 0,
|
currentTime: -beatOff * beatSec,
|
||||||
isPlaying: false,
|
isPlaying: false,
|
||||||
selectionStart: null,
|
selectionStart: null,
|
||||||
selectionEnd: null,
|
selectionEnd: null,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user