vexflow 4.0.1-beta.0 → 4.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +126 -26
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +94 -26
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-gonville.js +2 -2
  10. package/build/cjs/vexflow-gonville.js.map +1 -1
  11. package/build/cjs/vexflow-petaluma.js +2 -2
  12. package/build/cjs/vexflow-petaluma.js.map +1 -1
  13. package/build/cjs/vexflow.js +2 -2
  14. package/build/cjs/vexflow.js.map +1 -1
  15. package/build/esm/src/version.js +3 -3
  16. package/package.json +1 -1
  17. package/src/note.ts +2 -2
  18. package/src/stavenote.ts +80 -16
  19. package/build/esm/entry/vexflow-bravura.js +0 -11
  20. package/build/esm/entry/vexflow-core.js +0 -54
  21. package/build/esm/entry/vexflow-debug-with-tests.js +0 -4
  22. package/build/esm/entry/vexflow-debug.js +0 -3
  23. package/build/esm/entry/vexflow-font-bravura.js +0 -7
  24. package/build/esm/entry/vexflow-font-custom.js +0 -7
  25. package/build/esm/entry/vexflow-font-gonville.js +0 -7
  26. package/build/esm/entry/vexflow-font-petaluma.js +0 -7
  27. package/build/esm/entry/vexflow-gonville.js +0 -11
  28. package/build/esm/entry/vexflow-petaluma.js +0 -11
  29. package/build/esm/entry/vexflow.js +0 -9
  30. package/build/esm/src/accidental.js +0 -348
  31. package/build/esm/src/annotation.js +0 -213
  32. package/build/esm/src/articulation.js +0 -264
  33. package/build/esm/src/barnote.js +0 -58
  34. package/build/esm/src/beam.js +0 -632
  35. package/build/esm/src/bend.js +0 -202
  36. package/build/esm/src/boundingbox.js +0 -59
  37. package/build/esm/src/boundingboxcomputation.js +0 -107
  38. package/build/esm/src/canvascontext.js +0 -202
  39. package/build/esm/src/chordsymbol.js +0 -578
  40. package/build/esm/src/clef.js +0 -153
  41. package/build/esm/src/clefnote.js +0 -65
  42. package/build/esm/src/crescendo.js +0 -77
  43. package/build/esm/src/curve.js +0 -118
  44. package/build/esm/src/dot.js +0 -137
  45. package/build/esm/src/easyscore.js +0 -374
  46. package/build/esm/src/element.js +0 -216
  47. package/build/esm/src/factory.js +0 -440
  48. package/build/esm/src/flow.js +0 -275
  49. package/build/esm/src/font.js +0 -264
  50. package/build/esm/src/fonts/bravura_glyphs.js +0 -3239
  51. package/build/esm/src/fonts/bravura_metrics.js +0 -507
  52. package/build/esm/src/fonts/custom_glyphs.js +0 -78
  53. package/build/esm/src/fonts/custom_metrics.js +0 -5
  54. package/build/esm/src/fonts/gonville_glyphs.js +0 -828
  55. package/build/esm/src/fonts/gonville_metrics.js +0 -421
  56. package/build/esm/src/fonts/load_all.js +0 -10
  57. package/build/esm/src/fonts/load_bravura.js +0 -6
  58. package/build/esm/src/fonts/load_custom.js +0 -6
  59. package/build/esm/src/fonts/load_gonville.js +0 -6
  60. package/build/esm/src/fonts/load_petaluma.js +0 -6
  61. package/build/esm/src/fonts/petaluma_glyphs.js +0 -1335
  62. package/build/esm/src/fonts/petaluma_metrics.js +0 -536
  63. package/build/esm/src/fonts/petalumascript_glyphs.js +0 -863
  64. package/build/esm/src/fonts/robotoslab_glyphs.js +0 -863
  65. package/build/esm/src/fonts/textfonts.js +0 -44
  66. package/build/esm/src/formatter.js +0 -568
  67. package/build/esm/src/fraction.js +0 -171
  68. package/build/esm/src/frethandfinger.js +0 -156
  69. package/build/esm/src/ghostnote.js +0 -50
  70. package/build/esm/src/glyph.js +0 -331
  71. package/build/esm/src/glyphnote.js +0 -55
  72. package/build/esm/src/gracenote.js +0 -133
  73. package/build/esm/src/gracenotegroup.js +0 -128
  74. package/build/esm/src/gracetabnote.js +0 -12
  75. package/build/esm/src/index.js +0 -91
  76. package/build/esm/src/keymanager.js +0 -99
  77. package/build/esm/src/keysignature.js +0 -250
  78. package/build/esm/src/keysignote.js +0 -28
  79. package/build/esm/src/modifier.js +0 -128
  80. package/build/esm/src/modifiercontext.js +0 -110
  81. package/build/esm/src/multimeasurerest.js +0 -173
  82. package/build/esm/src/music.js +0 -322
  83. package/build/esm/src/note.js +0 -371
  84. package/build/esm/src/notehead.js +0 -169
  85. package/build/esm/src/notesubgroup.js +0 -59
  86. package/build/esm/src/ornament.js +0 -206
  87. package/build/esm/src/parenthesis.js +0 -76
  88. package/build/esm/src/parser.js +0 -164
  89. package/build/esm/src/pedalmarking.js +0 -192
  90. package/build/esm/src/registry.js +0 -81
  91. package/build/esm/src/rendercontext.js +0 -24
  92. package/build/esm/src/renderer.js +0 -112
  93. package/build/esm/src/repeatnote.js +0 -22
  94. package/build/esm/src/stave.js +0 -547
  95. package/build/esm/src/stavebarline.js +0 -182
  96. package/build/esm/src/staveconnector.js +0 -196
  97. package/build/esm/src/stavehairpin.js +0 -120
  98. package/build/esm/src/staveline.js +0 -218
  99. package/build/esm/src/stavemodifier.js +0 -77
  100. package/build/esm/src/stavenote.js +0 -799
  101. package/build/esm/src/staverepetition.js +0 -155
  102. package/build/esm/src/stavesection.js +0 -58
  103. package/build/esm/src/stavetempo.js +0 -91
  104. package/build/esm/src/stavetext.js +0 -82
  105. package/build/esm/src/stavetie.js +0 -141
  106. package/build/esm/src/stavevolta.js +0 -67
  107. package/build/esm/src/stem.js +0 -131
  108. package/build/esm/src/stemmablenote.js +0 -193
  109. package/build/esm/src/stringnumber.js +0 -231
  110. package/build/esm/src/strokes.js +0 -200
  111. package/build/esm/src/svgcontext.js +0 -414
  112. package/build/esm/src/system.js +0 -116
  113. package/build/esm/src/tables.js +0 -1102
  114. package/build/esm/src/tabnote.js +0 -299
  115. package/build/esm/src/tabslide.js +0 -76
  116. package/build/esm/src/tabstave.js +0 -17
  117. package/build/esm/src/tabtie.js +0 -19
  118. package/build/esm/src/textbracket.js +0 -144
  119. package/build/esm/src/textdynamics.js +0 -81
  120. package/build/esm/src/textformatter.js +0 -177
  121. package/build/esm/src/textnote.js +0 -176
  122. package/build/esm/src/tickable.js +0 -214
  123. package/build/esm/src/tickcontext.js +0 -170
  124. package/build/esm/src/timesigglyph.js +0 -85
  125. package/build/esm/src/timesignature.js +0 -89
  126. package/build/esm/src/timesignote.js +0 -32
  127. package/build/esm/src/tremolo.js +0 -47
  128. package/build/esm/src/tuning.js +0 -54
  129. package/build/esm/src/tuplet.js +0 -240
  130. package/build/esm/src/typeguard.js +0 -30
  131. package/build/esm/src/util.js +0 -58
  132. package/build/esm/src/vex.js +0 -51
  133. package/build/esm/src/vibrato.js +0 -100
  134. package/build/esm/src/vibratobracket.js +0 -50
  135. package/build/esm/src/voice.js +0 -187
  136. package/build/esm/src/web.js +0 -15
  137. package/build/esm/tests/accidental_tests.js +0 -974
  138. package/build/esm/tests/annotation_tests.js +0 -377
  139. package/build/esm/tests/articulation_tests.js +0 -365
  140. package/build/esm/tests/auto_beam_formatting_tests.js +0 -548
  141. package/build/esm/tests/bach_tests.js +0 -335
  142. package/build/esm/tests/barline_tests.js +0 -52
  143. package/build/esm/tests/beam_tests.js +0 -595
  144. package/build/esm/tests/bend_tests.js +0 -215
  145. package/build/esm/tests/boundingbox_tests.js +0 -53
  146. package/build/esm/tests/boundingboxcomputation_tests.js +0 -183
  147. package/build/esm/tests/chordsymbol_tests.js +0 -320
  148. package/build/esm/tests/clef_tests.js +0 -131
  149. package/build/esm/tests/curve_tests.js +0 -118
  150. package/build/esm/tests/dot_tests.js +0 -123
  151. package/build/esm/tests/easyscore_tests.js +0 -459
  152. package/build/esm/tests/factory_tests.js +0 -44
  153. package/build/esm/tests/font_tests.js +0 -135
  154. package/build/esm/tests/formatter/framestack.js +0 -61
  155. package/build/esm/tests/formatter/tests.js +0 -203
  156. package/build/esm/tests/formatter_tests.js +0 -669
  157. package/build/esm/tests/fraction_tests.js +0 -72
  158. package/build/esm/tests/ghostnote_tests.js +0 -77
  159. package/build/esm/tests/glyphnote_tests.js +0 -113
  160. package/build/esm/tests/gracenote_tests.js +0 -370
  161. package/build/esm/tests/gracetabnote_tests.js +0 -79
  162. package/build/esm/tests/index.js +0 -68
  163. package/build/esm/tests/key_clef_tests.js +0 -103
  164. package/build/esm/tests/keymanager_tests.js +0 -68
  165. package/build/esm/tests/keysignature_tests.js +0 -308
  166. package/build/esm/tests/mocks.js +0 -71
  167. package/build/esm/tests/modifier_tests.js +0 -24
  168. package/build/esm/tests/multimeasurerest_tests.js +0 -141
  169. package/build/esm/tests/music_tests.js +0 -161
  170. package/build/esm/tests/notehead_tests.js +0 -137
  171. package/build/esm/tests/notesubgroup_tests.js +0 -149
  172. package/build/esm/tests/offscreencanvas_tests.js +0 -47
  173. package/build/esm/tests/ornament_tests.js +0 -298
  174. package/build/esm/tests/parser_tests.js +0 -122
  175. package/build/esm/tests/pedalmarking_tests.js +0 -64
  176. package/build/esm/tests/percussion_tests.js +0 -180
  177. package/build/esm/tests/registry_tests.js +0 -64
  178. package/build/esm/tests/renderer_tests.js +0 -113
  179. package/build/esm/tests/rests_tests.js +0 -248
  180. package/build/esm/tests/rhythm_tests.js +0 -357
  181. package/build/esm/tests/stave_tests.js +0 -560
  182. package/build/esm/tests/staveconnector_tests.js +0 -402
  183. package/build/esm/tests/stavehairpin_tests.js +0 -90
  184. package/build/esm/tests/staveline_tests.js +0 -122
  185. package/build/esm/tests/stavemodifier_tests.js +0 -51
  186. package/build/esm/tests/stavenote_tests.js +0 -835
  187. package/build/esm/tests/stavetie_tests.js +0 -108
  188. package/build/esm/tests/stringnumber_tests.js +0 -259
  189. package/build/esm/tests/strokes_tests.js +0 -275
  190. package/build/esm/tests/style_tests.js +0 -98
  191. package/build/esm/tests/support/qunit.js +0 -2765
  192. package/build/esm/tests/tabnote_tests.js +0 -474
  193. package/build/esm/tests/tabslide_tests.js +0 -135
  194. package/build/esm/tests/tabstave_tests.js +0 -23
  195. package/build/esm/tests/tabtie_tests.js +0 -173
  196. package/build/esm/tests/textbracket_tests.js +0 -100
  197. package/build/esm/tests/textformatter_tests.js +0 -24
  198. package/build/esm/tests/textnote_tests.js +0 -215
  199. package/build/esm/tests/threevoice_tests.js +0 -132
  200. package/build/esm/tests/tickcontext_tests.js +0 -36
  201. package/build/esm/tests/timesignature_tests.js +0 -134
  202. package/build/esm/tests/tremolo_tests.js +0 -75
  203. package/build/esm/tests/tuning_tests.js +0 -56
  204. package/build/esm/tests/tuplet_tests.js +0 -450
  205. package/build/esm/tests/typeguard_tests.js +0 -82
  206. package/build/esm/tests/vexflow_test_helpers.js +0 -266
  207. package/build/esm/tests/vf_prefix_tests.js +0 -115
  208. package/build/esm/tests/vibrato_tests.js +0 -92
  209. package/build/esm/tests/vibratobracket_tests.js +0 -45
  210. package/build/esm/tests/voice_tests.js +0 -69
  211. package/build/types/entry/vexflow-bravura.d.ts +0 -3
  212. package/build/types/entry/vexflow-core.d.ts +0 -3
  213. package/build/types/entry/vexflow-debug.d.ts +0 -3
  214. package/build/types/entry/vexflow-font-bravura.d.ts +0 -3771
  215. package/build/types/entry/vexflow-font-custom.d.ts +0 -86
  216. package/build/types/entry/vexflow-font-gonville.d.ts +0 -1267
  217. package/build/types/entry/vexflow-font-petaluma.d.ts +0 -1896
  218. package/build/types/entry/vexflow-gonville.d.ts +0 -3
  219. package/build/types/entry/vexflow-petaluma.d.ts +0 -3
  220. package/build/types/entry/vexflow.d.ts +0 -3
  221. package/build/types/src/accidental.d.ts +0 -66
  222. package/build/types/src/annotation.d.ts +0 -60
  223. package/build/types/src/articulation.d.ts +0 -62
  224. package/build/types/src/barnote.d.ts +0 -29
  225. package/build/types/src/beam.d.ts +0 -124
  226. package/build/types/src/bend.d.ts +0 -73
  227. package/build/types/src/boundingbox.d.ts +0 -42
  228. package/build/types/src/boundingboxcomputation.d.ts +0 -33
  229. package/build/types/src/canvascontext.d.ts +0 -89
  230. package/build/types/src/chordsymbol.d.ts +0 -149
  231. package/build/types/src/clef.d.ts +0 -48
  232. package/build/types/src/clefnote.d.ts +0 -25
  233. package/build/types/src/crescendo.d.ts +0 -27
  234. package/build/types/src/curve.d.ts +0 -41
  235. package/build/types/src/dot.d.ts +0 -20
  236. package/build/types/src/easyscore.d.ts +0 -148
  237. package/build/types/src/element.d.ts +0 -202
  238. package/build/types/src/factory.d.ts +0 -271
  239. package/build/types/src/flow.d.ts +0 -245
  240. package/build/types/src/font.d.ts +0 -181
  241. package/build/types/src/fonts/bravura_glyphs.d.ts +0 -3239
  242. package/build/types/src/fonts/bravura_metrics.d.ts +0 -533
  243. package/build/types/src/fonts/custom_glyphs.d.ts +0 -78
  244. package/build/types/src/fonts/custom_metrics.d.ts +0 -5
  245. package/build/types/src/fonts/gonville_glyphs.d.ts +0 -828
  246. package/build/types/src/fonts/gonville_metrics.d.ts +0 -440
  247. package/build/types/src/fonts/load_all.d.ts +0 -1
  248. package/build/types/src/fonts/load_bravura.d.ts +0 -1
  249. package/build/types/src/fonts/load_custom.d.ts +0 -1
  250. package/build/types/src/fonts/load_gonville.d.ts +0 -1
  251. package/build/types/src/fonts/load_petaluma.d.ts +0 -1
  252. package/build/types/src/fonts/petaluma_glyphs.d.ts +0 -1335
  253. package/build/types/src/fonts/petaluma_metrics.d.ts +0 -562
  254. package/build/types/src/fonts/petalumascript_glyphs.d.ts +0 -863
  255. package/build/types/src/fonts/robotoslab_glyphs.d.ts +0 -863
  256. package/build/types/src/fonts/textfonts.d.ts +0 -1
  257. package/build/types/src/formatter.d.ts +0 -203
  258. package/build/types/src/fraction.d.ts +0 -62
  259. package/build/types/src/frethandfinger.d.ts +0 -22
  260. package/build/types/src/ghostnote.d.ts +0 -16
  261. package/build/types/src/glyph.d.ts +0 -139
  262. package/build/types/src/glyphnote.d.ts +0 -17
  263. package/build/types/src/gracenote.d.ts +0 -19
  264. package/build/types/src/gracenotegroup.d.ts +0 -33
  265. package/build/types/src/gracetabnote.d.ts +0 -5
  266. package/build/types/src/index.d.ts +0 -91
  267. package/build/types/src/keymanager.d.ts +0 -25
  268. package/build/types/src/keysignature.d.ts +0 -50
  269. package/build/types/src/keysignote.d.ts +0 -11
  270. package/build/types/src/modifier.d.ts +0 -97
  271. package/build/types/src/modifiercontext.d.ts +0 -45
  272. package/build/types/src/multimeasurerest.d.ts +0 -61
  273. package/build/types/src/music.d.ts +0 -91
  274. package/build/types/src/note.d.ts +0 -230
  275. package/build/types/src/notehead.d.ts +0 -70
  276. package/build/types/src/notesubgroup.d.ts +0 -18
  277. package/build/types/src/ornament.d.ts +0 -76
  278. package/build/types/src/parenthesis.d.ts +0 -22
  279. package/build/types/src/parser.d.ts +0 -45
  280. package/build/types/src/pedalmarking.d.ts +0 -69
  281. package/build/types/src/registry.d.ts +0 -40
  282. package/build/types/src/rendercontext.d.ts +0 -64
  283. package/build/types/src/renderer.d.ts +0 -35
  284. package/build/types/src/repeatnote.d.ts +0 -6
  285. package/build/types/src/stave.d.ts +0 -186
  286. package/build/types/src/stavebarline.d.ts +0 -28
  287. package/build/types/src/staveconnector.d.ts +0 -67
  288. package/build/types/src/stavehairpin.d.ts +0 -56
  289. package/build/types/src/staveline.d.ts +0 -57
  290. package/build/types/src/stavemodifier.d.ts +0 -44
  291. package/build/types/src/stavenote.d.ts +0 -154
  292. package/build/types/src/staverepetition.d.ts +0 -32
  293. package/build/types/src/stavesection.d.ts +0 -15
  294. package/build/types/src/stavetempo.d.ts +0 -25
  295. package/build/types/src/stavetext.d.ts +0 -25
  296. package/build/types/src/stavetie.d.ts +0 -59
  297. package/build/types/src/stavevolta.d.ts +0 -21
  298. package/build/types/src/stem.d.ts +0 -58
  299. package/build/types/src/stemmablenote.d.ts +0 -39
  300. package/build/types/src/stringnumber.d.ts +0 -27
  301. package/build/types/src/strokes.d.ts +0 -33
  302. package/build/types/src/svgcontext.d.ts +0 -131
  303. package/build/types/src/system.d.ts +0 -92
  304. package/build/types/src/tables.d.ts +0 -96
  305. package/build/types/src/tabnote.d.ts +0 -44
  306. package/build/types/src/tabslide.d.ts +0 -34
  307. package/build/types/src/tabstave.d.ts +0 -7
  308. package/build/types/src/tabtie.d.ts +0 -18
  309. package/build/types/src/textbracket.d.ts +0 -55
  310. package/build/types/src/textdynamics.d.ts +0 -39
  311. package/build/types/src/textformatter.d.ts +0 -109
  312. package/build/types/src/textnote.d.ts +0 -49
  313. package/build/types/src/tickable.d.ts +0 -140
  314. package/build/types/src/tickcontext.d.ts +0 -82
  315. package/build/types/src/timesigglyph.d.ts +0 -14
  316. package/build/types/src/timesignature.d.ts +0 -26
  317. package/build/types/src/timesignote.d.ts +0 -11
  318. package/build/types/src/tremolo.d.ts +0 -17
  319. package/build/types/src/tuning.d.ts +0 -23
  320. package/build/types/src/tuplet.d.ts +0 -105
  321. package/build/types/src/typeguard.d.ts +0 -99
  322. package/build/types/src/util.d.ts +0 -27
  323. package/build/types/src/version.d.ts +0 -3
  324. package/build/types/src/vex.d.ts +0 -18
  325. package/build/types/src/vibrato.d.ts +0 -29
  326. package/build/types/src/vibratobracket.d.ts +0 -33
  327. package/build/types/src/voice.d.ts +0 -108
  328. package/build/types/src/web.d.ts +0 -2
