export type Chord = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'A♭' | 'B♭' | 'C♭' | 'D♭' | 'E♭' | 'F♭' | 'G♭' | 'A♯' | 'B♯' | 'C♯' | 'D♯' | 'E♯' | 'F♯' | 'G♯' export let plains: Array = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G' ] export let bemols: Array = [ 'A♭', 'B♭', 'C♭', 'D♭', 'E♭', 'F♭', 'G♭' ] export let sharps: Array = [ 'A♯', 'B♯', 'C♯', 'D♯', 'E♯', 'F♯', 'G♯' ] export type Chords = Set export type GenerateParams = { major: Chords, minor: Chords, seventh: Chords, minorSeventh: Chords, majorSeventh: Chords, } export function generate(o: GenerateParams): [string, string] { const major: Array<[string, string]> = [...o.major].map(c => [c, '']) const minor: Array<[string, string]> = [...o.minor].map(c => [c, '-']) const seventh: Array<[string, string]> = [...o.seventh].map(c => [c, '7']) const minorSeventh: Array<[string, string]> = [...o.minorSeventh].map(c => [c, '-7']) const majorSeventh: Array<[string, string]> = [...o.majorSeventh].map(c => [c, '7']) const all = [...major, ...minor, ...seventh, ...minorSeventh, ...majorSeventh] return all[Math.floor(Math.random() * all.length)] }