From fd2356a438987b5ad77b24d0de10e8642fa1d642 Mon Sep 17 00:00:00 2001 From: Tom Keefe <8655118+MisterKeefe@users.noreply.github.com> Date: Sun, 26 Nov 2023 13:24:45 +0000 Subject: [PATCH] query string parsing trick --- src/lib/frettings.ts | 5 --- src/lib/music/relativeChord.ts | 4 +++ src/routes/+page.svelte | 59 ++++++++++++++++++++++++------ src/routes/progressionStore.ts | 66 +++++++++++++++++++++++++++++----- svelte.config.js | 5 +-- 5 files changed, 114 insertions(+), 25 deletions(-) diff --git a/src/lib/frettings.ts b/src/lib/frettings.ts index 1d0948d..d13b2de 100644 --- a/src/lib/frettings.ts +++ b/src/lib/frettings.ts @@ -7,11 +7,6 @@ import { unflatten, type Pitch, type PitchWithFlats, type Quality } from './musi * pointing at arrays of frettings for that pitch and chord variant. * This is a massive data entry task but also not that bad. GLHF! */ - -export const getFrettingForChord = ({ tonic, quality }: Chord, index: number = 0): number[] => { - return frettings[unflatten(tonic)][quality][index]; -}; - export const getFrettingsForChord = ({ tonic, quality }: Chord): number[][] => { return frettings[unflatten(tonic)][quality]; }; diff --git a/src/lib/music/relativeChord.ts b/src/lib/music/relativeChord.ts index 384f478..493ce0d 100644 --- a/src/lib/music/relativeChord.ts +++ b/src/lib/music/relativeChord.ts @@ -139,3 +139,7 @@ export const parseRelativeChord = (intervalString: string): RelativeChord | null export const progression = (strings: TemplateStringsArray, ...values: any): RelativeChord[] => { return strings[0].split(/[\s-]/).map(parseRelativeChord) as RelativeChord[]; }; + +export const progressionFromString = (string: string): RelativeChord[] => { + return string.split(/[\s-]/).map(parseRelativeChord) as RelativeChord[]; +}; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c493c8e..81f4154 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -6,6 +6,8 @@ progression, chords, randomizeApp, + randomizeTonic, + randomizeProgression, setTonic, previousProgression, nextProgression @@ -22,8 +24,21 @@ - Ukulele Chord Progression Generator - + Ukulele Chord Progressions Toy + + + + + + + + + + + + + +
@@ -36,7 +51,10 @@ {/each}
-

Progression

+

+ progression + +

-

Key

+

+ key + +

{#each displayPitches as pitch}