From d81fae31acc13fe7dc394132837ce4f289f1dcf1 Mon Sep 17 00:00:00 2001 From: Tom Keefe <8655118+MisterKeefe@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:42:19 +0000 Subject: [PATCH] fix bug with flat minors, add sequence --- src/lib/music/relativeChord.ts | 13 +------------ src/routes/progressionStore.ts | 5 ++--- src/tests/music/relativeChord.spec.ts | 6 ++++++ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lib/music/relativeChord.ts b/src/lib/music/relativeChord.ts index c40770d..7382a70 100644 --- a/src/lib/music/relativeChord.ts +++ b/src/lib/music/relativeChord.ts @@ -91,23 +91,12 @@ export const relativeChordToString = (interval: RelativeChord): string => { } }; -// 1458: perfect -// 2367: major -// -// major+1: augmented -// major-1: minor -// minor+1: major -// minor-1: diminished -// -// perfect+1:augmented -// perfect-1:diminished - /* * Turn a guitar-style interval (vii, Vdim etc) into an Interval object */ export const parseRelativeChord = (intervalString: string): RelativeChord | null => { const matches = intervalString.match( - /^(b?[VI]+|[vi]+)(7sus4|7sus2|6sus4|6sus2|maj7sus4|maj7sus2|maj7|aug7|dim7|7b5|7s5|add9|sus4|sus2|aug|dim|7|6|5){0,1}/ + /^(b?[VI]+|b?[vi]+)(7sus4|7sus2|6sus4|6sus2|maj7sus4|maj7sus2|maj7|aug7|dim7|7b5|7s5|add9|sus4|sus2|aug|dim|7|6|5){0,1}/ ); if (matches === null) { diff --git a/src/routes/progressionStore.ts b/src/routes/progressionStore.ts index 5b2f6e0..97b63a8 100644 --- a/src/routes/progressionStore.ts +++ b/src/routes/progressionStore.ts @@ -24,7 +24,8 @@ const progressions = [ `i-iv-bVI-V`, `i-V7-v7-IV-bVI-bIII-IV-V7`, // hotel california `I-Imaj7-I7-IV-V6-VI7-ii-V`, - `I-iii-IIIdim-IV-iv-I-ii-bIII` + `I-iii-IIIdim-IV-iv-I-ii-bIII`, + `I-I5-I-V-IIdim7-bVIdim-vi-II-V-V7` //dunno but it's interesting ]; // URL hash utilities @@ -53,8 +54,6 @@ const progressionFromURLHash = () => { return progressionFromString(window.location.hash.substring(1)); }; -// G-G5-D-Adim7(no3)-Adim7-Em-A-D-D75 This sounds good - const tonic = writable('C'); const progressionIndex = writable(0); diff --git a/src/tests/music/relativeChord.spec.ts b/src/tests/music/relativeChord.spec.ts index 64006c7..3655ced 100644 --- a/src/tests/music/relativeChord.spec.ts +++ b/src/tests/music/relativeChord.spec.ts @@ -199,6 +199,12 @@ describe('parseInterval', () => { quality: 'major' }); }); + it('should parse a minor flat 6th', () => { + expect(parseRelativeChord('bvi')).toEqual({ + number: 'bVI', + quality: 'minor' + }); + }); it('should parse a flat 7th', () => { expect(parseRelativeChord('bVII')).toEqual({ number: 'bVII',