diff options
Diffstat (limited to 'src/chord.ts')
-rw-r--r-- | src/chord.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/chord.ts b/src/chord.ts new file mode 100644 index 0000000..b2645e2 --- /dev/null +++ b/src/chord.ts @@ -0,0 +1,14 @@ +export type Options = { + major: boolean, + minor: boolean +} + +export function generate({ major, minor }: Options): string { + let choices: string[] = [] + if (major) choices = choices.concat(all) + if (minor) choices = choices.concat(all.map(chord => `${chord}m`)) + + return choices[Math.floor(Math.random() * choices.length)] +} + +const all: string[] = [ 'C', 'D♭', 'D', 'E♭', 'E', 'F', 'G♭', 'G', 'A♭', 'A', 'B♭', 'B' ] |