@@ -1,974 +0,0 @@
1
- import { VexFlowTests } from './vexflow_test_helpers.js';
2
- import { Accidental } from '../src/accidental.js';
3
- import { Beam } from '../src/beam.js';
4
- import { Dot } from '../src/dot.js';
5
- import { Flow } from '../src/flow.js';
6
- import { Formatter } from '../src/formatter.js';
7
- import { ModifierContext } from '../src/modifiercontext.js';
8
- import { Note } from '../src/note.js';
9
- import { Stave } from '../src/stave.js';
10
- import { StaveNote } from '../src/stavenote.js';
11
- import { Stem } from '../src/stem.js';
12
- import { TickContext } from '../src/tickcontext.js';
13
- import { TimeSigNote } from '../src/timesignote.js';
14
- import { isAccidental } from '../src/typeguard.js';
15
- import { Voice } from '../src/voice.js';
16
- const AccidentalTests = {
17
- Start() {
18
- QUnit.module('Accidental');
19
- test('Automatic Accidentals - Simple Tests', autoAccidentalWorking);
20
- const run = VexFlowTests.runTests;
21
- run('Accidental Padding', formatAccidentalSpaces);
22
- run('Basic', basic);
23
- run('Stem Down', basicStemDown);
24
- run('Cautionary Accidental', cautionary);
25
- run('Accidental Arrangement Special Cases', specialCases);
26
- run('Multi Voice', multiVoice);
27
- run('Microtonal', microtonal);
28
- run('Microtonal (Iranian)', microtonal_iranian);
29
- run('Sagittal', sagittal);
30
- run('Automatic Accidentals', automaticAccidentals0);
31
- run('Automatic Accidentals - C major scale in Ab', automaticAccidentals1);
32
- run('Automatic Accidentals - No Accidentals Necessary', automaticAccidentals2);
33
- run('Automatic Accidentals - No Accidentals Necessary (EasyScore)', automaticAccidentals3);
34
- run('Automatic Accidentals - Multi Voice Inline', automaticAccidentalsMultiVoiceInline);
35
- run('Automatic Accidentals - Multi Voice Offset', automaticAccidentalsMultiVoiceOffset);
36
- run('Automatic Accidentals - Key C, Single Octave', automaticAccidentalsCornerCases1);
37
- run('Automatic Accidentals - Key C, Two Octaves', automaticAccidentalsCornerCases2);
38
- run('Automatic Accidentals - Key C#, Single Octave', automaticAccidentalsCornerCases3);
39
- run('Automatic Accidentals - Key C#, Two Octaves', automaticAccidentalsCornerCases4);
40
- run('Factory API', factoryAPI);
41
- },
42
- };
43
- function hasAccidental(note) {
44
- return note.getModifiers().some((modifier) => isAccidental(modifier));
45
- }
46
- function makeNewAccid(factory) {
47
- return (type) => factory.Accidental({ type });
48
- }
49
- function autoAccidentalWorking() {
50
- const createStaveNote = (noteStruct) => new StaveNote(noteStruct);
51
- let notes = [
52
- { keys: ['bb/4'], duration: '4' },
53
- { keys: ['bb/4'], duration: '4' },
54
- { keys: ['g#/4'], duration: '4' },
55
- { keys: ['g/4'], duration: '4' },
56
- { keys: ['b/4'], duration: '4' },
57
- { keys: ['b/4'], duration: '4' },
58
- { keys: ['a#/4'], duration: '4' },
59
- { keys: ['g#/4'], duration: '4' },
60
- ].map(createStaveNote);
61
- let voice = new Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
62
- Accidental.applyAccidentals([voice], 'F');
63
- equal(hasAccidental(notes[0]), false, 'No flat because of key signature');
64
- equal(hasAccidental(notes[1]), false, 'No flat because of key signature');
65
- equal(hasAccidental(notes[2]), true, 'Added a sharp');
66
- equal(hasAccidental(notes[3]), true, 'Back to natural');
67
- equal(hasAccidental(notes[4]), true, 'Back to natural');
68
- equal(hasAccidental(notes[5]), false, 'Natural remembered');
69
- equal(hasAccidental(notes[6]), true, 'Added sharp');
70
- equal(hasAccidental(notes[7]), true, 'Added sharp');
71
- notes = [
72
- { keys: ['e#/4'], duration: '4' },
73
- { keys: ['cb/4'], duration: '4' },
74
- { keys: ['fb/4'], duration: '4' },
75
- { keys: ['b#/4'], duration: '4' },
76
- { keys: ['b#/4'], duration: '4' },
77
- { keys: ['cb/5'], duration: '4' },
78
- { keys: ['fb/5'], duration: '4' },
79
- { keys: ['e#/4'], duration: '4' },
80
- ].map(createStaveNote);
81
- voice = new Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
82
- Accidental.applyAccidentals([voice], 'A');
83
- equal(hasAccidental(notes[0]), true, 'Added sharp');
84
- equal(hasAccidental(notes[1]), true, 'Added flat');
85
- equal(hasAccidental(notes[2]), true, 'Added flat');
86
- equal(hasAccidental(notes[3]), true, 'Added sharp');
87
- equal(hasAccidental(notes[4]), false, 'Sharp remembered');
88
- equal(hasAccidental(notes[5]), true, 'Added flat(different octave)');
89
- equal(hasAccidental(notes[6]), true, 'Added flat(different octave)');
90
- equal(hasAccidental(notes[7]), false, 'sharp remembered');
91
- notes = [
92
- { keys: ['c/4'], duration: '4' },
93
- { keys: ['cb/4'], duration: '4' },
94
- { keys: ['cb/4'], duration: '4' },
95
- { keys: ['c#/4'], duration: '4' },
96
- { keys: ['c#/4'], duration: '4' },
97
- { keys: ['cbb/4'], duration: '4' },
98
- { keys: ['cbb/4'], duration: '4' },
99
- { keys: ['c##/4'], duration: '4' },
100
- { keys: ['c##/4'], duration: '4' },
101
- { keys: ['c/4'], duration: '4' },
102
- { keys: ['c/4'], duration: '4' },
103
- ].map(createStaveNote);
104
- voice = new Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
105
- Accidental.applyAccidentals([voice], 'C');
106
- equal(hasAccidental(notes[0]), false, 'No accidental');
107
- equal(hasAccidental(notes[1]), true, 'Added flat');
108
- equal(hasAccidental(notes[2]), false, 'Flat remembered');
109
- equal(hasAccidental(notes[3]), true, 'Sharp added');
110
- equal(hasAccidental(notes[4]), false, 'Sharp remembered');
111
- equal(hasAccidental(notes[5]), true, 'Added doubled flat');
112
- equal(hasAccidental(notes[6]), false, 'Double flat remembered');
113
- equal(hasAccidental(notes[7]), true, 'Added double sharp');
114
- equal(hasAccidental(notes[8]), false, 'Double sharp rememberd');
115
- equal(hasAccidental(notes[9]), true, 'Added natural');
116
- equal(hasAccidental(notes[10]), false, 'Natural remembered');
117
- }
118
- function formatAccidentalSpaces(options) {
119
- const f = VexFlowTests.makeFactory(options, 750, 280);
120
- const context = f.getContext();
121
- const softmaxFactor = 100;
122
- const notes = [
123
- new StaveNote({
124
- keys: ['e##/5'],
125
- duration: '8d',
126
- }).addModifier(new Accidental('##'), 0),
127
- new StaveNote({
128
- keys: ['b/4'],
129
- duration: '16',
130
- }).addModifier(new Accidental('b'), 0),
131
- new StaveNote({
132
- keys: ['f/3'],
133
- duration: '8',
134
- }),
135
- new StaveNote({
136
- keys: ['a/3'],
137
- duration: '16',
138
- }),
139
- new StaveNote({
140
- keys: ['e/4', 'g/4'],
141
- duration: '16',
142
- })
143
- .addModifier(new Accidental('bb'), 0)
144
- .addModifier(new Accidental('bb'), 1),
145
- new StaveNote({
146
- keys: ['d/4'],
147
- duration: '16',
148
- }),
149
- new StaveNote({
150
- keys: ['e/4', 'g/4'],
151
- duration: '16',
152
- })
153
- .addModifier(new Accidental('#'), 0)
154
- .addModifier(new Accidental('#'), 1),
155
- new StaveNote({
156
- keys: ['g/4'],
157
- duration: '32',
158
- }),
159
- new StaveNote({
160
- keys: ['a/4'],
161
- duration: '32',
162
- }),
163
- new StaveNote({
164
- keys: ['g/4'],
165
- duration: '16',
166
- }),
167
- new StaveNote({
168
- keys: ['d/4'],
169
- duration: 'q',
170
- }),
171
- ];
172
- Dot.buildAndAttach([notes[0]], { all: true });
173
- const beams = Beam.generateBeams(notes);
174
- const voice = new Voice({
175
- num_beats: 4,
176
- beat_value: 4,
177
- });
178
- voice.addTickables(notes);
179
- const formatter = new Formatter({ softmaxFactor }).joinVoices([voice]);
180
- const width = formatter.preCalculateMinTotalWidth([voice]);
181
- const stave = new Stave(10, 40, width + 20);
182
- stave.setContext(context).draw();
183
- formatter.format([voice], width);
184
- voice.draw(context, stave);
185
- beams.forEach((b) => b.setContext(context).draw());
186
- notes.forEach((note) => Note.plotMetrics(context, note, 30));
187
- VexFlowTests.plotLegendForNoteWidth(context, 300, 150);
188
- ok(true);
189
- }
190
- function basic(options) {
191
- const f = VexFlowTests.makeFactory(options, 700, 240);
192
- const accid = makeNewAccid(f);
193
- f.Stave({ x: 10, y: 10, width: 550 });
194
- const notes = [
195
- f
196
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '1' })
197
- .addModifier(accid('b'), 0)
198
- .addModifier(accid('#'), 1),
199
- f
200
- .StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: '2' })
201
- .addModifier(accid('##'), 0)
202
- .addModifier(accid('n'), 1)
203
- .addModifier(accid('bb'), 2)
204
- .addModifier(accid('b'), 3)
205
- .addModifier(accid('#'), 4)
206
- .addModifier(accid('n'), 5)
207
- .addModifier(accid('bb'), 6),
208
- f
209
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16' })
210
- .addModifier(accid('n'), 0)
211
- .addModifier(accid('#'), 1)
212
- .addModifier(accid('#'), 2)
213
- .addModifier(accid('b'), 3)
214
- .addModifier(accid('bb'), 4)
215
- .addModifier(accid('##'), 5)
216
- .addModifier(accid('#'), 6),
217
- f
218
- .StaveNote({ keys: ['a/3', 'c/4', 'e/4', 'b/4', 'd/5', 'g/5'], duration: '1' })
219
- .addModifier(accid('#'), 0)
220
- .addModifier(accid('##').setAsCautionary(), 1)
221
- .addModifier(accid('#').setAsCautionary(), 2)
222
- .addModifier(accid('b'), 3)
223
- .addModifier(accid('bb').setAsCautionary(), 4)
224
- .addModifier(accid('b').setAsCautionary(), 5),
225
- ];
226
- Formatter.SimpleFormat(notes, 10, { paddingBetween: 45 });
227
- notes.forEach((note, index) => {
228
- Note.plotMetrics(f.getContext(), note, 140);
229
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + index + ' has accidentals');
230
- note.getModifiersByType('Accidental').forEach((accid, index) => {
231
- ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
232
- });
233
- });
234
- f.draw();
235
- VexFlowTests.plotLegendForNoteWidth(f.getContext(), 480, 140);
236
- ok(true, 'Full Accidental');
237
- }
238
- function cautionary(options) {
239
- const staveCount = 12;
240
- const scale = 0.85;
241
- const staveWidth = 840;
242
- let i = 0;
243
- let j = 0;
244
- const f = VexFlowTests.makeFactory(options, staveWidth + 10, 175 * staveCount + 10);
245
- f.getContext().scale(scale, scale);
246
- const accids = Object.keys(Flow.accidentalMap).filter((accid) => accid !== '{' && accid !== '}');
247
- const mod = Math.round(accids.length / staveCount);
248
- for (i = 0; i < staveCount; ++i) {
249
- const stave = f.Stave({ x: 0, y: 10 + 200 * i, width: staveWidth / scale });
250
- const score = f.EasyScore();
251
- const rowMap = [];
252
- for (j = 0; j < mod && j + i * staveCount < accids.length; ++j) {
253
- rowMap.push(accids[j + i * staveCount]);
254
- }
255
- const notes = rowMap.map((accidType) => f
256
- .StaveNote({ keys: ['a/4'], duration: '4', stem_direction: Stem.UP })
257
- .addModifier(f.Accidental({ type: accidType }), 0));
258
- const voice = score.voice(notes, { time: rowMap.length + '/4' });
259
- voice.getTickables().forEach((tickable) => {
260
- tickable
261
- .getModifiers()
262
- .filter((modifier) => modifier.getAttribute('type') === Accidental.CATEGORY)
263
- .forEach((accid) => accid.setAsCautionary());
264
- });
265
- f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
266
- f.draw();
267
- }
268
- ok(true, 'Must successfully render cautionary accidentals');
269
- }
270
- function specialCases(options) {
271
- const f = VexFlowTests.makeFactory(options, 700, 240);
272
- const accid = makeNewAccid(f);
273
- f.Stave({ x: 10, y: 10, width: 550 });
274
- const notes = [
275
- f
276
- .StaveNote({ keys: ['f/4', 'd/5'], duration: '1' })
277
- .addModifier(accid('#'), 0)
278
- .addModifier(accid('b'), 1),
279
- f
280
- .StaveNote({ keys: ['c/4', 'g/4'], duration: '2' })
281
- .addModifier(accid('##'), 0)
282
- .addModifier(accid('##'), 1),
283
- f
284
- .StaveNote({ keys: ['b/3', 'd/4', 'f/4'], duration: '16' })
285
- .addModifier(accid('#'), 0)
286
- .addModifier(accid('#'), 1)
287
- .addModifier(accid('##'), 2),
288
- f
289
- .StaveNote({ keys: ['g/4', 'a/4', 'c/5', 'e/5'], duration: '16' })
290
- .addModifier(accid('b'), 0)
291
- .addModifier(accid('b'), 1)
292
- .addModifier(accid('n'), 3),
293
- f
294
- .StaveNote({ keys: ['e/4', 'g/4', 'b/4', 'c/5'], duration: '4' })
295
- .addModifier(accid('b').setAsCautionary(), 0)
296
- .addModifier(accid('b').setAsCautionary(), 1)
297
- .addModifier(accid('bb'), 2)
298
- .addModifier(accid('b'), 3),
299
- f
300
- .StaveNote({ keys: ['b/3', 'e/4', 'a/4', 'd/5', 'g/5'], duration: '8' })
301
- .addModifier(accid('bb'), 0)
302
- .addModifier(accid('b').setAsCautionary(), 1)
303
- .addModifier(accid('n').setAsCautionary(), 2)
304
- .addModifier(accid('#'), 3)
305
- .addModifier(accid('n').setAsCautionary(), 4),
306
- ];
307
- Formatter.SimpleFormat(notes, 0, { paddingBetween: 20 });
308
- notes.forEach((note, index) => {
309
- Note.plotMetrics(f.getContext(), note, 140);
310
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + index + ' has accidentals');
311
- note.getModifiersByType('Accidental').forEach((accid, index) => {
312
- ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
313
- });
314
- });
315
- f.draw();
316
- VexFlowTests.plotLegendForNoteWidth(f.getContext(), 480, 140);
317
- ok(true, 'Full Accidental');
318
- }
319
- function basicStemDown(options) {
320
- const f = VexFlowTests.makeFactory(options, 700, 240);
321
- const accid = makeNewAccid(f);
322
- f.Stave({ x: 10, y: 10, width: 550 });
323
- const notes = [
324
- f
325
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: 'w', stem_direction: -1 })
326
- .addModifier(accid('b'), 0)
327
- .addModifier(accid('#'), 1),
328
- f
329
- .StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: '2', stem_direction: -1 })
330
- .addModifier(accid('##'), 0)
331
- .addModifier(accid('n'), 1)
332
- .addModifier(accid('bb'), 2)
333
- .addModifier(accid('b'), 3)
334
- .addModifier(accid('#'), 4)
335
- .addModifier(accid('n'), 5)
336
- .addModifier(accid('bb'), 6),
337
- f
338
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16', stem_direction: -1 })
339
- .addModifier(accid('n'), 0)
340
- .addModifier(accid('#'), 1)
341
- .addModifier(accid('#'), 2)
342
- .addModifier(accid('b'), 3)
343
- .addModifier(accid('bb'), 4)
344
- .addModifier(accid('##'), 5)
345
- .addModifier(accid('#'), 6),
346
- ];
347
- Formatter.SimpleFormat(notes, 0, { paddingBetween: 30 });
348
- notes.forEach((note, noteIndex) => {
349
- Note.plotMetrics(f.getContext(), note, 140);
350
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + noteIndex + ' has accidentals');
351
- note.getModifiersByType('Accidental').forEach((accid, accidIndex) => {
352
- ok(accid.getWidth() > 0, 'Accidental ' + accidIndex + ' has set width');
353
- });
354
- });
355
- f.draw();
356
- VexFlowTests.plotLegendForNoteWidth(f.getContext(), 480, 140);
357
- ok(true, 'Full Accidental');
358
- }
359
- function multiVoice(options) {
360
- function showNotes(note1, note2, stave, ctx, x) {
361
- const modifierContext = new ModifierContext();
362
- note1.addToModifierContext(modifierContext);
363
- note2.addToModifierContext(modifierContext);
364
- new TickContext().addTickable(note1).addTickable(note2).preFormat().setX(x);
365
- note1.setContext(ctx).draw();
366
- note2.setContext(ctx).draw();
367
- Note.plotMetrics(ctx, note1, 180);
368
- Note.plotMetrics(ctx, note2, 15);
369
- }
370
- const f = VexFlowTests.makeFactory(options, 460, 250);
371
- const accid = makeNewAccid(f);
372
- const stave = f.Stave({ x: 10, y: 45, width: 420 });
373
- const ctx = f.getContext();
374
- stave.draw();
375
- let note1 = f
376
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '2', stem_direction: -1 })
377
- .addModifier(accid('b'), 0)
378
- .addModifier(accid('n'), 1)
379
- .addModifier(accid('#'), 2)
380
- .setStave(stave);
381
- let note2 = f
382
- .StaveNote({ keys: ['d/5', 'a/5', 'b/5'], duration: '2', stem_direction: 1 })
383
- .addModifier(accid('b'), 0)
384
- .addModifier(accid('bb'), 1)
385
- .addModifier(accid('##'), 2)
386
- .setStave(stave);
387
- showNotes(note1, note2, stave, ctx, 60);
388
- note1 = f
389
- .StaveNote({ keys: ['c/4', 'e/4', 'c/5'], duration: '2', stem_direction: -1 })
390
- .addModifier(accid('b'), 0)
391
- .addModifier(accid('n'), 1)
392
- .addModifier(accid('#'), 2)
393
- .setStave(stave);
394
- note2 = f
395
- .StaveNote({ keys: ['d/5', 'a/5', 'b/5'], duration: '4', stem_direction: 1 })
396
- .addModifier(accid('b'), 0)
397
- .setStave(stave);
398
- showNotes(note1, note2, stave, ctx, 150);
399
- note1 = f
400
- .StaveNote({ keys: ['d/4', 'c/5', 'd/5'], duration: '2', stem_direction: -1 })
401
- .addModifier(accid('b'), 0)
402
- .addModifier(accid('n'), 1)
403
- .addModifier(accid('#'), 2)
404
- .setStave(stave);
405
- note2 = f
406
- .StaveNote({ keys: ['d/5', 'a/5', 'b/5'], duration: '4', stem_direction: 1 })
407
- .addModifier(accid('b'), 0)
408
- .setStave(stave);
409
- showNotes(note1, note2, stave, ctx, 250);
410
- VexFlowTests.plotLegendForNoteWidth(ctx, 350, 150);
411
- ok(true, 'Full Accidental');
412
- }
413
- function microtonal(options) {
414
- const f = VexFlowTests.makeFactory(options, 700, 240);
415
- const accid = makeNewAccid(f);
416
- const ctx = f.getContext();
417
- f.Stave({ x: 10, y: 10, width: 650 });
418
- const notes = [
419
- f
420
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '1' })
421
- .addModifier(accid('db'), 0)
422
- .addModifier(accid('d'), 1),
423
- f
424
- .StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: '2' })
425
- .addModifier(accid('bbs'), 0)
426
- .addModifier(accid('++'), 1)
427
- .addModifier(accid('+'), 2)
428
- .addModifier(accid('d'), 3)
429
- .addModifier(accid('db'), 4)
430
- .addModifier(accid('+'), 5)
431
- .addModifier(accid('##'), 6),
432
- f
433
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16' })
434
- .addModifier(accid('++'), 0)
435
- .addModifier(accid('bbs'), 1)
436
- .addModifier(accid('+'), 2)
437
- .addModifier(accid('b'), 3)
438
- .addModifier(accid('db'), 4)
439
- .addModifier(accid('##'), 5)
440
- .addModifier(accid('#'), 6),
441
- f
442
- .StaveNote({ keys: ['a/3', 'c/4', 'e/4', 'b/4', 'd/5', 'g/5'], duration: '1' })
443
- .addModifier(accid('#'), 0)
444
- .addModifier(accid('db').setAsCautionary(), 1)
445
- .addModifier(accid('bbs').setAsCautionary(), 2)
446
- .addModifier(accid('b'), 3)
447
- .addModifier(accid('++').setAsCautionary(), 4)
448
- .addModifier(accid('d').setAsCautionary(), 5),
449
- f
450
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'd/5', 'g/5'], duration: '16' })
451
- .addModifier(accid('++-'), 0)
452
- .addModifier(accid('+-'), 1)
453
- .addModifier(accid('bs'), 2)
454
- .addModifier(accid('bss'), 3)
455
- .addModifier(accid('afhf'), 4)
456
- .addModifier(accid('ashs'), 5),
457
- ];
458
- Formatter.SimpleFormat(notes, 0, { paddingBetween: 35 });
459
- notes.forEach((note, index) => {
460
- Note.plotMetrics(f.getContext(), note, 140);
461
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + index + ' has accidentals');
462
- note.getModifiersByType('Accidental').forEach((accid, index) => {
463
- ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
464
- });
465
- });
466
- f.draw();
467
- VexFlowTests.plotLegendForNoteWidth(ctx, 580, 140);
468
- ok(true, 'Microtonal Accidental');
469
- }
470
- function microtonal_iranian(options) {
471
- const f = VexFlowTests.makeFactory(options, 700, 240);
472
- const accid = makeNewAccid(f);
473
- const ctx = f.getContext();
474
- f.Stave({ x: 10, y: 10, width: 650 });
475
- const notes = [
476
- f
477
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: '1' })
478
- .addModifier(accid('k'), 0)
479
- .addModifier(accid('o'), 1),
480
- f
481
- .StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: '2' })
482
- .addModifier(accid('b'), 0)
483
- .addModifier(accid('k'), 1)
484
- .addModifier(accid('n'), 2)
485
- .addModifier(accid('o'), 3)
486
- .addModifier(accid('#'), 4)
487
- .addModifier(accid('bb'), 5)
488
- .addModifier(accid('##'), 6),
489
- f
490
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16' })
491
- .addModifier(accid('o'), 0)
492
- .addModifier(accid('k'), 1)
493
- .addModifier(accid('n'), 2)
494
- .addModifier(accid('b'), 3)
495
- .addModifier(accid('bb'), 4)
496
- .addModifier(accid('##'), 5)
497
- .addModifier(accid('#'), 6),
498
- f
499
- .StaveNote({ keys: ['a/3', 'c/4', 'e/4', 'b/4', 'd/5', 'g/5'], duration: '1' })
500
- .addModifier(accid('#'), 0)
501
- .addModifier(accid('o').setAsCautionary(), 1)
502
- .addModifier(accid('n').setAsCautionary(), 2)
503
- .addModifier(accid('b'), 3)
504
- .addModifier(accid('k').setAsCautionary(), 4),
505
- f
506
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4'], duration: '16' })
507
- .addModifier(accid('k'), 0)
508
- .addModifier(accid('k'), 1)
509
- .addModifier(accid('k'), 2)
510
- .addModifier(accid('k'), 3),
511
- ];
512
- Formatter.SimpleFormat(notes, 0, { paddingBetween: 35 });
513
- notes.forEach((note, index) => {
514
- Note.plotMetrics(f.getContext(), note, 140);
515
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + index + ' has accidentals');
516
- note.getModifiersByType('Accidental').forEach((accid, index) => {
517
- ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
518
- });
519
- });
520
- f.draw();
521
- VexFlowTests.plotLegendForNoteWidth(ctx, 580, 140);
522
- ok(true, 'Microtonal Accidental (Iranian)');
523
- }
524
- function sagittal(options) {
525
- const f = VexFlowTests.makeFactory(options, 700, 240);
526
- const accid = makeNewAccid(f);
527
- const ctx = f.getContext();
528
- f.Stave({ x: 10, y: 10, width: 650 });
529
- const notes = [
530
- f
531
- .StaveNote({ keys: ['d/4', 'f/4', 'b/4', 'b/4'], duration: '4' })
532
- .addModifier(accid('accSagittal11MediumDiesisUp'), 1)
533
- .addModifier(accid('accSagittal5CommaDown'), 2)
534
- .addModifier(accid('b'), 3)
535
- .addModifier(accid('accSagittal7CommaDown'), 3),
536
- f
537
- .StaveNote({ keys: ['d/4', 'f/4', 'a/4', 'b/4'], duration: '4' })
538
- .addModifier(accid('accSagittal35LargeDiesisDown'), 2),
539
- f.StaveNote({ keys: ['c/4', 'e/4', 'g/4', 'c/5'], duration: '8' }).addModifier(accid('accSagittal5CommaDown'), 1),
540
- f
541
- .StaveNote({ keys: ['c/4', 'e/4', 'g/4', 'b/4'], duration: '8' })
542
- .addModifier(accid('b'), 1)
543
- .addModifier(accid('accSagittal7CommaDown'), 1)
544
- .addModifier(accid('accSagittal11LargeDiesisDown'), 3),
545
- f
546
- .StaveNote({ keys: ['d/4', 'f/4', 'b/4', 'b/4'], duration: '4' })
547
- .addModifier(accid('accSagittal11MediumDiesisUp'), 1)
548
- .addModifier(accid('accSagittal5CommaDown'), 2)
549
- .addModifier(accid('accSagittalFlat7CDown'), 3),
550
- f
551
- .StaveNote({ keys: ['d/4', 'f/4', 'a/4', 'b/4'], duration: '4' })
552
- .addModifier(accid('accSagittal35LargeDiesisDown'), 2),
553
- f.StaveNote({ keys: ['c/4', 'e/4', 'g/4', 'c/5'], duration: '8' }).addModifier(accid('accSagittal5CommaDown'), 1),
554
- f
555
- .StaveNote({ keys: ['c/4', 'e/4', 'g/4', 'b/4'], duration: '8' })
556
- .addModifier(accid('accSagittalFlat7CDown'), 1)
557
- .addModifier(accid('accSagittal11LargeDiesisDown'), 3),
558
- ];
559
- f.StaveTie({
560
- from: notes[0],
561
- to: notes[1],
562
- first_indices: [0, 1],
563
- last_indices: [0, 1],
564
- });
565
- f.StaveTie({
566
- from: notes[0],
567
- to: notes[1],
568
- first_indices: [3],
569
- last_indices: [3],
570
- options: {
571
- direction: Stem.DOWN,
572
- },
573
- });
574
- f.StaveTie({
575
- from: notes[4],
576
- to: notes[5],
577
- first_indices: [0, 1],
578
- last_indices: [0, 1],
579
- });
580
- f.StaveTie({
581
- from: notes[4],
582
- to: notes[5],
583
- first_indices: [3],
584
- last_indices: [3],
585
- options: {
586
- direction: Stem.DOWN,
587
- },
588
- });
589
- f.Beam({ notes: notes.slice(2, 4) });
590
- f.Beam({ notes: notes.slice(6, 8) });
591
- Formatter.SimpleFormat(notes);
592
- notes.forEach((note, index) => {
593
- Note.plotMetrics(f.getContext(), note, 140);
594
- ok(note.getModifiersByType('Accidental').length > 0, 'Note ' + index + ' has accidentals');
595
- note.getModifiersByType('Accidental').forEach((accid, index) => {
596
- ok(accid.getWidth() > 0, 'Accidental ' + index + ' has set width');
597
- });
598
- });
599
- f.draw();
600
- VexFlowTests.plotLegendForNoteWidth(ctx, 580, 140);
601
- ok(true, 'Sagittal');
602
- }
603
- function automaticAccidentals0(options) {
604
- const f = VexFlowTests.makeFactory(options, 700, 200);
605
- const stave = f.Stave();
606
- const notes = [
607
- { keys: ['c/4', 'c/5'], duration: '4' },
608
- { keys: ['c#/4', 'c#/5'], duration: '4' },
609
- { keys: ['c#/4', 'c#/5'], duration: '4' },
610
- { keys: ['c##/4', 'c##/5'], duration: '4' },
611
- { keys: ['c##/4', 'c##/5'], duration: '4' },
612
- { keys: ['c/4', 'c/5'], duration: '4' },
613
- { keys: ['cn/4', 'cn/5'], duration: '4' },
614
- { keys: ['cbb/4', 'cbb/5'], duration: '4' },
615
- { keys: ['cbb/4', 'cbb/5'], duration: '4' },
616
- { keys: ['cb/4', 'cb/5'], duration: '4' },
617
- { keys: ['cb/4', 'cb/5'], duration: '4' },
618
- { keys: ['c/4', 'c/5'], duration: '4' },
619
- ].map(f.StaveNote.bind(f));
620
- const gracenotes = [{ keys: ['d#/4'], duration: '16', slash: true }].map(f.GraceNote.bind(f));
621
- notes[0].addModifier(f.GraceNoteGroup({ notes: gracenotes }).beamNotes(), 0);
622
- const voice = f
623
- .Voice()
624
- .setMode(Voice.Mode.SOFT)
625
- .addTickable(new TimeSigNote('12/4').setStave(stave))
626
- .addTickables(notes);
627
- Accidental.applyAccidentals([voice], 'C');
628
- new Formatter().joinVoices([voice]).formatToStave([voice], stave);
629
- f.draw();
630
- ok(true);
631
- }
632
- function automaticAccidentals1(options) {
633
- const f = VexFlowTests.makeFactory(options, 700, 150);
634
- const stave = f.Stave().addKeySignature('Ab');
635
- const notes = [
636
- { keys: ['c/4'], duration: '4' },
637
- { keys: ['d/4'], duration: '4' },
638
- { keys: ['e/4'], duration: '4' },
639
- { keys: ['f/4'], duration: '4' },
640
- { keys: ['g/4'], duration: '4' },
641
- { keys: ['a/4'], duration: '4' },
642
- { keys: ['b/4'], duration: '4' },
643
- { keys: ['c/5'], duration: '4' },
644
- ].map(f.StaveNote.bind(f));
645
- const voice = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
646
- Accidental.applyAccidentals([voice], 'Ab');
647
- new Formatter().joinVoices([voice]).formatToStave([voice], stave);
648
- f.draw();
649
- ok(true);
650
- }
651
- function automaticAccidentals2(options) {
652
- const f = VexFlowTests.makeFactory(options, 700, 150);
653
- const stave = f.Stave().addKeySignature('A');
654
- const notes = [
655
- { keys: ['a/4'], duration: '4' },
656
- { keys: ['b/4'], duration: '4' },
657
- { keys: ['c#/5'], duration: '4' },
658
- { keys: ['d/5'], duration: '4' },
659
- { keys: ['e/5'], duration: '4' },
660
- { keys: ['f#/5'], duration: '4' },
661
- { keys: ['g#/5'], duration: '4' },
662
- { keys: ['a/5'], duration: '4' },
663
- ].map(f.StaveNote.bind(f));
664
- const voice = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
665
- Accidental.applyAccidentals([voice], 'A');
666
- new Formatter().joinVoices([voice]).formatToStave([voice], stave);
667
- f.draw();
668
- ok(true);
669
- }
670
- function automaticAccidentals3(options) {
671
- const f = VexFlowTests.makeFactory(options, 700, 150);
672
- const stave = f.Stave().addKeySignature('A');
673
- const score = f.EasyScore();
674
- score.set({ time: '8/4' });
675
- const notes = score.notes('A4/q, B4/q, C#5/q, D5/q, E5/q,F#5/q, G#5/q, A5/q', { stem: 'UP' });
676
- const voice = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes);
677
- Accidental.applyAccidentals([voice], 'A');
678
- new Formatter().joinVoices([voice]).formatToStave([voice], stave);
679
- f.draw();
680
- ok(true);
681
- }
682
- function automaticAccidentalsMultiVoiceInline(options) {
683
- const f = VexFlowTests.makeFactory(options, 700, 150);
684
- const stave = f.Stave().addKeySignature('Ab');
685
- const notes0 = [
686
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
687
- { keys: ['d/4'], duration: '4', stem_direction: -1 },
688
- { keys: ['e/4'], duration: '4', stem_direction: -1 },
689
- { keys: ['f/4'], duration: '4', stem_direction: -1 },
690
- { keys: ['g/4'], duration: '4', stem_direction: -1 },
691
- { keys: ['a/4'], duration: '4', stem_direction: -1 },
692
- { keys: ['b/4'], duration: '4', stem_direction: -1 },
693
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
694
- ].map(f.StaveNote.bind(f));
695
- const notes1 = [
696
- { keys: ['c/5'], duration: '4' },
697
- { keys: ['d/5'], duration: '4' },
698
- { keys: ['e/5'], duration: '4' },
699
- { keys: ['f/5'], duration: '4' },
700
- { keys: ['g/5'], duration: '4' },
701
- { keys: ['a/5'], duration: '4' },
702
- { keys: ['b/5'], duration: '4' },
703
- { keys: ['c/6'], duration: '4' },
704
- ].map(f.StaveNote.bind(f));
705
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
706
- const voice1 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes1);
707
- Accidental.applyAccidentals([voice0, voice1], 'Ab');
708
- equal(hasAccidental(notes0[0]), false);
709
- equal(hasAccidental(notes0[1]), true);
710
- equal(hasAccidental(notes0[2]), true);
711
- equal(hasAccidental(notes0[3]), false);
712
- equal(hasAccidental(notes0[4]), false);
713
- equal(hasAccidental(notes0[5]), true);
714
- equal(hasAccidental(notes0[6]), true);
715
- equal(hasAccidental(notes0[7]), false);
716
- equal(hasAccidental(notes1[0]), false);
717
- equal(hasAccidental(notes1[1]), true);
718
- equal(hasAccidental(notes1[2]), true);
719
- equal(hasAccidental(notes1[3]), false);
720
- equal(hasAccidental(notes1[4]), false);
721
- equal(hasAccidental(notes1[5]), true);
722
- equal(hasAccidental(notes1[6]), true);
723
- equal(hasAccidental(notes1[7]), false);
724
- new Formatter().joinVoices([voice0, voice1]).formatToStave([voice0, voice1], stave);
725
- f.draw();
726
- ok(true);
727
- }
728
- function automaticAccidentalsMultiVoiceOffset(options) {
729
- const f = VexFlowTests.makeFactory(options, 700, 150);
730
- const stave = f.Stave().addKeySignature('Cb');
731
- const notes0 = [
732
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
733
- { keys: ['d/4'], duration: '4', stem_direction: -1 },
734
- { keys: ['e/4'], duration: '4', stem_direction: -1 },
735
- { keys: ['f/4'], duration: '4', stem_direction: -1 },
736
- { keys: ['g/4'], duration: '4', stem_direction: -1 },
737
- { keys: ['a/4'], duration: '4', stem_direction: -1 },
738
- { keys: ['b/4'], duration: '4', stem_direction: -1 },
739
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
740
- ].map(f.StaveNote.bind(f));
741
- const notes1 = [
742
- { keys: ['c/5'], duration: '8' },
743
- { keys: ['c/5'], duration: '4' },
744
- { keys: ['d/5'], duration: '4' },
745
- { keys: ['e/5'], duration: '4' },
746
- { keys: ['f/5'], duration: '4' },
747
- { keys: ['g/5'], duration: '4' },
748
- { keys: ['a/5'], duration: '4' },
749
- { keys: ['b/5'], duration: '4' },
750
- { keys: ['c/6'], duration: '4' },
751
- ].map(f.StaveNote.bind(f));
752
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
753
- const voice1 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes1);
754
- Accidental.applyAccidentals([voice0, voice1], 'Cb');
755
- equal(hasAccidental(notes0[0]), true);
756
- equal(hasAccidental(notes0[1]), true);
757
- equal(hasAccidental(notes0[2]), true);
758
- equal(hasAccidental(notes0[3]), true);
759
- equal(hasAccidental(notes0[4]), true);
760
- equal(hasAccidental(notes0[5]), true);
761
- equal(hasAccidental(notes0[6]), true);
762
- equal(hasAccidental(notes0[7]), false, 'Natural Remembered');
763
- equal(hasAccidental(notes1[0]), true);
764
- equal(hasAccidental(notes1[1]), false);
765
- equal(hasAccidental(notes1[2]), true);
766
- equal(hasAccidental(notes1[3]), true);
767
- equal(hasAccidental(notes1[4]), true);
768
- equal(hasAccidental(notes1[5]), true);
769
- equal(hasAccidental(notes1[6]), true);
770
- equal(hasAccidental(notes1[7]), true);
771
- new Formatter().joinVoices([voice0, voice1]).formatToStave([voice0, voice1], stave);
772
- f.draw();
773
- ok(true);
774
- }
775
- function automaticAccidentalsCornerCases1(options) {
776
- const f = VexFlowTests.makeFactory(options, 700, 150);
777
- const stave = f.Stave().addKeySignature('C');
778
- const notes0 = [
779
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
780
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
781
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
782
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
783
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
784
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
785
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
786
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
787
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
788
- ].map(f.StaveNote.bind(f));
789
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
790
- Accidental.applyAccidentals([voice0], 'C');
791
- equal(hasAccidental(notes0[0]), false);
792
- equal(hasAccidental(notes0[1]), true);
793
- equal(hasAccidental(notes0[2]), false);
794
- equal(hasAccidental(notes0[3]), true);
795
- equal(hasAccidental(notes0[4]), false);
796
- equal(hasAccidental(notes0[5]), true);
797
- equal(hasAccidental(notes0[6]), false);
798
- equal(hasAccidental(notes0[7]), true);
799
- equal(hasAccidental(notes0[8]), false);
800
- new Formatter().joinVoices([voice0]).formatToStave([voice0], stave);
801
- f.draw();
802
- ok(true);
803
- }
804
- function automaticAccidentalsCornerCases2(options) {
805
- const f = VexFlowTests.makeFactory(options, 700, 150);
806
- const stave = f.Stave().addKeySignature('C');
807
- const notes0 = [
808
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
809
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
810
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
811
- { keys: ['c#/5'], duration: '4', stem_direction: -1 },
812
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
813
- { keys: ['c#/5'], duration: '4', stem_direction: -1 },
814
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
815
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
816
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
817
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
818
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
819
- { keys: ['cb/5'], duration: '4', stem_direction: -1 },
820
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
821
- { keys: ['cb/5'], duration: '4', stem_direction: -1 },
822
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
823
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
824
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
825
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
826
- ].map(f.StaveNote.bind(f));
827
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
828
- Accidental.applyAccidentals([voice0], 'C');
829
- equal(hasAccidental(notes0[0]), false);
830
- equal(hasAccidental(notes0[2]), true);
831
- equal(hasAccidental(notes0[4]), false);
832
- equal(hasAccidental(notes0[6]), true);
833
- equal(hasAccidental(notes0[8]), false);
834
- equal(hasAccidental(notes0[10]), true);
835
- equal(hasAccidental(notes0[12]), false);
836
- equal(hasAccidental(notes0[14]), true);
837
- equal(hasAccidental(notes0[16]), false);
838
- equal(hasAccidental(notes0[1]), false);
839
- equal(hasAccidental(notes0[3]), true);
840
- equal(hasAccidental(notes0[5]), false);
841
- equal(hasAccidental(notes0[7]), true);
842
- equal(hasAccidental(notes0[9]), false);
843
- equal(hasAccidental(notes0[11]), true);
844
- equal(hasAccidental(notes0[13]), false);
845
- equal(hasAccidental(notes0[15]), true);
846
- equal(hasAccidental(notes0[17]), false);
847
- new Formatter().joinVoices([voice0]).formatToStave([voice0], stave);
848
- f.draw();
849
- ok(true);
850
- }
851
- function automaticAccidentalsCornerCases3(options) {
852
- const f = VexFlowTests.makeFactory(options, 700, 150);
853
- const stave = f.Stave().addKeySignature('C#');
854
- const notes0 = [
855
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
856
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
857
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
858
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
859
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
860
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
861
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
862
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
863
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
864
- ].map(f.StaveNote.bind(f));
865
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
866
- Accidental.applyAccidentals([voice0], 'C#');
867
- equal(hasAccidental(notes0[0]), true);
868
- equal(hasAccidental(notes0[1]), true);
869
- equal(hasAccidental(notes0[2]), false);
870
- equal(hasAccidental(notes0[3]), true);
871
- equal(hasAccidental(notes0[4]), false);
872
- equal(hasAccidental(notes0[5]), true);
873
- equal(hasAccidental(notes0[6]), false);
874
- equal(hasAccidental(notes0[7]), true);
875
- equal(hasAccidental(notes0[8]), false);
876
- new Formatter().joinVoices([voice0]).formatToStave([voice0], stave);
877
- f.draw();
878
- ok(true);
879
- }
880
- function automaticAccidentalsCornerCases4(options) {
881
- const f = VexFlowTests.makeFactory(options, 700, 150);
882
- const stave = f.Stave().addKeySignature('C#');
883
- const notes0 = [
884
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
885
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
886
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
887
- { keys: ['c#/5'], duration: '4', stem_direction: -1 },
888
- { keys: ['c#/4'], duration: '4', stem_direction: -1 },
889
- { keys: ['c#/5'], duration: '4', stem_direction: -1 },
890
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
891
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
892
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
893
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
894
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
895
- { keys: ['cb/5'], duration: '4', stem_direction: -1 },
896
- { keys: ['cb/4'], duration: '4', stem_direction: -1 },
897
- { keys: ['cb/5'], duration: '4', stem_direction: -1 },
898
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
899
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
900
- { keys: ['c/4'], duration: '4', stem_direction: -1 },
901
- { keys: ['c/5'], duration: '4', stem_direction: -1 },
902
- ].map(f.StaveNote.bind(f));
903
- const voice0 = f.Voice().setMode(Voice.Mode.SOFT).addTickables(notes0);
904
- Accidental.applyAccidentals([voice0], 'C#');
905
- equal(hasAccidental(notes0[0]), true);
906
- equal(hasAccidental(notes0[2]), true);
907
- equal(hasAccidental(notes0[4]), false);
908
- equal(hasAccidental(notes0[6]), true);
909
- equal(hasAccidental(notes0[8]), false);
910
- equal(hasAccidental(notes0[10]), true);
911
- equal(hasAccidental(notes0[12]), false);
912
- equal(hasAccidental(notes0[14]), true);
913
- equal(hasAccidental(notes0[16]), false);
914
- equal(hasAccidental(notes0[1]), true);
915
- equal(hasAccidental(notes0[3]), true);
916
- equal(hasAccidental(notes0[5]), false);
917
- equal(hasAccidental(notes0[7]), true);
918
- equal(hasAccidental(notes0[9]), false);
919
- equal(hasAccidental(notes0[11]), true);
920
- equal(hasAccidental(notes0[13]), false);
921
- equal(hasAccidental(notes0[15]), true);
922
- equal(hasAccidental(notes0[17]), false);
923
- new Formatter().joinVoices([voice0]).formatToStave([voice0], stave);
924
- f.draw();
925
- ok(true);
926
- }
927
- function factoryAPI(options) {
928
- const f = VexFlowTests.makeFactory(options, 700, 240);
929
- f.Stave({ x: 10, y: 10, width: 550 });
930
- const accid = makeNewAccid(f);
931
- const notes = [
932
- f
933
- .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: 'w' })
934
- .addModifier(accid('b'), 0)
935
- .addModifier(accid('#'), 1),
936
- f
937
- .StaveNote({ keys: ['d/4', 'e/4', 'f/4', 'a/4', 'c/5', 'e/5', 'g/5'], duration: 'h' })
938
- .addModifier(accid('##'), 0)
939
- .addModifier(accid('n'), 1)
940
- .addModifier(accid('bb'), 2)
941
- .addModifier(accid('b'), 3)
942
- .addModifier(accid('#'), 4)
943
- .addModifier(accid('n'), 5)
944
- .addModifier(accid('bb'), 6),
945
- f
946
- .StaveNote({ keys: ['f/4', 'g/4', 'a/4', 'b/4', 'c/5', 'e/5', 'g/5'], duration: '16' })
947
- .addModifier(accid('n'), 0)
948
- .addModifier(accid('#'), 1)
949
- .addModifier(accid('#'), 2)
950
- .addModifier(accid('b'), 3)
951
- .addModifier(accid('bb'), 4)
952
- .addModifier(accid('##'), 5)
953
- .addModifier(accid('#'), 6),
954
- f
955
- .StaveNote({ keys: ['a/3', 'c/4', 'e/4', 'b/4', 'd/5', 'g/5'], duration: 'w' })
956
- .addModifier(accid('#'), 0)
957
- .addModifier(accid('##').setAsCautionary(), 1)
958
- .addModifier(accid('#').setAsCautionary(), 2)
959
- .addModifier(accid('b'), 3)
960
- .addModifier(accid('bb').setAsCautionary(), 4)
961
- .addModifier(accid('b').setAsCautionary(), 5),
962
- ];
963
- Formatter.SimpleFormat(notes);
964
- notes.forEach((n, i) => {
965
- ok(n.getModifiersByType('Accidental').length > 0, 'Note ' + i + ' has accidentals');
966
- n.getModifiersByType('Accidental').forEach((accid, i) => {
967
- ok(accid.getWidth() > 0, 'Accidental ' + i + ' has set width');
968
- });
969
- });
970
- f.draw();
971
- ok(true, 'Factory API');
972
- }
973
- VexFlowTests.register(AccidentalTests);
974
- export { AccidentalTests };