fix: piano roll snap values inverted in getSnapBeat/getSnapDuration/grid
snap='1' gave q=4.0 (4-beat snap). Fix all 3 mappings: grid lines, note snap, default duration.
This commit is contained in:
+18
-18
@@ -6013,25 +6013,25 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
const getSnapBeat = (beat, mode) => {
|
||||
let q = 0.25;
|
||||
if (mode === 'free') return beat;
|
||||
if (mode === '1') q = 4.0;
|
||||
else if (mode === '1/2') q = 2.0;
|
||||
else if (mode === '1/4') q = 1.0;
|
||||
else if (mode === '1/8') q = 0.5;
|
||||
else if (mode === '1/16') q = 0.25;
|
||||
if (mode === '1') q = 1.0;
|
||||
else if (mode === '1/2') q = 0.5;
|
||||
else if (mode === '1/4') q = 0.25;
|
||||
else if (mode === '1/8') q = 0.125;
|
||||
else if (mode === '1/16') q = 0.0625;
|
||||
else if (mode === '4') q = 4.0;
|
||||
else if (mode === '1/32') q = 0.125;
|
||||
else if (mode === '1/32') q = 0.03125;
|
||||
return Math.round(beat / q) * q;
|
||||
};
|
||||
|
||||
const getSnapDuration = (mode) => {
|
||||
if (mode === 'free') return 0.25;
|
||||
if (mode === '1') return 4.0;
|
||||
if (mode === '1/2') return 2.0;
|
||||
if (mode === '1/4') return 1.0;
|
||||
if (mode === '1/8') return 0.5;
|
||||
if (mode === '1/16') return 0.25;
|
||||
if (mode === '1') return 1.0;
|
||||
if (mode === '1/2') return 0.5;
|
||||
if (mode === '1/4') return 0.25;
|
||||
if (mode === '1/8') return 0.125;
|
||||
if (mode === '1/16') return 0.0625;
|
||||
if (mode === '4') return 4.0;
|
||||
if (mode === '1/32') return 0.125;
|
||||
if (mode === '1/32') return 0.03125;
|
||||
return 0.25;
|
||||
};
|
||||
|
||||
@@ -6147,13 +6147,13 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
|
||||
// Draw snap lines
|
||||
let snapBeats = 0.25;
|
||||
if (snapVal === '1') snapBeats = 4.0;
|
||||
else if (snapVal === '1/2') snapBeats = 2.0;
|
||||
else if (snapVal === '1/4') snapBeats = 1.0;
|
||||
else if (snapVal === '1/8') snapBeats = 0.5;
|
||||
else if (snapVal === '1/16') snapBeats = 0.25;
|
||||
if (snapVal === '1') snapBeats = 1.0;
|
||||
else if (snapVal === '1/2') snapBeats = 0.5;
|
||||
else if (snapVal === '1/4') snapBeats = 0.25;
|
||||
else if (snapVal === '1/8') snapBeats = 0.125;
|
||||
else if (snapVal === '1/16') snapBeats = 0.0625;
|
||||
else if (snapVal === '4') snapBeats = 4.0;
|
||||
else if (snapVal === '1/32') snapBeats = 0.125;
|
||||
else if (snapVal === '1/32') snapBeats = 0.03125;
|
||||
|
||||
for (let beat = 0; beat <= viewBeats; beat += snapBeats) {
|
||||
const x = beat * pixelsPerBeat;
|
||||
|
||||
Reference in New Issue
Block a user