1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
export type Options = {
major: boolean,
minor: boolean,
seventh: boolean,
minorSeventh: boolean,
majorSeventh: boolean,
}
export function generate(o: Options): [string, string] {
let base = all[Math.floor(Math.random() * all.length)]
let alterations: string[] = []
if (o.major) alterations = alterations.concat('')
if (o.minor) alterations = alterations.concat('-')
if (o.seventh) alterations = alterations.concat('7')
if (o.minorSeventh) alterations = alterations.concat('-7')
if (o.majorSeventh) alterations = alterations.concat('7')
return [base, alterations[Math.floor(Math.random() * alterations.length)]]
}
const all: string[] = [ 'C', 'D♭', 'D', 'E♭', 'E', 'F', 'G♭', 'G', 'A♭', 'A', 'B♭', 'B' ]
|