Skip to content

Commit

Permalink
fix bug with flat minors, add sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
marginalhours committed Dec 4, 2023
1 parent d8c23ab commit d81fae3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
13 changes: 1 addition & 12 deletions src/lib/music/relativeChord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions src/routes/progressionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<PitchWithFlats>('C');
const progressionIndex = writable<number>(0);

Expand Down
6 changes: 6 additions & 0 deletions src/tests/music/relativeChord.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit d81fae3

Please sign in to comment.