fix: brush drawing smooth - track pitch + beat delta
This commit is contained in:
+13
-7
@@ -5119,7 +5119,8 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
drawDuration: initialDur,
|
||||
visitedPitches: snapToScaleRef.current ? [snapPitchToScale(pitch, selectedScaleRef.current)] : [pitch],
|
||||
initialBeat: start,
|
||||
initialPitch: snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch
|
||||
initialPitch: snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch,
|
||||
lastDrawBeat: start
|
||||
});
|
||||
// Play the note with SoundFont
|
||||
if (window.SonicSF) {
|
||||
@@ -5215,14 +5216,16 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
}));
|
||||
}
|
||||
const snappedPitch = snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch;
|
||||
if (!visited.includes(snappedPitch)) {
|
||||
const newPitches = [...visited, snappedPitch];
|
||||
const lastDrawBeat = draggedNote.lastDrawBeat !== undefined ? draggedNote.lastDrawBeat : draggedNote.startOffsetBeat;
|
||||
const minBeatStep = Math.max(0.03125, getSnapDuration(snapVal) * 0.25);
|
||||
const pitchChanged = !visited.includes(snappedPitch);
|
||||
const beatChanged = Math.abs(beat - lastDrawBeat) >= minBeatStep;
|
||||
if (pitchChanged || (beatChanged && visited.length > 0)) {
|
||||
const brushIds = draggedNote.brushIds || [];
|
||||
const snappedBeat = getSnapBeat(beat, snapVal);
|
||||
const newNote = {
|
||||
id: 'note_' + Date.now() + Math.random().toString(36).substr(2, 8) + '_' + newPitches.length,
|
||||
id: 'note_' + Date.now() + Math.random().toString(36).substr(2, 8) + '_' + (visited.length + 1),
|
||||
pitch: snappedPitch,
|
||||
start_beat: snappedBeat,
|
||||
start_beat: beat,
|
||||
duration_beats: getSnapDuration(snapVal),
|
||||
velocity: brushVelocityRef.current,
|
||||
pan: 0.0
|
||||
@@ -5230,7 +5233,10 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
setNotes(prev => [...prev, newNote]);
|
||||
setSelectedNoteIds(prev => [...prev, newNote.id]);
|
||||
draggedNote.brushIds = [...brushIds, newNote.id];
|
||||
draggedNote.visitedPitches = newPitches;
|
||||
draggedNote.lastDrawBeat = beat;
|
||||
if (pitchChanged) {
|
||||
draggedNote.visitedPitches = [...visited, snappedPitch];
|
||||
}
|
||||
}
|
||||
const container = gridScrollRef.current;
|
||||
if (container) {
|
||||
|
||||
Reference in New Issue
Block a user