diff options
-rw-r--r-- | scale.mjs | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1,13 +1,3 @@ -const ringHandler = { - get(target, prop) { - return target[prop % target.length] || Reflect.get(...arguments); - } -}; - -export const chromaticScale = new Proxy( - ['A', 'A♯', 'B', 'C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯'], - ringHandler); - function notesBetween(a, b) { const [tonicA, tonicB] = [a[0], b[0]] const abs = tonicB.charCodeAt() - tonicA.charCodeAt(); @@ -18,6 +8,16 @@ function notesBetween(a, b) { } } +const ringHandler = { + get(target, prop) { + return target[prop % target.length] || Reflect.get(...arguments); + } +}; + +export const chromaticScale = new Proxy( + ['C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'A♯', 'B'], + ringHandler); + // todo: handle tonics with a flat ‘♭’, so we can deal with [BE]♭. function scaleFromIntervals(tonic, intervals) { const scaleIndex = chromaticScale.indexOf(tonic); |