fix: velocity start position + shift-scroll play on note start + canvas redraw deps
This commit is contained in:
@@ -4551,11 +4551,11 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
const newBeat = Math.max(0, Math.min(maxBeats, currentBeat + step));
|
||||
const newTime = newBeat * beatSec;
|
||||
setSubTabs(prev => prev.map(s => s.id === st.id ? { ...s, currentTime: newTime } : s));
|
||||
// Play notes at the new beat position
|
||||
// Play notes only when playhead crosses a note start
|
||||
if (window.SonicSF) {
|
||||
const ctx = getAudioContext();
|
||||
const playing = notes.filter(n =>
|
||||
newBeat >= n.start_beat && newBeat < n.start_beat + n.duration_beats
|
||||
currentBeat < n.start_beat && newBeat >= n.start_beat
|
||||
);
|
||||
playing.forEach(n => {
|
||||
window.SonicSF.playNote(n.pitch, (n.velocity || 0.8) * 127, 200, ctx.currentTime, st.instrumentProgram, null);
|
||||
@@ -4676,7 +4676,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}, [notes, snapVal, rollZoom, selectedNoteIds, selectionMarquee, st.currentTime, bpm]);
|
||||
}, [notes, snapVal, rollZoom, selectedNoteIds, selectionMarquee, st.currentTime, bpm, viewWidth, viewBeats]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const canvas = ccCanvasRef.current;
|
||||
@@ -4699,7 +4699,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
ctx.stroke();
|
||||
|
||||
notes.forEach((note) => {
|
||||
const x = note.start_beat * pixelsPerBeat + (note.duration_beats * pixelsPerBeat) / 2;
|
||||
const x = note.start_beat * pixelsPerBeat;
|
||||
let val = note.velocity !== undefined ? note.velocity : 0.8;
|
||||
if (ccMode === 'pan') {
|
||||
val = (note.pan !== undefined ? note.pan : 0.0) * 0.5 + 0.5;
|
||||
@@ -4720,7 +4720,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
ctx.arc(x, y, 3.5, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
});
|
||||
}, [notes, ccMode, rollZoom]);
|
||||
}, [notes, ccMode, rollZoom, viewWidth]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const scrollToC3 = () => {
|
||||
|
||||
Reference in New Issue
Block a user