summaryrefslogtreecommitdiffstats
path: root/scale.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-04-10 14:13:20 -0400
committerBrian Cully <bjc@spork.org>2025-04-10 14:13:20 -0400
commit844494bb547004fb1ac06bb2a3f06be51618d3b7 (patch)
tree69fb20a354155db958ea1555d65107e413ae29f4 /scale.mjs
parentbbfdd803ef2f3918efca6e0c965e449c02626094 (diff)
downloadchords-844494bb547004fb1ac06bb2a3f06be51618d3b7.tar.gz
chords-844494bb547004fb1ac06bb2a3f06be51618d3b7.zip
js: add stubs for aug/dim scales
Diffstat (limited to 'scale.mjs')
-rw-r--r--scale.mjs26
1 files changed, 24 insertions, 2 deletions
diff --git a/scale.mjs b/scale.mjs
index 0ee079a..b364a3e 100644
--- a/scale.mjs
+++ b/scale.mjs
@@ -86,6 +86,9 @@ export class Note {
const alternate = this.toAlternateString();
const otherStr = other.toString();
const delta = otherStr.charCodeAt() - alternate.charCodeAt();
+ // if (other.root == 'G' && other.isSharp == true) {
+ //console.debug('bjc', 'other', otherStr, 'me', this.toString(), 'alt', alternate, 'delta', delta);
+ // }
if (delta === -1 || delta === 1) {
return alternate;
} else {
@@ -122,13 +125,16 @@ function scaleFromIntervals(tonic, intervals) {
const delta = notesBetween(lastBase, note);
if (delta === 0) {
const nextBase = chromaticScale[scaleIndex + steps + 1][0];
+ //console.log('0', 'prev', lastBase, 'next', nextBase, 'note', note)
scale.push(`${nextBase}♭`)
} else if (delta === 1) {
+ //console.log('1', 'note', note)
scale.push(`${note}`)
} else {
// we can only be two away, so take the sharp of the
// previous note.
const nextBase = chromaticScale[scaleIndex + steps - 1][0];
+ //console.log('other', 'prev', lastBase, 'next', nextBase, 'note', note);
scale.push(`${nextBase}♯`)
}
lastBase = scale[scale.length-1];
@@ -172,17 +178,33 @@ class Scale {
}
export function MajorScale(tonic) {
- console.debug(`MajorScale(${tonic})`);
+ // console.debug(`MajorScale(${tonic})`);
const intervals = [2, 2, 1, 2, 2, 2];
return new Scale(tonic, intervals);
}
export function MinorScale(tonic) {
- console.debug(`MinorScale(${tonic})`);
+ // console.debug(`MinorScale(${tonic})`);
const intervals = [2, 1, 2, 2, 1, 2];
return new Scale(tonic, intervals);
}
+export function AugmentedScale(tonic) {
+ // console.debug(`AugmentedScale(${tonic})`);
+ const intervals = [2, 2, 1, 1, 2, 2];
+ // C D Eb F Gb Ab, C
+ return new Scale(tonic, intervals);
+}
+
+export function DiminishedScale(tonic) {
+ // console.debug(`DiminishedScale(${tonic})`);
+ const intervals = [2, 1, 2, 1, 2, 1];
+ // C D Eb F Gb Ab, Bb
+ return new Scale(tonic, intervals);
+}
+
+// todo: add sus4/sus2
+
// well, a lot of them.
export const allDiatonicScales = chromaticScale.flatMap(tonic => {
return [