diff options
| author | Brian Cully <bjc@spork.org> | 2025-03-10 11:23:16 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-03-10 11:23:16 -0400 |
| commit | 86dbb49f4137555cadd3d0ed748a0b986993c83d (patch) | |
| tree | 4405d9772e2a4cc35c65dd080b3f5c2becc5adf3 | |
| parent | b9ce8b8c04c4e530d1eccb0e09bc182fd914117b (diff) | |
| download | chords-86dbb49f4137555cadd3d0ed748a0b986993c83d.tar.gz chords-86dbb49f4137555cadd3d0ed748a0b986993c83d.zip | |
scale: start scales from C
| -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); |
