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) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -190,3 +190,8 @@
|
||||
- **Tóm tắt thay đổi:** (1) Brush drawing: thay vì redistribute notes evenly, append từng note mới tại beat position thực tế (`getSnapBeat(beat, snapVal)`) — notes theo đúng hình dạng brush stroke. (2) Xóa transport controls (back/play/stop/record/forward) khỏi MIDI tab toolbar — chỉ dùng global transport. (3) Loop repeat: thêm `schedulePianoRollMidi` helper — reschedule MIDI notes qua SonicSF mỗi khi loop repeat, fix lỗi notes trong vùng chọn không có âm thanh khi play lặp lại.
|
||||
- **Các file ảnh hưởng:** `app/static/js/app.jsx`
|
||||
- **Ghi chú/Test (nếu có):** `npm run build` pass.
|
||||
|
||||
### [2026-07-26 10:44] Task: Fix brush drawing smooth - track pitch + beat delta
|
||||
- **Tóm tắt thay đổi:** Brush drawing: theo dõi cả `lastDrawBeat` và `visitedPitches`. Tạo note mới khi pitch thay đổi HOẶC beat di chuyển >= minBeatStep (25% của grid duration). Dùng raw `beat` thay vì `getSnapBeat` để note theo sát vị trí chuột. Khởi tạo `lastDrawBeat: start` trong draggedNote. Fix lỗi draw bị ngắt quãng do chỉ tạo note khi pitch thay đổi.
|
||||
- **Các file ảnh hưởng:** `app/static/js/app.jsx`
|
||||
- **Ghi chú/Test (nếu có):** `npm run build` pass.
|
||||
|
||||
Reference in New Issue
Block a user