diff options
author | Brian Cully <bjc@spork.org> | 2025-03-09 14:37:18 -0400 |
---|---|---|
committer | Brian Cully <bjc@spork.org> | 2025-03-09 14:37:18 -0400 |
commit | d69720d09760d153bb2059e57da3a4ed6c59e142 (patch) | |
tree | 5bdc9370682f4d23831cbfa3317f8cfc626f726f /scale.mjs | |
parent | 6db45269a1b2be66ee89297e3c7fba7af5a20cc2 (diff) | |
download | chords-d69720d09760d153bb2059e57da3a4ed6c59e142.tar.gz chords-d69720d09760d153bb2059e57da3a4ed6c59e142.zip |
use ‘tonic’ rather than ‘root’
i dunno, makes me seem like i know what i'm talking about. to me, at
least.
Diffstat (limited to 'scale.mjs')
-rw-r--r-- | scale.mjs | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -8,15 +8,15 @@ export const chromaticScale = new Proxy( ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'], ringHandler); -function scaleFromIntervals(root, intervals) { - const scaleIndex = chromaticScale.indexOf(root); +function scaleFromIntervals(tonic, intervals) { + const scaleIndex = chromaticScale.indexOf(tonic); if (scaleIndex < 0) { return undefined; } - let scale = [root]; + let scale = [tonic]; let steps = 0; - let lastBase = root[0]; + let lastBase = tonic[0]; for (let i = 0; i < intervals.length; i++) { steps += intervals[i]; const note = chromaticScale[scaleIndex + steps]; @@ -35,8 +35,8 @@ function scaleFromIntervals(root, intervals) { } class Scale { - constructor(root, intervals) { - this.scale = scaleFromIntervals(root, intervals); + constructor(tonic, intervals) { + this.scale = scaleFromIntervals(tonic, intervals); return new Proxy(this, { get(target, prop) { if (prop in target) { @@ -48,7 +48,7 @@ class Scale { }); } - get root() { + get tonic() { return this.scale[0]; } @@ -70,14 +70,14 @@ class Scale { } } -export function MajorScale(root) { - console.debug(`MajorScale(${root})`); +export function MajorScale(tonic) { + console.debug(`MajorScale(${tonic})`); const intervals = [2, 2, 1, 2, 2, 2]; - return new Scale(root, intervals); + return new Scale(tonic, intervals); } -export function MinorScale(root) { - console.debug(`MinorScale(${root})`); +export function MinorScale(tonic) { + console.debug(`MinorScale(${tonic})`); const intervals = [2, 1, 2, 2, 1, 2]; - return new Scale(root, intervals); + return new Scale(tonic, intervals); } |