aboutsummaryrefslogtreecommitdiff
path: root/src/chord.ts
blob: b2645e296a7e7411873d68847889448635827844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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' ]