From 71952ca8fd486d756ea24c07513641d4d1bfbebc Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 28 Feb 2022 22:55:03 +0100 Subject: [PATCH] fix scales without c --- repl/src/tonal.mjs | 4 ++-- test/tonal.test.mjs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/repl/src/tonal.mjs b/repl/src/tonal.mjs index 66cce4ad..e8757056 100644 --- a/repl/src/tonal.mjs +++ b/repl/src/tonal.mjs @@ -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; } } diff --git a/test/tonal.test.mjs b/test/tonal.test.mjs index cc70449b..0b85d9f8 100644 --- a/test/tonal.test.mjs +++ b/test/tonal.test.mjs @@ -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'); }); });