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,669 +0,0 @@
1
- import { VexFlowTests } from './vexflow_test_helpers.js';
2
- import { Accidental } from '../src/accidental.js';
3
- import { Annotation, AnnotationVerticalJustify } from '../src/annotation.js';
4
- import { Articulation } from '../src/articulation.js';
5
- import { Beam } from '../src/beam.js';
6
- import { Bend } from '../src/bend.js';
7
- import { Dot } from '../src/dot.js';
8
- import { Flow } from '../src/flow.js';
9
- import { Font, FontWeight } from '../src/font.js';
10
- import { Formatter } from '../src/formatter.js';
11
- import { FretHandFinger } from '../src/frethandfinger.js';
12
- import { ModifierPosition } from '../src/modifier.js';
13
- import { Note } from '../src/note.js';
14
- import { Registry } from '../src/registry.js';
15
- import { Stave } from '../src/stave.js';
16
- import { StaveConnector } from '../src/staveconnector.js';
17
- import { StaveNote } from '../src/stavenote.js';
18
- import { Stem } from '../src/stem.js';
19
- import { StringNumber } from '../src/stringnumber.js';
20
- import { Tables } from '../src/tables.js';
21
- import { Tuplet } from '../src/tuplet.js';
22
- import { Voice } from '../src/voice.js';
23
- import { MockTickable } from './mocks.js';
24
- const FormatterTests = {
25
- Start() {
26
- QUnit.module('Formatter');
27
- test('TickContext Building', buildTickContexts);
28
- const run = VexFlowTests.runTests;
29
- run('Whitespace and justify', rightJustify);
30
- run('Notehead padding', noteHeadPadding);
31
- run('Justification and alignment with accidentals', accidentalJustification);
32
- run('Long measure taking full space', longMeasureProblems);
33
- run('Vertical alignment - few unaligned beats', unalignedNoteDurations1);
34
- run('Vertical alignment - many unaligned beats', unalignedNoteDurations2, { globalSoftmax: false });
35
- run('Vertical alignment - many unaligned beats (global softmax)', unalignedNoteDurations2, { globalSoftmax: true });
36
- run('Vertical alignment - many mixed elements', alignedMixedElements, { globalSoftmax: true });
37
- run('StaveNote - Justification', justifyStaveNotes);
38
- run('Notes with Tab', notesWithTab);
39
- run('Multiple Staves - Justified', multiStaves, { debug: true });
40
- run('Softmax', softMax);
41
- run('Mixtime', mixTime);
42
- run('Tight', tightNotes1);
43
- run('Tight 2', tightNotes2);
44
- run('Annotations', annotations);
45
- run('Proportional Formatting - No Tuning', proportional, { debug: true, iterations: 0 });
46
- run('Proportional Formatting - No Justification', proportional, { justify: false, debug: true, iterations: 0 });
47
- run('Proportional Formatting (20 iterations)', proportional, { debug: true, iterations: 20, alpha: 0.5 });
48
- },
49
- };
50
- function getGlyphWidth(glyphName) {
51
- const musicFont = Tables.currentMusicFont();
52
- const glyph = musicFont.getGlyphs()[glyphName];
53
- const widthInEm = (glyph.x_max - glyph.x_min) / musicFont.getResolution();
54
- return widthInEm * 38 * Font.scaleToPxFrom.pt;
55
- }
56
- function buildTickContexts() {
57
- function createTickable(beat) {
58
- return new MockTickable().setTicks(beat);
59
- }
60
- const BEAT = (1 * Flow.RESOLUTION) / 4;
61
- const tickables1 = [
62
- createTickable(BEAT).setWidth(10),
63
- createTickable(BEAT * 2).setWidth(20),
64
- createTickable(BEAT).setWidth(30),
65
- ];
66
- const tickables2 = [
67
- createTickable(BEAT * 2).setWidth(10),
68
- createTickable(BEAT).setWidth(20),
69
- createTickable(BEAT).setWidth(30),
70
- ];
71
- const voice1 = new Voice(Flow.TIME4_4);
72
- const voice2 = new Voice(Flow.TIME4_4);
73
- voice1.addTickables(tickables1);
74
- voice2.addTickables(tickables2);
75
- const formatter = new Formatter();
76
- const tContexts = formatter.createTickContexts([voice1, voice2]);
77
- equal(tContexts.list.length, 4, 'Voices should have four tick contexts');
78
- throws(() => formatter.getMinTotalWidth(), /NoMinTotalWidth/, 'Expected to throw exception');
79
- ok(formatter.preCalculateMinTotalWidth([voice1, voice2]), 'Successfully runs preCalculateMinTotalWidth');
80
- equal(formatter.getMinTotalWidth(), 88, 'Get minimum total width without passing voices');
81
- formatter.preFormat();
82
- equal(formatter.getMinTotalWidth(), 88, 'Minimum total width');
83
- equal(tickables1[0].getX(), tickables2[0].getX(), 'First notes of both voices have the same X');
84
- equal(tickables1[2].getX(), tickables2[2].getX(), 'Last notes of both voices have the same X');
85
- ok(tickables1[1].getX() < tickables2[1].getX(), 'Second note of voice 2 is to the right of the second note of voice 1');
86
- }
87
- function rightJustify(options) {
88
- const f = VexFlowTests.makeFactory(options, 1200, 300);
89
- const getTickables = (time, n, duration) => {
90
- const tickar = [];
91
- let i = 0;
92
- for (i = 0; i < n; ++i) {
93
- tickar.push(new StaveNote({ keys: ['f/4'], duration }));
94
- }
95
- return new Voice(time).addTickables(tickar);
96
- };
97
- const renderTest = (time, n, duration, x, width) => {
98
- const formatter = f.Formatter();
99
- const stave = f.Stave({ x, y: 40, width });
100
- const voice = getTickables(time, n, duration);
101
- formatter.joinVoices([voice]).formatToStave([voice], stave);
102
- stave.draw();
103
- voice.draw(f.getContext(), stave);
104
- };
105
- renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 2, '2', 10, 300);
106
- renderTest({ num_beats: 4, beat_value: 4, resolution: 4 * 4096 }, 1, 'w', 310, 300);
107
- renderTest({ num_beats: 3, beat_value: 4, resolution: 4 * 4096 }, 3, '4', 610, 300);
108
- renderTest({ num_beats: 3, beat_value: 4, resolution: 4 * 4096 }, 6, '8', 910, 300);
109
- ok(true);
110
- }
111
- function noteHeadPadding(options) {
112
- const registry = new Registry();
113
- Registry.enableDefaultRegistry(registry);
114
- const f = VexFlowTests.makeFactory(options, 600, 300);
115
- const score = f.EasyScore();
116
- score.set({ time: '9/8' });
117
- const notes1 = score.notes('(d5 f5)/8,(c5 e5)/8,(d5 f5)/8,(c5 e5)/2.');
118
- const beams = [new Beam(notes1.slice(0, 3), true)];
119
- const voice1 = new Voice().setMode(Voice.Mode.SOFT);
120
- const notes2 = score.notes('(g4 an4)/2.,(g4 a4)/4.', { clef: 'treble' });
121
- const voice2 = new Voice().setMode(Voice.Mode.SOFT);
122
- voice2.addTickables(notes2);
123
- voice1.addTickables(notes1);
124
- const formatter = f.Formatter().joinVoices([voice1]).joinVoices([voice2]);
125
- const width = formatter.preCalculateMinTotalWidth([voice1, voice2]);
126
- formatter.format([voice1, voice2], width);
127
- const staveWidth = width + Stave.defaultPadding;
128
- const stave1 = f.Stave({ y: 50, width: staveWidth });
129
- const stave2 = f.Stave({ y: 150, width: staveWidth });
130
- stave1.draw();
131
- stave2.draw();
132
- voice1.draw(f.getContext(), stave1);
133
- voice2.draw(f.getContext(), stave2);
134
- beams.forEach((b) => b.setContext(f.getContext()).draw());
135
- ok(true);
136
- }
137
- function longMeasureProblems(options) {
138
- const registry = new Registry();
139
- Registry.enableDefaultRegistry(registry);
140
- const f = VexFlowTests.makeFactory(options, 1500, 300);
141
- const score = f.EasyScore();
142
- score.set({ time: '4/4' });
143
- const notes1 = score.notes('b4/4,b4/8,b4/8,b4/4,b4/4,b4/2,b4/2,b4/4,b4/8,b4/8,b4/4,b4/4,b4/2,b4/2,b4/4,b4/8,b4/8,b4/4,b4/4,b4/2,b4/2,b4/4,b4/2,b4/8,b4/8');
144
- const voice1 = new Voice().setMode(Voice.Mode.SOFT);
145
- const notes2 = score.notes('d3/4,(ab3 f4)/2,d3/4,ab3/4,d3/2,ab3/4,d3/4,ab3/2,d3/4,ab3/4,d3/2,ab3/4,d3/4,ab3/2,d3/4,ab3/4,d3/2,ab3/4,d4/4,d4/2,d4/4', { clef: 'bass' });
146
- const voice2 = new Voice().setMode(Voice.Mode.SOFT);
147
- voice2.addTickables(notes2);
148
- voice1.addTickables(notes1);
149
- const formatter = f.Formatter().joinVoices([voice1]).joinVoices([voice2]);
150
- const width = formatter.preCalculateMinTotalWidth([voice1, voice2]);
151
- formatter.format([voice1, voice2], width);
152
- const stave1 = f.Stave({ y: 50, width: width + Stave.defaultPadding });
153
- const stave2 = f.Stave({ y: 200, width: width + Stave.defaultPadding });
154
- stave1.draw();
155
- stave2.draw();
156
- voice1.draw(f.getContext(), stave1);
157
- voice2.draw(f.getContext(), stave2);
158
- ok(true);
159
- }
160
- function accidentalJustification(options) {
161
- const f = VexFlowTests.makeFactory(options, 600, 300);
162
- const score = f.EasyScore();
163
- const notes11 = score.notes('a4/2, a4/4, a4/8, ab4/16, an4/16');
164
- const voice11 = score.voice(notes11, { time: '4/4' });
165
- const notes21 = score.notes('c4/2, d4/8, d4/8, e4/8, e4/8');
166
- const voice21 = score.voice(notes21, { time: '4/4' });
167
- let beams = Beam.generateBeams(notes11.slice(2));
168
- beams = beams.concat(beams, Beam.generateBeams(notes21.slice(1, 3)));
169
- beams = beams.concat(Beam.generateBeams(notes21.slice(3)));
170
- const formatter = f.Formatter({ softmaxFactor: 100 }).joinVoices([voice11]).joinVoices([voice21]);
171
- const width = formatter.preCalculateMinTotalWidth([voice11, voice21]);
172
- const stave11 = f.Stave({ y: 20, width: width + Stave.defaultPadding });
173
- const stave21 = f.Stave({ y: 130, width: width + Stave.defaultPadding });
174
- formatter.format([voice11, voice21], width);
175
- const ctx = f.getContext();
176
- stave11.setContext(ctx).draw();
177
- stave21.setContext(ctx).draw();
178
- voice11.draw(ctx, stave11);
179
- voice21.draw(ctx, stave21);
180
- beams.forEach((b) => b.setContext(ctx).draw());
181
- ok(true);
182
- }
183
- function unalignedNoteDurations1(options) {
184
- const f = VexFlowTests.makeFactory(options, 600, 250);
185
- const score = f.EasyScore();
186
- const notes11 = [
187
- new StaveNote({ keys: ['a/4'], duration: '8' }),
188
- new StaveNote({ keys: ['b/4'], duration: '4' }),
189
- new StaveNote({ keys: ['b/4'], duration: '8' }),
190
- ];
191
- const notes21 = [
192
- new StaveNote({ keys: ['a/4'], duration: '16' }),
193
- new StaveNote({ keys: ['b/4.'], duration: '4' }),
194
- new StaveNote({ keys: ['a/4'], duration: '8d' }),
195
- ];
196
- Dot.buildAndAttach([notes21[2]], { all: true });
197
- const ctx = f.getContext();
198
- const voice11 = score.voice(notes11, { time: '2/4' }).setMode(Voice.Mode.SOFT);
199
- const voice21 = score.voice(notes21, { time: '2/4' }).setMode(Voice.Mode.SOFT);
200
- const beams21 = Beam.generateBeams(notes21);
201
- const beams11 = Beam.generateBeams(notes11);
202
- const formatter = new Formatter();
203
- formatter.joinVoices([voice11]);
204
- formatter.joinVoices([voice21]);
205
- const width = formatter.preCalculateMinTotalWidth([voice11, voice21]);
206
- const stave11 = f.Stave({ y: 20, width: width + Stave.defaultPadding });
207
- const stave21 = f.Stave({ y: 130, width: width + Stave.defaultPadding });
208
- formatter.format([voice11, voice21], width);
209
- stave11.setContext(ctx).draw();
210
- stave21.setContext(ctx).draw();
211
- voice11.draw(ctx, stave11);
212
- voice21.draw(ctx, stave21);
213
- beams21.forEach((b) => b.setContext(ctx).draw());
214
- beams11.forEach((b) => b.setContext(ctx).draw());
215
- ok(voice11.getTickables()[1].getX() > voice21.getTickables()[1].getX());
216
- }
217
- function unalignedNoteDurations2(options) {
218
- const notes1 = [
219
- new StaveNote({ keys: ['b/4'], duration: '8r' }),
220
- new StaveNote({ keys: ['g/4'], duration: '16' }),
221
- new StaveNote({ keys: ['c/5'], duration: '16' }),
222
- new StaveNote({ keys: ['e/5'], duration: '16' }),
223
- new StaveNote({ keys: ['g/4'], duration: '16' }),
224
- new StaveNote({ keys: ['c/5'], duration: '16' }),
225
- new StaveNote({ keys: ['e/5'], duration: '16' }),
226
- new StaveNote({ keys: ['b/4'], duration: '8r' }),
227
- new StaveNote({ keys: ['g/4'], duration: '16' }),
228
- new StaveNote({ keys: ['c/5'], duration: '16' }),
229
- new StaveNote({ keys: ['e/5'], duration: '16' }),
230
- new StaveNote({ keys: ['g/4'], duration: '16' }),
231
- new StaveNote({ keys: ['c/5'], duration: '16' }),
232
- new StaveNote({ keys: ['e/5'], duration: '16' }),
233
- ];
234
- const notes2 = [
235
- new StaveNote({ keys: ['a/4'], duration: '16r' }),
236
- new StaveNote({ keys: ['e/4.'], duration: '8d' }),
237
- new StaveNote({ keys: ['e/4'], duration: '4' }),
238
- new StaveNote({ keys: ['a/4'], duration: '16r' }),
239
- new StaveNote({ keys: ['e/4.'], duration: '8d' }),
240
- new StaveNote({ keys: ['e/4'], duration: '4' }),
241
- ];
242
- const f = VexFlowTests.makeFactory(options, 750, 280);
243
- const context = f.getContext();
244
- const voice1 = new Voice({ num_beats: 4, beat_value: 4 });
245
- voice1.addTickables(notes1);
246
- const voice2 = new Voice({ num_beats: 4, beat_value: 4 });
247
- voice2.addTickables(notes2);
248
- const formatter = new Formatter({ softmaxFactor: 100, globalSoftmax: options.params.globalSoftmax });
249
- formatter.joinVoices([voice1]);
250
- formatter.joinVoices([voice2]);
251
- const width = formatter.preCalculateMinTotalWidth([voice1, voice2]);
252
- formatter.format([voice1, voice2], width);
253
- const stave1 = new Stave(10, 40, width + Stave.defaultPadding);
254
- const stave2 = new Stave(10, 100, width + Stave.defaultPadding);
255
- stave1.setContext(context).draw();
256
- stave2.setContext(context).draw();
257
- voice1.draw(context, stave1);
258
- voice2.draw(context, stave2);
259
- ok(voice1.getTickables()[1].getX() > voice2.getTickables()[1].getX());
260
- }
261
- function alignedMixedElements(options) {
262
- const f = VexFlowTests.makeFactory(options, 800, 500);
263
- const context = f.getContext();
264
- const stave = new Stave(10, 200, 400);
265
- const stave2 = new Stave(410, 200, 400);
266
- const notes = [
267
- new StaveNote({ keys: ['c/5'], duration: '8' })
268
- .addModifier(new Accidental('##'), 0)
269
- .addModifier(new FretHandFinger('4').setPosition(ModifierPosition.BELOW), 0)
270
- .addModifier(new StringNumber('3').setPosition(ModifierPosition.BELOW), 0)
271
- .addModifier(new Articulation('a.').setPosition(ModifierPosition.BELOW), 0)
272
- .addModifier(new Articulation('a>').setPosition(ModifierPosition.BELOW), 0)
273
- .addModifier(new Articulation('a^').setPosition(ModifierPosition.BELOW), 0)
274
- .addModifier(new Articulation('am').setPosition(ModifierPosition.BELOW), 0)
275
- .addModifier(new Articulation('a@u').setPosition(ModifierPosition.BELOW), 0)
276
- .addModifier(new Annotation('yyyy').setVerticalJustification(AnnotationVerticalJustify.BOTTOM), 0)
277
- .addModifier(new Annotation('xxxx').setVerticalJustification(AnnotationVerticalJustify.BOTTOM).setFont('sans-serif', 20), 0)
278
- .addModifier(new Annotation('ttt').setVerticalJustification(AnnotationVerticalJustify.BOTTOM).setFont('sans-serif', 20), 0),
279
- new StaveNote({ keys: ['c/5'], duration: '8', stem_direction: Stem.DOWN })
280
- .addModifier(new StringNumber('3').setPosition(ModifierPosition.BELOW), 0)
281
- .addModifier(new Articulation('a.').setPosition(ModifierPosition.BELOW), 0)
282
- .addModifier(new Articulation('a>').setPosition(ModifierPosition.BELOW), 0),
283
- new StaveNote({ keys: ['c/5'], duration: '8' }),
284
- ];
285
- const notes2 = [
286
- new StaveNote({ keys: ['c/5'], duration: '8' })
287
- .addModifier(new StringNumber('3').setPosition(ModifierPosition.ABOVE), 0)
288
- .addModifier(new Articulation('a.').setPosition(ModifierPosition.ABOVE), 0)
289
- .addModifier(new Annotation('yyyy').setVerticalJustification(AnnotationVerticalJustify.TOP), 0),
290
- new StaveNote({ keys: ['c/5'], duration: '8', stem_direction: Stem.DOWN })
291
- .addModifier(new FretHandFinger('4').setPosition(ModifierPosition.ABOVE), 0)
292
- .addModifier(new StringNumber('3').setPosition(ModifierPosition.ABOVE), 0)
293
- .addModifier(new Articulation('a.').setPosition(ModifierPosition.ABOVE), 0)
294
- .addModifier(new Articulation('a>').setPosition(ModifierPosition.ABOVE), 0)
295
- .addModifier(new Articulation('a^').setPosition(ModifierPosition.ABOVE), 0)
296
- .addModifier(new Articulation('am').setPosition(ModifierPosition.ABOVE), 0)
297
- .addModifier(new Articulation('a@u').setPosition(ModifierPosition.ABOVE), 0)
298
- .addModifier(new Annotation('yyyy').setVerticalJustification(AnnotationVerticalJustify.TOP), 0)
299
- .addModifier(new Annotation('xxxx').setVerticalJustification(AnnotationVerticalJustify.TOP).setFont('sans-serif', 20), 0)
300
- .addModifier(new Annotation('ttt').setVerticalJustification(AnnotationVerticalJustify.TOP).setFont('sans-serif', 20), 0),
301
- new StaveNote({ keys: ['c/5'], duration: '8' }),
302
- ];
303
- const tuplet = new Tuplet(notes).setTupletLocation(-1);
304
- const tuplet2 = new Tuplet(notes2).setTupletLocation(1);
305
- Formatter.FormatAndDraw(context, stave, notes);
306
- Formatter.FormatAndDraw(context, stave2, notes2);
307
- stave.setContext(context).draw();
308
- stave2.setContext(context).draw();
309
- tuplet.setContext(context).draw();
310
- tuplet2.setContext(context).draw();
311
- ok(true);
312
- }
313
- function justifyStaveNotes(options) {
314
- const f = VexFlowTests.makeFactory(options, 520, 280);
315
- const ctx = f.getContext();
316
- const score = f.EasyScore();
317
- let y = 30;
318
- function justifyToWidth(width) {
319
- f.Stave({ y: y }).addClef('treble');
320
- const voices = [
321
- score.voice(score.notes('(cbb4 en4 a4)/2, (d4 e4 f4)/8, (d4 f4 a4)/8, (cn4 f#4 a4)/4', { stem: 'down' })),
322
- score.voice(score.notes('(bb4 e#5 a5)/4, (d5 e5 f5)/2, (c##5 fb5 a5)/4', { stem: 'up' })),
323
- ];
324
- f.Formatter()
325
- .joinVoices(voices)
326
- .format(voices, width - (Stave.defaultPadding + getGlyphWidth('gClef')));
327
- voices[0].getTickables().forEach((note) => Note.plotMetrics(ctx, note, y + 140));
328
- voices[1].getTickables().forEach((note) => Note.plotMetrics(ctx, note, y - 20));
329
- y += 210;
330
- }
331
- justifyToWidth(520);
332
- f.draw();
333
- ok(true);
334
- }
335
- function notesWithTab(options) {
336
- const f = VexFlowTests.makeFactory(options, 420, 580);
337
- const score = f.EasyScore();
338
- let y = 10;
339
- function justifyToWidth(width) {
340
- const stave = f.Stave({ y: y }).addClef('treble');
341
- const voice = score.voice(score.notes('d#4/2, (c4 d4)/8, d4/8, (c#4 e4 a4)/4', { stem: 'up' }));
342
- y += 100;
343
- f.TabStave({ y: y }).addTabGlyph().setNoteStartX(stave.getNoteStartX());
344
- const tabVoice = score.voice([
345
- f.TabNote({ positions: [{ str: 3, fret: 6 }], duration: '2' }).addModifier(new Bend('Full'), 0),
346
- f
347
- .TabNote({
348
- positions: [
349
- { str: 2, fret: 3 },
350
- { str: 3, fret: 5 },
351
- ],
352
- duration: '8',
353
- })
354
- .addModifier(new Bend('Unison'), 1),
355
- f.TabNote({ positions: [{ str: 3, fret: 7 }], duration: '8' }),
356
- f.TabNote({
357
- positions: [
358
- { str: 3, fret: 6 },
359
- { str: 4, fret: 7 },
360
- { str: 2, fret: 5 },
361
- ],
362
- duration: '4',
363
- }),
364
- ]);
365
- f.Formatter().joinVoices([voice]).joinVoices([tabVoice]).format([voice, tabVoice], width);
366
- y += 150;
367
- }
368
- justifyToWidth(0);
369
- justifyToWidth(300);
370
- f.draw();
371
- ok(true);
372
- }
373
- function multiStaves(options) {
374
- const f = VexFlowTests.makeFactory(options, 600, 400);
375
- const ctx = f.getContext();
376
- const score = f.EasyScore();
377
- const notes11 = score.notes('f4/4, d4/8, g4/4, eb4/8');
378
- const notes21 = score.notes('d4/8, d4, d4, d4, e4, eb4');
379
- const notes31 = score.notes('a5/8, a5, a5, a5, a5, a5', { stem: 'down' });
380
- let voices = [
381
- score.voice(notes11, { time: '6/8' }),
382
- score.voice(notes21, { time: '6/8' }),
383
- score.voice(notes31, { time: '6/8' }),
384
- ];
385
- let formatter = f.Formatter();
386
- voices.forEach((v) => formatter.joinVoices([v]));
387
- let width = formatter.preCalculateMinTotalWidth(voices);
388
- formatter.format(voices, width);
389
- let beams = [
390
- new Beam(notes21.slice(0, 3), true),
391
- new Beam(notes21.slice(3, 6), true),
392
- new Beam(notes31.slice(0, 3), true),
393
- new Beam(notes31.slice(3, 6), true),
394
- ];
395
- const staveYs = [20, 130, 250];
396
- let staveWidth = width + getGlyphWidth('gClef') + getGlyphWidth('timeSig8') + Stave.defaultPadding;
397
- let staves = [
398
- f.Stave({ y: staveYs[0], width: staveWidth }).addClef('treble').addTimeSignature('6/8'),
399
- f.Stave({ y: staveYs[1], width: staveWidth }).addClef('treble').addTimeSignature('6/8'),
400
- f.Stave({ y: staveYs[2], width: staveWidth }).addClef('bass').addTimeSignature('6/8'),
401
- ];
402
- f.StaveConnector({
403
- top_stave: staves[1],
404
- bottom_stave: staves[2],
405
- type: 'brace',
406
- });
407
- for (let i = 0; i < staves.length; ++i) {
408
- staves[i].setContext(ctx).draw();
409
- voices[i].draw(ctx, staves[i]);
410
- }
411
- beams.forEach((beam) => beam.setContext(ctx).draw());
412
- const notes12 = score.notes('ab4/4, bb4/8, (cb5 eb5)/4[stem="down"], d5/8[stem="down"]');
413
- const notes22 = score.notes('(eb4 ab4)/4., (c4 eb4 ab4)/4, db5/8', { stem: 'up' });
414
- const notes32 = score.notes('a5/8, a5, a5, a5, a5, a5', { stem: 'down' });
415
- voices = [
416
- score.voice(notes12, { time: '6/8' }),
417
- score.voice(notes22, { time: '6/8' }),
418
- score.voice(notes32, { time: '6/8' }),
419
- ];
420
- formatter = f.Formatter();
421
- voices.forEach((v) => formatter.joinVoices([v]));
422
- width = formatter.preCalculateMinTotalWidth(voices);
423
- const staveX = staves[0].getX() + staves[0].getWidth();
424
- staveWidth = width + Stave.defaultPadding;
425
- staves = [
426
- f.Stave({ x: staveX, y: staveYs[0], width: staveWidth }),
427
- f.Stave({ x: staveX, y: staveYs[1], width: staveWidth }),
428
- f.Stave({ x: staveX, y: staveYs[2], width: staveWidth }),
429
- ];
430
- formatter.format(voices, width);
431
- beams = [
432
- new Beam(notes32.slice(0, 3), true),
433
- new Beam(notes32.slice(3, 6), true),
434
- ];
435
- for (let i = 0; i < staves.length; ++i) {
436
- staves[i].setContext(ctx).draw();
437
- voices[i].draw(ctx, staves[i]);
438
- voices[i].getTickables().forEach((note) => Note.plotMetrics(ctx, note, staveYs[i] - 20));
439
- }
440
- beams.forEach((beam) => beam.setContext(ctx).draw());
441
- ok(true);
442
- }
443
- function proportional(options) {
444
- const debug = options.params.debug;
445
- Registry.enableDefaultRegistry(new Registry());
446
- const f = VexFlowTests.makeFactory(options, 775, 750);
447
- const system = f.System({
448
- x: 50,
449
- autoWidth: true,
450
- debugFormatter: debug,
451
- noJustification: !(options.params.justify === undefined && true),
452
- formatIterations: options.params.iterations,
453
- details: { alpha: options.params.alpha },
454
- });
455
- const score = f.EasyScore();
456
- const voices = [
457
- score.notes('c5/8, c5'),
458
- score.tuplet(score.notes('a4/8, a4, a4'), { notes_occupied: 2 }),
459
- score.notes('c5/16, c5, c5, c5'),
460
- score.tuplet(score.notes('a4/16, a4, a4, a4, a4'), { notes_occupied: 4 }),
461
- score.tuplet(score.notes('a4/32, a4, a4, a4, a4, a4, a4'), { notes_occupied: 8 }),
462
- ];
463
- const createVoice = (notes) => score.voice(notes, { time: '1/4' });
464
- const createStave = (voice) => system
465
- .addStave({ voices: [voice], debugNoteMetrics: debug })
466
- .addClef('treble')
467
- .addTimeSignature('1/4');
468
- voices.map(createVoice).forEach(createStave);
469
- system.addConnector().setType(StaveConnector.type.BRACKET);
470
- f.draw();
471
- Registry.disableDefaultRegistry();
472
- ok(true);
473
- }
474
- function softMax(options) {
475
- const f = VexFlowTests.makeFactory(options, 550, 500);
476
- f.getContext().scale(0.8, 0.8);
477
- function draw(y, factor) {
478
- const score = f.EasyScore();
479
- const system = f.System({
480
- x: 100,
481
- y,
482
- details: { softmaxFactor: factor },
483
- autoWidth: true,
484
- });
485
- system
486
- .addStave({
487
- voices: [
488
- score.voice(score
489
- .notes('C#5/h, a4/q')
490
- .concat(score.beam(score.notes('Abb4/8, A4/8')))
491
- .concat(score.beam(score.notes('A4/16, A#4, A4, Ab4/32, A4'))), { time: '5/4' }),
492
- ],
493
- })
494
- .addClef('treble')
495
- .addTimeSignature('5/4');
496
- f.draw();
497
- ok(true);
498
- }
499
- draw(50, 1);
500
- draw(150, 2);
501
- draw(250, 10);
502
- draw(350, 20);
503
- draw(450, 200);
504
- }
505
- function mixTime(options) {
506
- const f = VexFlowTests.makeFactory(options, 400 + Stave.defaultPadding, 250);
507
- f.getContext().scale(0.8, 0.8);
508
- const score = f.EasyScore();
509
- const system = f.System({
510
- details: { softmaxFactor: 100 },
511
- autoWidth: true,
512
- debugFormatter: true,
513
- });
514
- system
515
- .addStave({
516
- voices: [score.voice(score.notes('C#5/q, B4').concat(score.beam(score.notes('A4/8, E4, C4, D4'))))],
517
- })
518
- .addClef('treble')
519
- .addTimeSignature('4/4');
520
- system
521
- .addStave({
522
- voices: [score.voice(score.notes('C#5/q, B4, B4').concat(score.tuplet(score.beam(score.notes('A4/8, E4, C4')))))],
523
- })
524
- .addClef('treble')
525
- .addTimeSignature('4/4');
526
- f.draw();
527
- ok(true);
528
- }
529
- function tightNotes1(options) {
530
- const f = VexFlowTests.makeFactory(options, 440, 250);
531
- f.getContext().scale(0.8, 0.8);
532
- const score = f.EasyScore();
533
- const system = f.System({
534
- autoWidth: true,
535
- debugFormatter: true,
536
- details: { maxIterations: 10 },
537
- });
538
- system
539
- .addStave({
540
- voices: [
541
- score.voice(score.beam(score.notes('B4/16, B4, B4, B4, B4, B4, B4, B4')).concat(score.notes('B4/q, B4'))),
542
- ],
543
- })
544
- .addClef('treble')
545
- .addTimeSignature('4/4');
546
- system
547
- .addStave({
548
- voices: [
549
- score.voice(score.notes('B4/q, B4').concat(score.beam(score.notes('B4/16, B4, B4, B4, B4, B4, B4, B4')))),
550
- ],
551
- })
552
- .addClef('treble')
553
- .addTimeSignature('4/4');
554
- f.draw();
555
- ok(true);
556
- }
557
- function tightNotes2(options) {
558
- const f = VexFlowTests.makeFactory(options, 440, 250);
559
- f.getContext().scale(0.8, 0.8);
560
- const score = f.EasyScore();
561
- const system = f.System({
562
- autoWidth: true,
563
- debugFormatter: true,
564
- });
565
- system
566
- .addStave({
567
- voices: [
568
- score.voice(score.beam(score.notes('B4/16, B4, B4, B4, B4, B4, B4, B4')).concat(score.notes('B4/q, B4'))),
569
- ],
570
- })
571
- .addClef('treble')
572
- .addTimeSignature('4/4');
573
- system
574
- .addStave({
575
- voices: [score.voice(score.notes('B4/w'))],
576
- })
577
- .addClef('treble')
578
- .addTimeSignature('4/4');
579
- f.draw();
580
- ok(true);
581
- }
582
- function annotations(options) {
583
- const pageWidth = 916;
584
- const pageHeight = 600;
585
- const f = VexFlowTests.makeFactory(options, pageWidth, pageHeight);
586
- const context = f.getContext();
587
- const lyrics1 = ['ipso', 'ipso-', 'ipso', 'ipso', 'ipsoz', 'ipso-', 'ipso', 'ipso', 'ipso', 'ip', 'ipso'];
588
- const lyrics2 = ['ipso', 'ipso-', 'ipsoz', 'ipso', 'ipso', 'ipso-', 'ipso', 'ipso', 'ipso', 'ip', 'ipso'];
589
- const smar = [
590
- {
591
- sm: 5,
592
- width: 550,
593
- lyrics: lyrics1,
594
- title: '550px,softMax:5',
595
- },
596
- {
597
- sm: 10,
598
- width: 550,
599
- lyrics: lyrics2,
600
- title: '550px,softmax:10,different word order',
601
- },
602
- {
603
- sm: 5,
604
- width: 550,
605
- lyrics: lyrics2,
606
- title: '550px,softmax:5',
607
- },
608
- {
609
- sm: 100,
610
- width: 550,
611
- lyrics: lyrics2,
612
- title: '550px,softmax:100',
613
- },
614
- ];
615
- const rowSize = 140;
616
- const beats = 12;
617
- const beatsPer = 8;
618
- const beamGroup = 3;
619
- const durations = ['8d', '16', '8', '8d', '16', '8', '8d', '16', '8', '4', '8'];
620
- const beams = [];
621
- let y = 40;
622
- smar.forEach((sm) => {
623
- const stave = new Stave(10, y, sm.width);
624
- const notes = [];
625
- let iii = 0;
626
- context.fillText(sm.title, 100, y);
627
- y += rowSize;
628
- durations.forEach((dd) => {
629
- const note = new StaveNote({ keys: ['b/4'], duration: dd });
630
- if (dd.indexOf('d') >= 0) {
631
- Dot.buildAndAttach([note], { all: true });
632
- }
633
- if (sm.lyrics.length > iii) {
634
- note.addModifier(new Annotation(sm.lyrics[iii])
635
- .setVerticalJustification(Annotation.VerticalJustify.BOTTOM)
636
- .setFont(Font.SERIF, 12, FontWeight.NORMAL));
637
- }
638
- notes.push(note);
639
- iii += 1;
640
- });
641
- notes.forEach((note) => {
642
- if (note.getDuration().indexOf('d') >= 0) {
643
- Dot.buildAndAttach([note], { all: true });
644
- }
645
- });
646
- let notesToBeam = [];
647
- notes.forEach((note) => {
648
- if (note.getIntrinsicTicks() < 4096) {
649
- notesToBeam.push(note);
650
- if (notesToBeam.length >= beamGroup) {
651
- beams.push(new Beam(notesToBeam));
652
- notesToBeam = [];
653
- }
654
- }
655
- else {
656
- notesToBeam = [];
657
- }
658
- });
659
- const voice1 = new Voice({ num_beats: beats, beat_value: beatsPer }).setMode(Voice.Mode.SOFT).addTickables(notes);
660
- const fmt = new Formatter({ softmaxFactor: sm.sm, maxIterations: 2 }).joinVoices([voice1]);
661
- fmt.format([voice1], sm.width - 11);
662
- stave.setContext(context).draw();
663
- voice1.draw(context, stave);
664
- beams.forEach((b) => b.setContext(context).draw());
665
- });
666
- ok(true);
667
- }
668
- VexFlowTests.register(FormatterTests);
669
- export { FormatterTests };