From 86dbb49f4137555cadd3d0ed748a0b986993c83d Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 10 Mar 2025 11:23:16 -0400 Subject: scale: start scales from C --- scale.mjs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scale.mjs b/scale.mjs index 485d0c5..de25d14 100644 --- a/scale.mjs +++ b/scale.mjs @@ -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); -- cgit v1.3