diff options
| author | Brian Cully <bjc@spork.org> | 2025-04-10 14:13:20 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-04-10 14:13:20 -0400 |
| commit | 844494bb547004fb1ac06bb2a3f06be51618d3b7 (patch) | |
| tree | 69fb20a354155db958ea1555d65107e413ae29f4 | |
| parent | bbfdd803ef2f3918efca6e0c965e449c02626094 (diff) | |
| download | chords-844494bb547004fb1ac06bb2a3f06be51618d3b7.tar.gz chords-844494bb547004fb1ac06bb2a3f06be51618d3b7.zip | |
js: add stubs for aug/dim scales
| -rw-r--r-- | key-picker.mjs | 6 | ||||
| -rw-r--r-- | scale.mjs | 26 |
2 files changed, 30 insertions, 2 deletions
diff --git a/key-picker.mjs b/key-picker.mjs index 6d2efbe..f88f45c 100644 --- a/key-picker.mjs +++ b/key-picker.mjs @@ -6,6 +6,10 @@ function scaleFrom(tonic, scale) { return MajorScale(tonic); case 'minor': return MinorScale(tonic); + case 'aug': + return AugmentedScale(tonic); + case 'dim': + return DiminishedScale(tonic); default: throw new Error('how this happen') } @@ -111,4 +115,6 @@ export default function KeyPicker(form) { elt.onclick = handleNoteClick; }); formChanged(form); + + console.log('bjc', 'Cdim', DiminishedScale('C').toString()); } @@ -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 [ |
