Build, search, and play chords.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

275 Zeilen
7.2 KiB

  1. // TODO make this dictionary more computable
  2. // TODO construct/deconstruct chords
  3. // TODO add chord inversion
  4. // TODO add chord quality
  5. // TODO add chord extensions
  6. // TODO add chord alterations
  7. // TODO provide formats for WAV, MIDI, MP3, notation, etc.
  8. export * from './analyze';
  9. export * from './common';
  10. export * from './utils';
  11. //
  12. // const CHORD_DICTIONARY = [
  13. // {
  14. // name: 'Augmented',
  15. // symbol: 'aug',
  16. // id: 'aug',
  17. // notes: [0, 4, 8],
  18. // },
  19. // {
  20. // name: 'Augmented eleventh',
  21. // symbol: '<sup>(♯11)</sup>',
  22. // id: '(#11)',
  23. // notes: [0, 4, 7, 10, 14, 18],
  24. // },
  25. // {
  26. // name: 'Augmented major seventh',
  27. // symbol: 'aug<sup>maj7</sup>',
  28. // id: 'augmaj7',
  29. // notes: [0, 4, 8, 11],
  30. // },
  31. // {
  32. // name: 'Augmented seventh',
  33. // symbol: 'aug<sup>7</sup>',
  34. // id: 'aug7',
  35. // notes: [0, 4, 8, 10],
  36. // },
  37. // {
  38. // name: 'Diminished',
  39. // symbol: 'dim',
  40. // id: 'dim',
  41. // notes: [0, 3, 6],
  42. // },
  43. // {
  44. // name: 'Diminished major seventh',
  45. // symbol: 'dim<sup>maj7</sup>',
  46. // id: 'dimmaj7',
  47. // notes: [0, 3, 6, 11],
  48. // },
  49. // {
  50. // name: 'Diminished seventh',
  51. // symbol: 'dim<sup>7</sup>',
  52. // id: 'dim7',
  53. // notes: [0, 3, 6, 9],
  54. // },
  55. // {
  56. // name: 'Dominant eleventh',
  57. // symbol: '<sup>11</sup>',
  58. // id: '11',
  59. // notes: [0, 4, 7, 10, 14, 17],
  60. // },
  61. // {
  62. // name: 'Dominant minor ninth',
  63. // symbol: '<sup>7♭9</sup>',
  64. // notes: [0, 4, 7, 10, 13],
  65. // },
  66. // {
  67. // name: 'Dominant ninth',
  68. // symbol: '<sup>9</sup>',
  69. // notes: [0, 4, 7, 10, 14],
  70. // },
  71. // {
  72. // name: 'Dominant seventh',
  73. // symbol: '<sup>7</sup>',
  74. // notes: [0, 4, 7, 10],
  75. // },
  76. // {
  77. // name: 'Dominant seventh flat five',
  78. // symbol: '<sup>7♭5</sup>',
  79. // notes: [0, 4, 6, 10],
  80. // },
  81. // {
  82. // name: 'Dominant seventh sharp nine',
  83. // symbol: '<sup>(♯9)</sup>',
  84. // notes: [0, 4, 7, 10, 15],
  85. // },
  86. // { name: 'Dominant thirteenth', symbol: '<sup>13</sup>', notes: [0, 4, 7, 10, 14, 17, 21] },
  87. // { name: 'Half-diminished seventh', symbol: 'm<sup>7(♭5)</sup>', notes: [0, 3, 6, 10] },
  88. // {
  89. // name: 'Major',
  90. // symbol: '',
  91. // id: '',
  92. // notes: [0, 4, 7],
  93. // },
  94. // { name: 'Major eleventh', symbol: '<sup>maj11</sup>', notes: [0, 4, 7, 11, 14, 17] },
  95. // {
  96. // name: 'Major seventh',
  97. // symbol: '<sup>maj7</sup>',
  98. // notes: [0, 4, 7, 11],
  99. // },
  100. // { name: 'Major seventh sharp eleventh', symbol: '<sup>maj7♯11</sup>', notes: [0, 4, 8, 11, 18] },
  101. // {
  102. // name: 'Major sixth',
  103. // symbol: '<sup>6</sup>',
  104. // notes: [0, 4, 7, 9],
  105. // },
  106. // {
  107. // name: 'Major sixth ninth',
  108. // symbol: '<sup>6(9)</sup>',
  109. // notes: [0, 4, 7, 9, 14],
  110. // },
  111. // { name: 'Major ninth', symbol: '<sup>maj9</sup>', notes: [0, 4, 7, 11, 14] },
  112. // {
  113. // name: 'Major thirteenth',
  114. // symbol: '<sup>maj13</sup>',
  115. // notes: [0, 4, 7, 11, 14, 18, 21],
  116. // },
  117. // {
  118. // name: 'Minor',
  119. // symbol: 'm',
  120. // notes: [0, 3, 7],
  121. // },
  122. // { name: 'Minor eleventh', symbol: 'm<sup>11</sup>', notes: [0, 3, 7, 10, 14, 17] },
  123. // {
  124. // name: 'Minor major seventh',
  125. // symbol: 'm<sup>maj7</sup>',
  126. // notes: [0, 3, 7, 11],
  127. // },
  128. // { name: 'Minor ninth', symbol: 'm<sup>9</sup>', notes: [0, 3, 7, 10, 14] },
  129. // {
  130. // name: 'Minor seventh',
  131. // symbol: 'm<sup>7</sup>',
  132. // notes: [0, 3, 7, 10],
  133. // },
  134. // { name: 'Minor sixth', symbol: 'm<sup>6</sup>', notes: [0, 3, 7, 9] },
  135. // {
  136. // name: 'Minor sixth ninth (6/9)',
  137. // symbol: 'm<sup>6(9)</sup>',
  138. // notes: [0, 3, 7, 9, 14],
  139. // },
  140. // { name: 'Minor thirteenth', symbol: 'm<sup>13</sup>', notes: [0, 3, 7, 10, 14, 17, 21] },
  141. // {
  142. // name: 'Ninth augmented fifth',
  143. // symbol: '<sup>9♯5</sup>',
  144. // notes: [0, 4, 8, 10, 14],
  145. // },
  146. // { name: 'Ninth flat fifth', notes: [0, 4, 6, 10, 14], symbol: '<sup>9♭5</sup>' },
  147. // {
  148. // name: 'Seven six',
  149. // symbol: '<sup>7(6)</sup>',
  150. // notes: [0, 4, 7, 9, 10],
  151. // },
  152. // { name: 'Seventh suspension four', symbol: '<sup>7sus4</sup>', notes: [0, 5, 7, 10] },
  153. // {
  154. // name: 'Suspended fourth',
  155. // symbol: '<sup>sus4</sup>',
  156. // notes: [0, 5, 7],
  157. // },
  158. // {
  159. // name: 'Suspended second',
  160. // symbol: '<sup>sus2</sup>',
  161. // notes: [0, 2, 7],
  162. // },
  163. // {
  164. // name: 'Thirteenth flat ninth',
  165. // symbol: '<sup>13♭9</sup>',
  166. // notes: [0, 4, 7, 10, 13, 21],
  167. // },
  168. // {
  169. // name: 'Thirteenth flat ninth flat fifth',
  170. // symbol: '<sup>13♭9(♭5)</sup>',
  171. // notes: [0, 4, 6, 10, 13, 21],
  172. // },
  173. // ];
  174. //
  175. // export enum ConstructChordFormat {
  176. // PITCH_ARRAY,
  177. // NOTATION,
  178. // SOUND,
  179. // }
  180. //
  181. // enum NotationType {
  182. // STANDARD,
  183. // TABLATURE,
  184. // }
  185. //
  186. // interface ConstructChordOptions {
  187. // format?: ConstructChordFormat;
  188. // }
  189. //
  190. // enum ConstructChordStyle {
  191. // CHORD = 'CHORD',
  192. // ARPEGGIO = 'ARPEGGIO',
  193. // ARPEGGIO_THEN_CHORD = 'ARPEGGIO_THEN_CHORD',
  194. // CHORD_THEN_ARPEGGIO = 'CHORD_THEN_ARPEGGIO',
  195. // }
  196. //
  197. // interface ConstructChordSoundOptions extends ConstructChordOptions {
  198. // format?: ConstructChordFormat.SOUND;
  199. // midiInstrument?: number;
  200. // style?: ConstructChordStyle;
  201. // mimeType?: string;
  202. // }
  203. //
  204. // interface ConstructChordNotationOptions extends ConstructChordOptions {
  205. // format?: ConstructChordFormat.NOTATION;
  206. // notationType?: NotationType;
  207. // mimeType?: string;
  208. // }
  209. //
  210. // export enum PitchClass {
  211. // C,
  212. // B_SHARP = C,
  213. // C_SHARP,
  214. // D_FLAT = C_SHARP,
  215. // D,
  216. // D_SHARP,
  217. // E_FLAT = D_SHARP,
  218. // E,
  219. // F_FLAT = E,
  220. // F,
  221. // E_SHARP = F,
  222. // F_SHARP,
  223. // G_FLAT = F_SHARP,
  224. // G,
  225. // G_SHARP,
  226. // A_FLAT = G_SHARP,
  227. // A,
  228. // A_SHARP,
  229. // B_FLAT = A_SHARP,
  230. // B,
  231. // C_FLAT = B,
  232. // }
  233. //
  234. // interface ChordParams {
  235. // pitchClass: PitchClass;
  236. // chord?: string;
  237. // inversion?: number;
  238. // }
  239. //
  240. // const constructChordPitchArray = (params: ChordParams) => {
  241. // const { pitchClass, chord = '', inversion = 0 } = params;
  242. // const chordDefinition = CHORD_DICTIONARY.find((c) => c.id === chord);
  243. // if (!chordDefinition) {
  244. // throw new Error(`Chord ${chord} not found`);
  245. // }
  246. // const { notes } = chordDefinition;
  247. // const pitchArray = notes.map((note) => note + pitchClass);
  248. // return pitchArray;
  249. // };
  250. //
  251. // const constructChordNotation = (params: ChordParams, options: ConstructChordNotationOptions) => {
  252. // return constructChordPitchArray(params);
  253. // };
  254. //
  255. // const constructChordSound = (params: ChordParams, options: ConstructChordSoundOptions) => {
  256. // return constructChordPitchArray(params);
  257. // };
  258. //
  259. // export const constructChord = (params: ChordParams, options = {} as ConstructChordOptions) => {
  260. // const { format = ConstructChordFormat.PITCH_ARRAY } = options;
  261. // switch (format) {
  262. // case ConstructChordFormat.PITCH_ARRAY:
  263. // return constructChordPitchArray(params);
  264. // case ConstructChordFormat.NOTATION:
  265. // return constructChordNotation(params, options as ConstructChordNotationOptions);
  266. // case ConstructChordFormat.SOUND:
  267. // return constructChordSound(params, options as ConstructChordSoundOptions);
  268. // default:
  269. // break;
  270. // }
  271. //
  272. // throw new TypeError(`Unknown format ${format as string}`);
  273. // };