summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.html8
-rw-r--r--scale.mjs26
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 @@
<form id='key-picker'>
<fieldset>
<legend>key</legend>
- <label for='root'>root note:</label>
- <select id='root' name='root'>
+ <label for='tonic'>tonic:</label>
+ <select id='tonic' name='tonic'>
<option value='A'>A</option>
<option value='B'>B</option>
<option value='C' selected>C</option>
@@ -108,8 +108,8 @@
<option value='F'>F</option>
<option value='G'>G</option>
</select>
- <label for='foo'></label>
- <select id='foo' name='foo'>
+ <label for='diatonic'>diatonic:</label>
+ <select id='diatonic' name='diatonic'>
<option value='major' selected>major</option>
<option value='minor'>minor</option>
</select>
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);
}