fix: brush draw pitch revisit by comparing lastDrawnPitch
This commit is contained in:
@@ -5117,10 +5117,10 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
startOffsetPitch: snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch,
|
||||
drawNoteId: noteId,
|
||||
drawDuration: initialDur,
|
||||
visitedPitches: snapToScaleRef.current ? [snapPitchToScale(pitch, selectedScaleRef.current)] : [pitch],
|
||||
initialBeat: start,
|
||||
initialPitch: snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch,
|
||||
noteStartBeats: [start]
|
||||
noteStartBeats: [start],
|
||||
lastDrawnPitch: snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch
|
||||
});
|
||||
// Play the note with SoundFont
|
||||
if (window.SonicSF) {
|
||||
@@ -5206,9 +5206,9 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
return;
|
||||
}
|
||||
if (draggedNote.mode === 'draw') {
|
||||
const visited = draggedNote.visitedPitches || [];
|
||||
const snappedPitch = snapToScaleRef.current ? snapPitchToScale(pitch, selectedScaleRef.current) : pitch;
|
||||
const pitchChanged = !visited.includes(snappedPitch);
|
||||
const lastPitch = draggedNote.lastDrawnPitch !== undefined ? draggedNote.lastDrawnPitch : draggedNote.startOffsetPitch;
|
||||
const pitchChanged = snappedPitch !== lastPitch;
|
||||
const noteBeats = draggedNote.noteStartBeats || [];
|
||||
const defaultDur = getSnapDuration(snapVal);
|
||||
if (pitchChanged) {
|
||||
@@ -5223,7 +5223,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
}));
|
||||
}
|
||||
const newNote = {
|
||||
id: 'note_' + Date.now() + Math.random().toString(36).substr(2, 8) + '_' + (visited.length + 1),
|
||||
id: 'note_' + Date.now() + Math.random().toString(36).substr(2, 8) + '_' + (noteBeats.length + 1),
|
||||
pitch: snappedPitch,
|
||||
start_beat: beat,
|
||||
duration_beats: defaultDur,
|
||||
@@ -5233,7 +5233,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
||||
setNotes(prev => [...prev, newNote]);
|
||||
setSelectedNoteIds(prev => [...prev, newNote.id]);
|
||||
draggedNote.brushIds = [...brushIds, newNote.id];
|
||||
draggedNote.visitedPitches = [...visited, snappedPitch];
|
||||
draggedNote.lastDrawnPitch = snappedPitch;
|
||||
draggedNote.noteStartBeats = [...noteBeats, beat];
|
||||
} else {
|
||||
const brushIds = draggedNote.brushIds || [];
|
||||
|
||||
Reference in New Issue
Block a user