diff options
Diffstat (limited to 'scale.mjs')
| -rw-r--r-- | scale.mjs | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -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 [ |
