fix: brush draw pitch revisit by comparing lastDrawnPitch

This commit is contained in:
2026-07-26 10:55:21 +07:00
parent bc0c2d3279
commit 27d9556a9d
3 changed files with 13 additions and 8 deletions
+6 -6
View File
@@ -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 || [];
File diff suppressed because one or more lines are too long