fix scales without c

This commit is contained in:
Felix Roos 2022-02-28 22:55:03 +01:00
parent df21c81bfa
commit 71952ca8fd
2 changed files with 5 additions and 2 deletions

View File

@ -21,11 +21,11 @@ export function scaleOffset(scale, offset, index = 0) {
while (Math.abs(i) < Math.abs(offset)) {
i += direction;
const index = mod(i, notes.length);
if (direction < 0 && n === 'C') {
if (direction < 0 && n[0] === 'C') {
o += direction;
}
n = notes[index];
if (direction > 0 && n === 'C') {
if (direction > 0 && n[0] === 'C') {
o += direction;
}
}

View File

@ -33,6 +33,9 @@ describe('scaleTranspose', () => {
scaleTranspose('C minor', -1, 'Bb2');
scaleTranspose('C minor', 8, 'C4');
scaleTranspose('C4 minor', 8, 'C5');
scaleTranspose('C# major', 8, 'C#4');
scaleTranspose('C# major', -1, 'B#2');
scaleTranspose('C# major', -2, 'A#2');
});
});