From 844494bb547004fb1ac06bb2a3f06be51618d3b7 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Thu, 10 Apr 2025 14:13:20 -0400 Subject: js: add stubs for aug/dim scales --- key-picker.mjs | 6 ++++++ 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()); } 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 [ -- cgit v1.3