From d69720d09760d153bb2059e57da3a4ed6c59e142 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 9 Mar 2025 14:37:18 -0400 Subject: use ‘tonic’ rather than ‘root’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i dunno, makes me seem like i know what i'm talking about. to me, at least. --- index.html | 8 ++++---- scale.mjs | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 1c0afff..bb5fb32 100644 --- a/index.html +++ b/index.html @@ -98,8 +98,8 @@
key - - @@ -108,8 +108,8 @@ - - diff --git a/scale.mjs b/scale.mjs index b781f14..045265b 100644 --- a/scale.mjs +++ b/scale.mjs @@ -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); } -- cgit v1.3