vexflow 4.0.1-beta.1 → 4.0.1-beta.2

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 (331) 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 +92 -24
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +38 -16
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-font-gonville.js +1 -1
  10. package/build/cjs/vexflow-font-gonville.js.map +1 -1
  11. package/build/cjs/vexflow-gonville.js +2 -2
  12. package/build/cjs/vexflow-gonville.js.map +1 -1
  13. package/build/cjs/vexflow-petaluma.js +2 -2
  14. package/build/cjs/vexflow-petaluma.js.map +1 -1
  15. package/build/cjs/vexflow.js +2 -2
  16. package/build/cjs/vexflow.js.map +1 -1
  17. package/build/esm/entry/vexflow-bravura.js +11 -0
  18. package/build/esm/entry/vexflow-core.js +54 -0
  19. package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
  20. package/build/esm/entry/vexflow-debug.js +3 -0
  21. package/build/esm/entry/vexflow-font-bravura.js +7 -0
  22. package/build/esm/entry/vexflow-font-custom.js +7 -0
  23. package/build/esm/entry/vexflow-font-gonville.js +7 -0
  24. package/build/esm/entry/vexflow-font-petaluma.js +7 -0
  25. package/build/esm/entry/vexflow-gonville.js +11 -0
  26. package/build/esm/entry/vexflow-petaluma.js +11 -0
  27. package/build/esm/entry/vexflow.js +9 -0
  28. package/build/esm/src/accidental.js +348 -0
  29. package/build/esm/src/annotation.js +232 -0
  30. package/build/esm/src/articulation.js +267 -0
  31. package/build/esm/src/barnote.js +58 -0
  32. package/build/esm/src/beam.js +632 -0
  33. package/build/esm/src/bend.js +202 -0
  34. package/build/esm/src/boundingbox.js +59 -0
  35. package/build/esm/src/boundingboxcomputation.js +107 -0
  36. package/build/esm/src/canvascontext.js +202 -0
  37. package/build/esm/src/chordsymbol.js +578 -0
  38. package/build/esm/src/clef.js +153 -0
  39. package/build/esm/src/clefnote.js +65 -0
  40. package/build/esm/src/crescendo.js +77 -0
  41. package/build/esm/src/curve.js +118 -0
  42. package/build/esm/src/dot.js +137 -0
  43. package/build/esm/src/easyscore.js +374 -0
  44. package/build/esm/src/element.js +216 -0
  45. package/build/esm/src/factory.js +440 -0
  46. package/build/esm/src/flow.js +275 -0
  47. package/build/esm/src/font.js +264 -0
  48. package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
  49. package/build/esm/src/fonts/bravura_metrics.js +507 -0
  50. package/build/esm/src/fonts/custom_glyphs.js +78 -0
  51. package/build/esm/src/fonts/custom_metrics.js +5 -0
  52. package/build/esm/src/fonts/gonville_glyphs.js +828 -0
  53. package/build/esm/src/fonts/gonville_metrics.js +421 -0
  54. package/build/esm/src/fonts/load_all.js +10 -0
  55. package/build/esm/src/fonts/load_bravura.js +6 -0
  56. package/build/esm/src/fonts/load_custom.js +6 -0
  57. package/build/esm/src/fonts/load_gonville.js +6 -0
  58. package/build/esm/src/fonts/load_petaluma.js +6 -0
  59. package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
  60. package/build/esm/src/fonts/petaluma_metrics.js +536 -0
  61. package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
  62. package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
  63. package/build/esm/src/fonts/textfonts.js +44 -0
  64. package/build/esm/src/formatter.js +568 -0
  65. package/build/esm/src/fraction.js +171 -0
  66. package/build/esm/src/frethandfinger.js +156 -0
  67. package/build/esm/src/ghostnote.js +50 -0
  68. package/build/esm/src/glyph.js +331 -0
  69. package/build/esm/src/glyphnote.js +55 -0
  70. package/build/esm/src/gracenote.js +133 -0
  71. package/build/esm/src/gracenotegroup.js +128 -0
  72. package/build/esm/src/gracetabnote.js +12 -0
  73. package/build/esm/src/index.js +91 -0
  74. package/build/esm/src/keymanager.js +99 -0
  75. package/build/esm/src/keysignature.js +250 -0
  76. package/build/esm/src/keysignote.js +28 -0
  77. package/build/esm/src/modifier.js +128 -0
  78. package/build/esm/src/modifiercontext.js +110 -0
  79. package/build/esm/src/multimeasurerest.js +173 -0
  80. package/build/esm/src/music.js +322 -0
  81. package/build/esm/src/note.js +371 -0
  82. package/build/esm/src/notehead.js +169 -0
  83. package/build/esm/src/notesubgroup.js +59 -0
  84. package/build/esm/src/ornament.js +206 -0
  85. package/build/esm/src/parenthesis.js +76 -0
  86. package/build/esm/src/parser.js +164 -0
  87. package/build/esm/src/pedalmarking.js +192 -0
  88. package/build/esm/src/registry.js +81 -0
  89. package/build/esm/src/rendercontext.js +24 -0
  90. package/build/esm/src/renderer.js +112 -0
  91. package/build/esm/src/repeatnote.js +22 -0
  92. package/build/esm/src/stave.js +547 -0
  93. package/build/esm/src/stavebarline.js +182 -0
  94. package/build/esm/src/staveconnector.js +196 -0
  95. package/build/esm/src/stavehairpin.js +120 -0
  96. package/build/esm/src/staveline.js +218 -0
  97. package/build/esm/src/stavemodifier.js +77 -0
  98. package/build/esm/src/stavenote.js +855 -0
  99. package/build/esm/src/staverepetition.js +155 -0
  100. package/build/esm/src/stavesection.js +58 -0
  101. package/build/esm/src/stavetempo.js +91 -0
  102. package/build/esm/src/stavetext.js +82 -0
  103. package/build/esm/src/stavetie.js +141 -0
  104. package/build/esm/src/stavevolta.js +67 -0
  105. package/build/esm/src/stem.js +131 -0
  106. package/build/esm/src/stemmablenote.js +193 -0
  107. package/build/esm/src/stringnumber.js +231 -0
  108. package/build/esm/src/strokes.js +200 -0
  109. package/build/esm/src/svgcontext.js +414 -0
  110. package/build/esm/src/system.js +116 -0
  111. package/build/esm/src/tables.js +1102 -0
  112. package/build/esm/src/tabnote.js +299 -0
  113. package/build/esm/src/tabslide.js +76 -0
  114. package/build/esm/src/tabstave.js +17 -0
  115. package/build/esm/src/tabtie.js +19 -0
  116. package/build/esm/src/textbracket.js +144 -0
  117. package/build/esm/src/textdynamics.js +81 -0
  118. package/build/esm/src/textformatter.js +177 -0
  119. package/build/esm/src/textnote.js +176 -0
  120. package/build/esm/src/tickable.js +214 -0
  121. package/build/esm/src/tickcontext.js +170 -0
  122. package/build/esm/src/timesigglyph.js +85 -0
  123. package/build/esm/src/timesignature.js +89 -0
  124. package/build/esm/src/timesignote.js +32 -0
  125. package/build/esm/src/tremolo.js +47 -0
  126. package/build/esm/src/tuning.js +54 -0
  127. package/build/esm/src/tuplet.js +240 -0
  128. package/build/esm/src/typeguard.js +30 -0
  129. package/build/esm/src/util.js +58 -0
  130. package/build/esm/src/version.js +3 -3
  131. package/build/esm/src/vex.js +51 -0
  132. package/build/esm/src/vibrato.js +100 -0
  133. package/build/esm/src/vibratobracket.js +50 -0
  134. package/build/esm/src/voice.js +187 -0
  135. package/build/esm/src/web.js +15 -0
  136. package/build/esm/tests/accidental_tests.js +974 -0
  137. package/build/esm/tests/annotation_tests.js +377 -0
  138. package/build/esm/tests/articulation_tests.js +365 -0
  139. package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
  140. package/build/esm/tests/bach_tests.js +335 -0
  141. package/build/esm/tests/barline_tests.js +52 -0
  142. package/build/esm/tests/beam_tests.js +595 -0
  143. package/build/esm/tests/bend_tests.js +215 -0
  144. package/build/esm/tests/boundingbox_tests.js +53 -0
  145. package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
  146. package/build/esm/tests/chordsymbol_tests.js +320 -0
  147. package/build/esm/tests/clef_tests.js +131 -0
  148. package/build/esm/tests/curve_tests.js +118 -0
  149. package/build/esm/tests/dot_tests.js +123 -0
  150. package/build/esm/tests/easyscore_tests.js +459 -0
  151. package/build/esm/tests/factory_tests.js +44 -0
  152. package/build/esm/tests/font_tests.js +135 -0
  153. package/build/esm/tests/formatter/framestack.js +61 -0
  154. package/build/esm/tests/formatter/tests.js +203 -0
  155. package/build/esm/tests/formatter_tests.js +669 -0
  156. package/build/esm/tests/fraction_tests.js +72 -0
  157. package/build/esm/tests/ghostnote_tests.js +77 -0
  158. package/build/esm/tests/glyphnote_tests.js +113 -0
  159. package/build/esm/tests/gracenote_tests.js +413 -0
  160. package/build/esm/tests/gracetabnote_tests.js +79 -0
  161. package/build/esm/tests/index.js +68 -0
  162. package/build/esm/tests/key_clef_tests.js +103 -0
  163. package/build/esm/tests/keymanager_tests.js +68 -0
  164. package/build/esm/tests/keysignature_tests.js +308 -0
  165. package/build/esm/tests/mocks.js +71 -0
  166. package/build/esm/tests/modifier_tests.js +24 -0
  167. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  168. package/build/esm/tests/music_tests.js +161 -0
  169. package/build/esm/tests/notehead_tests.js +137 -0
  170. package/build/esm/tests/notesubgroup_tests.js +149 -0
  171. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  172. package/build/esm/tests/ornament_tests.js +298 -0
  173. package/build/esm/tests/parser_tests.js +122 -0
  174. package/build/esm/tests/pedalmarking_tests.js +64 -0
  175. package/build/esm/tests/percussion_tests.js +180 -0
  176. package/build/esm/tests/registry_tests.js +64 -0
  177. package/build/esm/tests/renderer_tests.js +113 -0
  178. package/build/esm/tests/rests_tests.js +248 -0
  179. package/build/esm/tests/rhythm_tests.js +357 -0
  180. package/build/esm/tests/stave_tests.js +560 -0
  181. package/build/esm/tests/staveconnector_tests.js +402 -0
  182. package/build/esm/tests/stavehairpin_tests.js +90 -0
  183. package/build/esm/tests/staveline_tests.js +122 -0
  184. package/build/esm/tests/stavemodifier_tests.js +51 -0
  185. package/build/esm/tests/stavenote_tests.js +867 -0
  186. package/build/esm/tests/stavetie_tests.js +108 -0
  187. package/build/esm/tests/stringnumber_tests.js +259 -0
  188. package/build/esm/tests/strokes_tests.js +275 -0
  189. package/build/esm/tests/style_tests.js +98 -0
  190. package/build/esm/tests/support/qunit.js +2765 -0
  191. package/build/esm/tests/tabnote_tests.js +474 -0
  192. package/build/esm/tests/tabslide_tests.js +135 -0
  193. package/build/esm/tests/tabstave_tests.js +23 -0
  194. package/build/esm/tests/tabtie_tests.js +173 -0
  195. package/build/esm/tests/textbracket_tests.js +100 -0
  196. package/build/esm/tests/textformatter_tests.js +24 -0
  197. package/build/esm/tests/textnote_tests.js +215 -0
  198. package/build/esm/tests/threevoice_tests.js +132 -0
  199. package/build/esm/tests/tickcontext_tests.js +36 -0
  200. package/build/esm/tests/timesignature_tests.js +134 -0
  201. package/build/esm/tests/tremolo_tests.js +75 -0
  202. package/build/esm/tests/tuning_tests.js +56 -0
  203. package/build/esm/tests/tuplet_tests.js +450 -0
  204. package/build/esm/tests/typeguard_tests.js +82 -0
  205. package/build/esm/tests/vexflow_test_helpers.js +266 -0
  206. package/build/esm/tests/vf_prefix_tests.js +115 -0
  207. package/build/esm/tests/vibrato_tests.js +92 -0
  208. package/build/esm/tests/vibratobracket_tests.js +45 -0
  209. package/build/esm/tests/voice_tests.js +69 -0
  210. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  211. package/build/types/entry/vexflow-core.d.ts +3 -0
  212. package/build/types/entry/vexflow-debug.d.ts +3 -0
  213. package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
  214. package/build/types/entry/vexflow-font-custom.d.ts +86 -0
  215. package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
  216. package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
  217. package/build/types/entry/vexflow-gonville.d.ts +3 -0
  218. package/build/types/entry/vexflow-petaluma.d.ts +3 -0
  219. package/build/types/entry/vexflow.d.ts +3 -0
  220. package/build/types/src/accidental.d.ts +66 -0
  221. package/build/types/src/annotation.d.ts +60 -0
  222. package/build/types/src/articulation.d.ts +62 -0
  223. package/build/types/src/barnote.d.ts +29 -0
  224. package/build/types/src/beam.d.ts +124 -0
  225. package/build/types/src/bend.d.ts +73 -0
  226. package/build/types/src/boundingbox.d.ts +42 -0
  227. package/build/types/src/boundingboxcomputation.d.ts +33 -0
  228. package/build/types/src/canvascontext.d.ts +89 -0
  229. package/build/types/src/chordsymbol.d.ts +149 -0
  230. package/build/types/src/clef.d.ts +48 -0
  231. package/build/types/src/clefnote.d.ts +25 -0
  232. package/build/types/src/crescendo.d.ts +27 -0
  233. package/build/types/src/curve.d.ts +41 -0
  234. package/build/types/src/dot.d.ts +20 -0
  235. package/build/types/src/easyscore.d.ts +148 -0
  236. package/build/types/src/element.d.ts +202 -0
  237. package/build/types/src/factory.d.ts +271 -0
  238. package/build/types/src/flow.d.ts +245 -0
  239. package/build/types/src/font.d.ts +181 -0
  240. package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
  241. package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
  242. package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
  243. package/build/types/src/fonts/custom_metrics.d.ts +5 -0
  244. package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
  245. package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
  246. package/build/types/src/fonts/load_all.d.ts +1 -0
  247. package/build/types/src/fonts/load_bravura.d.ts +1 -0
  248. package/build/types/src/fonts/load_custom.d.ts +1 -0
  249. package/build/types/src/fonts/load_gonville.d.ts +1 -0
  250. package/build/types/src/fonts/load_petaluma.d.ts +1 -0
  251. package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
  252. package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
  253. package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
  254. package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
  255. package/build/types/src/fonts/textfonts.d.ts +1 -0
  256. package/build/types/src/formatter.d.ts +203 -0
  257. package/build/types/src/fraction.d.ts +62 -0
  258. package/build/types/src/frethandfinger.d.ts +22 -0
  259. package/build/types/src/ghostnote.d.ts +16 -0
  260. package/build/types/src/glyph.d.ts +139 -0
  261. package/build/types/src/glyphnote.d.ts +17 -0
  262. package/build/types/src/gracenote.d.ts +19 -0
  263. package/build/types/src/gracenotegroup.d.ts +33 -0
  264. package/build/types/src/gracetabnote.d.ts +5 -0
  265. package/build/types/src/index.d.ts +91 -0
  266. package/build/types/src/keymanager.d.ts +25 -0
  267. package/build/types/src/keysignature.d.ts +50 -0
  268. package/build/types/src/keysignote.d.ts +11 -0
  269. package/build/types/src/modifier.d.ts +97 -0
  270. package/build/types/src/modifiercontext.d.ts +45 -0
  271. package/build/types/src/multimeasurerest.d.ts +61 -0
  272. package/build/types/src/music.d.ts +91 -0
  273. package/build/types/src/note.d.ts +231 -0
  274. package/build/types/src/notehead.d.ts +70 -0
  275. package/build/types/src/notesubgroup.d.ts +18 -0
  276. package/build/types/src/ornament.d.ts +76 -0
  277. package/build/types/src/parenthesis.d.ts +22 -0
  278. package/build/types/src/parser.d.ts +45 -0
  279. package/build/types/src/pedalmarking.d.ts +69 -0
  280. package/build/types/src/registry.d.ts +40 -0
  281. package/build/types/src/rendercontext.d.ts +64 -0
  282. package/build/types/src/renderer.d.ts +35 -0
  283. package/build/types/src/repeatnote.d.ts +6 -0
  284. package/build/types/src/stave.d.ts +186 -0
  285. package/build/types/src/stavebarline.d.ts +28 -0
  286. package/build/types/src/staveconnector.d.ts +67 -0
  287. package/build/types/src/stavehairpin.d.ts +56 -0
  288. package/build/types/src/staveline.d.ts +57 -0
  289. package/build/types/src/stavemodifier.d.ts +44 -0
  290. package/build/types/src/stavenote.d.ts +154 -0
  291. package/build/types/src/staverepetition.d.ts +32 -0
  292. package/build/types/src/stavesection.d.ts +15 -0
  293. package/build/types/src/stavetempo.d.ts +25 -0
  294. package/build/types/src/stavetext.d.ts +25 -0
  295. package/build/types/src/stavetie.d.ts +59 -0
  296. package/build/types/src/stavevolta.d.ts +21 -0
  297. package/build/types/src/stem.d.ts +58 -0
  298. package/build/types/src/stemmablenote.d.ts +39 -0
  299. package/build/types/src/stringnumber.d.ts +27 -0
  300. package/build/types/src/strokes.d.ts +33 -0
  301. package/build/types/src/svgcontext.d.ts +131 -0
  302. package/build/types/src/system.d.ts +92 -0
  303. package/build/types/src/tables.d.ts +96 -0
  304. package/build/types/src/tabnote.d.ts +44 -0
  305. package/build/types/src/tabslide.d.ts +34 -0
  306. package/build/types/src/tabstave.d.ts +7 -0
  307. package/build/types/src/tabtie.d.ts +18 -0
  308. package/build/types/src/textbracket.d.ts +55 -0
  309. package/build/types/src/textdynamics.d.ts +39 -0
  310. package/build/types/src/textformatter.d.ts +109 -0
  311. package/build/types/src/textnote.d.ts +49 -0
  312. package/build/types/src/tickable.d.ts +140 -0
  313. package/build/types/src/tickcontext.d.ts +82 -0
  314. package/build/types/src/timesigglyph.d.ts +14 -0
  315. package/build/types/src/timesignature.d.ts +26 -0
  316. package/build/types/src/timesignote.d.ts +11 -0
  317. package/build/types/src/tremolo.d.ts +17 -0
  318. package/build/types/src/tuning.d.ts +23 -0
  319. package/build/types/src/tuplet.d.ts +105 -0
  320. package/build/types/src/typeguard.d.ts +99 -0
  321. package/build/types/src/util.d.ts +27 -0
  322. package/build/types/src/version.d.ts +3 -0
  323. package/build/types/src/vex.d.ts +18 -0
  324. package/build/types/src/vibrato.d.ts +29 -0
  325. package/build/types/src/vibratobracket.d.ts +33 -0
  326. package/build/types/src/voice.d.ts +108 -0
  327. package/build/types/src/web.d.ts +2 -0
  328. package/package.json +1 -1
  329. package/src/annotation.ts +27 -6
  330. package/src/articulation.ts +8 -2
  331. package/src/fonts/gonville_glyphs.ts +4 -4
@@ -0,0 +1,173 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { Annotation } from '../src/annotation.js';
3
+ import { Flow } from '../src/flow.js';
4
+ import { Formatter } from '../src/formatter.js';
5
+ import { TabNote } from '../src/tabnote.js';
6
+ import { TabStave } from '../src/tabstave.js';
7
+ import { TabTie } from '../src/tabtie.js';
8
+ import { Voice } from '../src/voice.js';
9
+ const TabTieTests = {
10
+ Start() {
11
+ QUnit.module('TabTie');
12
+ const run = VexFlowTests.runTests;
13
+ run('Simple TabTie', simple);
14
+ run('Hammerons', simpleHammerOn);
15
+ run('Pulloffs', simplePullOff);
16
+ run('Tapping', tap);
17
+ run('Continuous', continuous);
18
+ },
19
+ };
20
+ const tabNote = (noteStruct) => new TabNote(noteStruct);
21
+ function setupContext(options, w = 0, h = 0) {
22
+ const context = options.contextBuilder(options.elementId, w || 350, h || 160);
23
+ context.fillStyle = '#221';
24
+ context.strokeStyle = '#221';
25
+ context.setFont('Arial', VexFlowTests.Font.size);
26
+ const stave = new TabStave(10, 10, w || 350).addTabGlyph().setContext(context).draw();
27
+ return { context, stave };
28
+ }
29
+ function tieNotes(notes, indices, stave, ctx, text) {
30
+ const voice = new Voice(Flow.TIME4_4);
31
+ voice.addTickables(notes);
32
+ new Formatter().joinVoices([voice]).format([voice], 100);
33
+ voice.draw(ctx, stave);
34
+ const tie = new TabTie({
35
+ first_note: notes[0],
36
+ last_note: notes[1],
37
+ first_indices: indices,
38
+ last_indices: indices,
39
+ }, text !== null && text !== void 0 ? text : 'Annotation');
40
+ tie.setContext(ctx);
41
+ tie.draw();
42
+ }
43
+ function simple(options, contextBuilder) {
44
+ options.contextBuilder = contextBuilder;
45
+ const { context, stave } = setupContext(options);
46
+ const note1 = tabNote({ positions: [{ str: 4, fret: 4 }], duration: 'h' });
47
+ const note2 = tabNote({ positions: [{ str: 4, fret: 6 }], duration: 'h' });
48
+ tieNotes([note1, note2], [0], stave, context);
49
+ ok(true, 'Simple Test');
50
+ }
51
+ function simpleHammerOn(options, contextBuilder) {
52
+ options.contextBuilder = contextBuilder;
53
+ multiTest(options, TabTie.createHammeron);
54
+ }
55
+ function simplePullOff(options, contextBuilder) {
56
+ options.contextBuilder = contextBuilder;
57
+ multiTest(options, TabTie.createPulloff);
58
+ }
59
+ function multiTest(options, createTabTie) {
60
+ const { context, stave } = setupContext(options, 440, 140);
61
+ const notes = [
62
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: '8' }),
63
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: '8' }),
64
+ tabNote({
65
+ positions: [
66
+ { str: 4, fret: 4 },
67
+ { str: 5, fret: 4 },
68
+ ],
69
+ duration: '8',
70
+ }),
71
+ tabNote({
72
+ positions: [
73
+ { str: 4, fret: 6 },
74
+ { str: 5, fret: 6 },
75
+ ],
76
+ duration: '8',
77
+ }),
78
+ tabNote({ positions: [{ str: 2, fret: 14 }], duration: '8' }),
79
+ tabNote({ positions: [{ str: 2, fret: 16 }], duration: '8' }),
80
+ tabNote({
81
+ positions: [
82
+ { str: 2, fret: 14 },
83
+ { str: 3, fret: 14 },
84
+ ],
85
+ duration: '8',
86
+ }),
87
+ tabNote({
88
+ positions: [
89
+ { str: 2, fret: 16 },
90
+ { str: 3, fret: 16 },
91
+ ],
92
+ duration: '8',
93
+ }),
94
+ ];
95
+ const voice = new Voice(Flow.TIME4_4).addTickables(notes);
96
+ new Formatter().joinVoices([voice]).format([voice], 300);
97
+ voice.draw(context, stave);
98
+ createTabTie({
99
+ first_note: notes[0],
100
+ last_note: notes[1],
101
+ first_indices: [0],
102
+ last_indices: [0],
103
+ })
104
+ .setContext(context)
105
+ .draw();
106
+ ok(true, 'Single note');
107
+ createTabTie({
108
+ first_note: notes[2],
109
+ last_note: notes[3],
110
+ first_indices: [0, 1],
111
+ last_indices: [0, 1],
112
+ })
113
+ .setContext(context)
114
+ .draw();
115
+ ok(true, 'Chord');
116
+ createTabTie({
117
+ first_note: notes[4],
118
+ last_note: notes[5],
119
+ first_indices: [0],
120
+ last_indices: [0],
121
+ })
122
+ .setContext(context)
123
+ .draw();
124
+ ok(true, 'Single note high-fret');
125
+ createTabTie({
126
+ first_note: notes[6],
127
+ last_note: notes[7],
128
+ first_indices: [0, 1],
129
+ last_indices: [0, 1],
130
+ })
131
+ .setContext(context)
132
+ .draw();
133
+ ok(true, 'Chord high-fret');
134
+ }
135
+ function tap(options, contextBuilder) {
136
+ options.contextBuilder = contextBuilder;
137
+ const { context, stave } = setupContext(options);
138
+ const note1 = tabNote({ positions: [{ str: 4, fret: 12 }], duration: 'h' }).addModifier(new Annotation('T'), 0);
139
+ const note2 = tabNote({ positions: [{ str: 4, fret: 10 }], duration: 'h' });
140
+ tieNotes([note1, note2], [0], stave, context, 'P');
141
+ ok(true, 'Tapping Test');
142
+ }
143
+ function continuous(options, contextBuilder) {
144
+ options.contextBuilder = contextBuilder;
145
+ const { context, stave } = setupContext(options, 440, 140);
146
+ const notes = [
147
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: 'q' }),
148
+ tabNote({ positions: [{ str: 4, fret: 5 }], duration: 'q' }),
149
+ tabNote({ positions: [{ str: 4, fret: 6 }], duration: 'h' }),
150
+ ];
151
+ const voice = new Voice(Flow.TIME4_4).addTickables(notes);
152
+ new Formatter().joinVoices([voice]).format([voice], 300);
153
+ voice.draw(context, stave);
154
+ TabTie.createHammeron({
155
+ first_note: notes[0],
156
+ last_note: notes[1],
157
+ first_indices: [0],
158
+ last_indices: [0],
159
+ })
160
+ .setContext(context)
161
+ .draw();
162
+ TabTie.createPulloff({
163
+ first_note: notes[1],
164
+ last_note: notes[2],
165
+ first_indices: [0],
166
+ last_indices: [0],
167
+ })
168
+ .setContext(context)
169
+ .draw();
170
+ ok(true, 'Continuous Hammeron');
171
+ }
172
+ VexFlowTests.register(TabTieTests);
173
+ export { TabTieTests };
@@ -0,0 +1,100 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ const TextBracketTests = {
3
+ Start() {
4
+ QUnit.module('TextBracket');
5
+ const run = VexFlowTests.runTests;
6
+ run('Simple TextBracket', simple0);
7
+ run('TextBracket Styles', simple1);
8
+ },
9
+ };
10
+ function simple0(options) {
11
+ const f = VexFlowTests.makeFactory(options, 550);
12
+ const stave = f.Stave();
13
+ const score = f.EasyScore();
14
+ const notes = score.notes('c4/4, c4, c4, c4, c4', { stem: 'up' });
15
+ const voice = score.voice(notes, { time: '5/4' });
16
+ f.TextBracket({
17
+ from: notes[0],
18
+ to: notes[4],
19
+ text: '15',
20
+ options: {
21
+ superscript: 'va',
22
+ position: 'top',
23
+ },
24
+ });
25
+ f.TextBracket({
26
+ from: notes[0],
27
+ to: notes[4],
28
+ text: '8',
29
+ options: {
30
+ superscript: 'vb',
31
+ position: 'bottom',
32
+ line: 3,
33
+ },
34
+ });
35
+ f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
36
+ f.draw();
37
+ ok(true);
38
+ }
39
+ function simple1(options) {
40
+ const f = VexFlowTests.makeFactory(options, 550);
41
+ const stave = f.Stave();
42
+ const score = f.EasyScore();
43
+ const notes = score.notes('c4/4, c4, c4, c4, c4', { stem: 'up' });
44
+ const voice = score.voice(notes, { time: '5/4' });
45
+ const topOctaves = [
46
+ f.TextBracket({
47
+ from: notes[0],
48
+ to: notes[1],
49
+ text: 'Cool notes',
50
+ options: {
51
+ superscript: '',
52
+ position: 'top',
53
+ },
54
+ }),
55
+ f.TextBracket({
56
+ from: notes[2],
57
+ to: notes[4],
58
+ text: 'Testing',
59
+ options: {
60
+ position: 'top',
61
+ superscript: 'superscript',
62
+ font: { family: 'Arial', size: 15, weight: 'normal', style: 'normal' },
63
+ },
64
+ }),
65
+ ];
66
+ const bottomOctaves = [
67
+ f.TextBracket({
68
+ from: notes[0],
69
+ to: notes[1],
70
+ text: '8',
71
+ options: {
72
+ superscript: 'vb',
73
+ position: 'bottom',
74
+ line: 3,
75
+ font: { size: 30 },
76
+ },
77
+ }),
78
+ f.TextBracket({
79
+ from: notes[2],
80
+ to: notes[4],
81
+ text: 'Not cool notes',
82
+ options: {
83
+ superscript: ' super uncool',
84
+ position: 'bottom',
85
+ line: 4,
86
+ },
87
+ }),
88
+ ];
89
+ topOctaves[1].render_options.line_width = 2;
90
+ topOctaves[1].render_options.show_bracket = false;
91
+ bottomOctaves[0].render_options.underline_superscript = false;
92
+ bottomOctaves[0].setDashed(false);
93
+ bottomOctaves[1].render_options.bracket_height = 40;
94
+ bottomOctaves[1].setDashed(true, [2, 2]);
95
+ f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
96
+ f.draw();
97
+ ok(true);
98
+ }
99
+ VexFlowTests.register(TextBracketTests);
100
+ export { TextBracketTests };
@@ -0,0 +1,24 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { TextFormatter } from '../src/textformatter.js';
3
+ const TextFormatterTests = {
4
+ Start() {
5
+ QUnit.module('TextFormatter');
6
+ test('Basic', basic);
7
+ },
8
+ };
9
+ function basic() {
10
+ var _a;
11
+ const registeredFamilies = TextFormatter.getFontFamilies();
12
+ equal(registeredFamilies.length, 2, `There are two registered font families: 'Roboto Slab' & 'PetalumaScript'`);
13
+ const petalumaFormatterInfo = TextFormatter.getInfo('PetalumaScript');
14
+ equal((_a = petalumaFormatterInfo === null || petalumaFormatterInfo === void 0 ? void 0 : petalumaFormatterInfo.glyphs) === null || _a === void 0 ? void 0 : _a.C.advanceWidth, 623, 'PetalumaScript advanceWidth of C character is 623.');
15
+ const formatterForPetalumaScript = TextFormatter.create({ family: 'PetalumaScript', size: '100px' });
16
+ const metricsPetalumaScriptH = formatterForPetalumaScript.getGlyphMetrics('H');
17
+ equal(metricsPetalumaScriptH.leftSideBearing, 37);
18
+ const formatterForRobotoSlab = TextFormatter.create({ family: 'Roboto Slab', size: '100px', style: 'italic' });
19
+ const metricsRobotoSlabH = formatterForRobotoSlab.getGlyphMetrics('H');
20
+ equal(metricsRobotoSlabH.advanceWidth, 1578);
21
+ equal(formatterForRobotoSlab.cacheKey, 'Roboto_Slab%75%normal%normal');
22
+ }
23
+ VexFlowTests.register(TextFormatterTests);
24
+ export { TextFormatterTests };
@@ -0,0 +1,215 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { Crescendo } from '../src/crescendo.js';
3
+ import { Flow } from '../src/flow.js';
4
+ import { Font } from '../src/font.js';
5
+ import { Note } from '../src/note.js';
6
+ import { Stave } from '../src/stave.js';
7
+ import { TextNote } from '../src/textnote.js';
8
+ const TextNoteTests = {
9
+ Start() {
10
+ QUnit.module('TextNote');
11
+ const run = VexFlowTests.runTests;
12
+ run('TextNote Formatting', formatTextNotes);
13
+ run('TextNote Formatting 2', formatTextNotes2);
14
+ run('TextNote Superscript and Subscript', superscriptAndSubscript);
15
+ run('TextNote Formatting With Glyphs 0', formatTextGlyphs0);
16
+ run('TextNote Formatting With Glyphs 1', formatTextGlyphs1);
17
+ run('Crescendo', crescendo);
18
+ run('Text Dynamics', textDynamics);
19
+ },
20
+ };
21
+ function formatTextNotes(options) {
22
+ const f = VexFlowTests.makeFactory(options, 400, 200);
23
+ const stave = f.Stave({ y: 40 });
24
+ const score = f.EasyScore();
25
+ const voice1 = score.voice([
26
+ f
27
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stem_direction: -1, duration: 'h' })
28
+ .addModifier(f.Accidental({ type: 'b' }), 0)
29
+ .addModifier(f.Accidental({ type: '#' }), 1),
30
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stem_direction: -1, duration: 'q' }),
31
+ f
32
+ .StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: 'q' })
33
+ .addModifier(f.Accidental({ type: 'n' }), 0)
34
+ .addModifier(f.Accidental({ type: '#' }), 1),
35
+ ]);
36
+ const voice2 = score.voice([
37
+ f.TextNote({ text: 'Center Justification', duration: 'h' }).setJustification(TextNote.Justification.CENTER),
38
+ f.TextNote({ text: 'Left Line 1', duration: 'q' }).setLine(1),
39
+ f.TextNote({ text: 'Right', duration: 'q' }).setJustification(TextNote.Justification.RIGHT),
40
+ ]);
41
+ const formatter = f.Formatter();
42
+ formatter.joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
43
+ f.draw();
44
+ ok(true);
45
+ }
46
+ function formatTextNotes2(options) {
47
+ const f = VexFlowTests.makeFactory(options, 600, 200);
48
+ const stave = f.Stave({ y: 40 });
49
+ const score = f.EasyScore();
50
+ const voice1 = score.voice([
51
+ f.StaveNote({ keys: ['g/4'], stem_direction: 1, duration: '16' }),
52
+ f.StaveNote({ keys: ['g/4'], stem_direction: 1, duration: '16' }),
53
+ f.StaveNote({ keys: ['g/4'], stem_direction: 1, duration: '16' }),
54
+ f.StaveNote({ keys: ['g/5'], stem_direction: -1, duration: '16' }),
55
+ f.StaveNote({ keys: ['g/5'], stem_direction: -1, duration: '16' }),
56
+ f.StaveNote({ keys: ['g/5'], stem_direction: -1, duration: '16' }),
57
+ f.StaveNote({ keys: ['g/5', 'a/5'], stem_direction: -1, duration: '16' }),
58
+ f.StaveNote({ keys: ['g/5', 'a/5'], stem_direction: -1, duration: '16' }),
59
+ f.StaveNote({ keys: ['g/5', 'a/5'], stem_direction: -1, duration: '16' }),
60
+ f.StaveNote({ keys: ['g/4', 'a/4'], stem_direction: 1, duration: '16' }),
61
+ f.StaveNote({ keys: ['g/4', 'a/4'], stem_direction: 1, duration: '16' }),
62
+ f.StaveNote({ keys: ['g/4', 'a/4'], stem_direction: 1, duration: '16' }),
63
+ f.StaveNote({ keys: ['g/4', 'a/4'], stem_direction: 1, duration: 'q' }),
64
+ ]);
65
+ const voice2 = score.voice([
66
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
67
+ f.TextNote({ text: 'L', duration: '16' }),
68
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
69
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
70
+ f.TextNote({ text: 'L', duration: '16' }),
71
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
72
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
73
+ f.TextNote({ text: 'L', duration: '16' }),
74
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
75
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
76
+ f.TextNote({ text: 'L', duration: '16' }),
77
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
78
+ f.TextNote({ text: 'R', duration: 'q' }).setJustification(TextNote.Justification.RIGHT),
79
+ ]);
80
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
81
+ voice2.getTickables().forEach((note) => Note.plotMetrics(f.getContext(), note, 170));
82
+ f.draw();
83
+ ok(true);
84
+ }
85
+ function superscriptAndSubscript(options) {
86
+ const f = VexFlowTests.makeFactory(options, 600, 230);
87
+ const stave = f.Stave({ y: 40 });
88
+ const score = f.EasyScore();
89
+ const voice1 = score.voice([
90
+ f
91
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stem_direction: 1, duration: 'h' })
92
+ .addModifier(f.Accidental({ type: 'b' }), 0)
93
+ .addModifier(f.Accidental({ type: '#' }), 1),
94
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stem_direction: 1, duration: 'q' }),
95
+ f
96
+ .StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: 1, duration: 'q' })
97
+ .addModifier(f.Accidental({ type: 'n' }), 0)
98
+ .addModifier(f.Accidental({ type: '#' }), 1),
99
+ ]);
100
+ const voice2 = score.voice([
101
+ f.TextNote({ text: Flow.unicode.flat + 'I', superscript: '+5', duration: '8' }),
102
+ f.TextNote({ text: 'D' + Flow.unicode.sharp + '/F', duration: '4d', superscript: 'sus2' }),
103
+ f.TextNote({ text: 'ii', superscript: '6', subscript: '4', duration: '8' }),
104
+ f.TextNote({ text: 'C', superscript: Flow.unicode.triangle + '7', subscript: '', duration: '8' }),
105
+ f.TextNote({ text: 'vii', superscript: Flow.unicode['o-with-slash'] + '7', duration: '8' }),
106
+ f.TextNote({ text: 'V', superscript: '7', duration: '8' }),
107
+ ]);
108
+ voice2.getTickables().forEach((note) => {
109
+ const textNote = note;
110
+ textNote.setFont({ family: Font.SERIF, size: 15 });
111
+ textNote.setLine(13);
112
+ textNote.setJustification(TextNote.Justification.LEFT);
113
+ });
114
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
115
+ f.draw();
116
+ ok(true);
117
+ }
118
+ function formatTextGlyphs0(options) {
119
+ const f = VexFlowTests.makeFactory(options, 600, 230);
120
+ const stave = f.Stave({ y: 40 });
121
+ const score = f.EasyScore();
122
+ const voice1 = score.voice([
123
+ f
124
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stem_direction: -1, duration: 'h' })
125
+ .addModifier(f.Accidental({ type: 'b' }), 0)
126
+ .addModifier(f.Accidental({ type: '#' }), 1),
127
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stem_direction: -1, duration: '8' }),
128
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
129
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
130
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
131
+ ]);
132
+ const voice2 = score.voice([
133
+ f.TextNote({ text: 'Center', duration: '8' }).setJustification(TextNote.Justification.CENTER),
134
+ f.TextNote({ glyph: 'f', duration: '8' }),
135
+ f.TextNote({ glyph: 'p', duration: '8' }),
136
+ f.TextNote({ glyph: 'm', duration: '8' }),
137
+ f.TextNote({ glyph: 'z', duration: '8' }),
138
+ f.TextNote({ glyph: 'mordent_upper', duration: '16' }),
139
+ f.TextNote({ glyph: 'mordent_lower', duration: '16' }),
140
+ f.TextNote({ glyph: 'segno', duration: '8' }),
141
+ f.TextNote({ glyph: 'coda', duration: '8' }),
142
+ ]);
143
+ voice2.getTickables().forEach((n) => n.setJustification(TextNote.Justification.CENTER));
144
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
145
+ f.draw();
146
+ ok(true);
147
+ }
148
+ function formatTextGlyphs1(options) {
149
+ const f = VexFlowTests.makeFactory(options, 600, 230);
150
+ const stave = f.Stave({ y: 40 });
151
+ const score = f.EasyScore();
152
+ const voice1 = score.voice([
153
+ f
154
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stem_direction: -1, duration: 'h' })
155
+ .addModifier(f.Accidental({ type: 'b' }), 0)
156
+ .addModifier(f.Accidental({ type: '#' }), 1),
157
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stem_direction: -1, duration: '8' }),
158
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
159
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
160
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: '8' }),
161
+ ]);
162
+ const voice2 = score.voice([
163
+ f.TextNote({ glyph: 'turn', duration: '16' }),
164
+ f.TextNote({ glyph: 'turn_inverted', duration: '16' }),
165
+ f.TextNote({ glyph: 'pedal_open', duration: '8' }).setLine(10),
166
+ f.TextNote({ glyph: 'pedal_close', duration: '8' }).setLine(10),
167
+ f.TextNote({ glyph: 'caesura_curved', duration: '8' }).setLine(3),
168
+ f.TextNote({ glyph: 'caesura_straight', duration: '8' }).setLine(3),
169
+ f.TextNote({ glyph: 'breath', duration: '8' }).setLine(2),
170
+ f.TextNote({ glyph: 'tick', duration: '8' }).setLine(3),
171
+ f.TextNote({ glyph: 'tr', duration: '8', smooth: true }).setJustification(TextNote.Justification.CENTER),
172
+ ]);
173
+ voice2.getTickables().forEach((n) => n.setJustification(TextNote.Justification.CENTER));
174
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
175
+ f.draw();
176
+ ok(true);
177
+ }
178
+ function crescendo(options) {
179
+ const f = VexFlowTests.makeFactory(options, 600, 230);
180
+ const stave = f.Stave({ y: 40 });
181
+ const score = f.EasyScore();
182
+ const voice = score.voice([
183
+ f.TextNote({ glyph: 'p', duration: '16' }),
184
+ new Crescendo({ duration: '4d' }).setLine(0).setHeight(25).setStave(stave),
185
+ f.TextNote({ glyph: 'f', duration: '16' }),
186
+ new Crescendo({ duration: '4' }).setLine(5).setStave(stave),
187
+ new Crescendo({ duration: '4' }).setLine(10).setDecrescendo(true).setHeight(5).setStave(stave),
188
+ ]);
189
+ f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
190
+ f.draw();
191
+ ok(true);
192
+ }
193
+ function textDynamics(options) {
194
+ const f = VexFlowTests.makeFactory(options, 600, 230);
195
+ const score = f.EasyScore();
196
+ const voice = score.voice([
197
+ f.TextDynamics({ text: 'sfz', duration: '4' }),
198
+ f.TextDynamics({ text: 'rfz', duration: '4' }),
199
+ f.TextDynamics({ text: 'mp', duration: '4' }),
200
+ f.TextDynamics({ text: 'ppp', duration: '4' }),
201
+ f.TextDynamics({ text: 'fff', duration: '4' }),
202
+ f.TextDynamics({ text: 'mf', duration: '4' }),
203
+ f.TextDynamics({ text: 'sff', duration: '4' }),
204
+ ], { time: '7/4' });
205
+ const formatter = f.Formatter();
206
+ formatter.joinVoices([voice]);
207
+ const width = formatter.preCalculateMinTotalWidth([voice]);
208
+ formatter.format([voice]);
209
+ const stave = f.Stave({ y: 40, width: width + Stave.defaultPadding });
210
+ stave.draw();
211
+ voice.draw(f.getContext(), stave);
212
+ ok(true);
213
+ }
214
+ VexFlowTests.register(TextNoteTests);
215
+ export { TextNoteTests };
@@ -0,0 +1,132 @@
1
+ import { concat, VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { Beam } from '../src/beam.js';
3
+ const ThreeVoicesTests = {
4
+ Start() {
5
+ QUnit.module('Three Voice Rests');
6
+ const run = VexFlowTests.runTests;
7
+ run('Three Voices - #1', threeVoices1);
8
+ run('Three Voices - #2 Complex', threeVoices2);
9
+ run('Three Voices - #3', threeVoices3);
10
+ run('Auto Adjust Rest Positions - Two Voices', autoRestTwoVoices);
11
+ run('Auto Adjust Rest Positions - Three Voices #1', autoRestThreeVoices1);
12
+ run('Auto Adjust Rest Positions - Three Voices #2', autoRestThreeVoices2);
13
+ },
14
+ };
15
+ function createThreeVoicesTest(noteGroup1, noteGroup2, noteGroup3, setup) {
16
+ return (options) => {
17
+ const factory = VexFlowTests.makeFactory(options, 600, 200);
18
+ const stave = factory.Stave().addClef('treble').addTimeSignature('4/4');
19
+ const score = factory.EasyScore();
20
+ const noteGroups = [noteGroup1, noteGroup2, noteGroup3].map((args) => score.notes(...args));
21
+ const voices = noteGroups.map((notes) => score.voice(notes));
22
+ setup(factory, voices);
23
+ const beams = [
24
+ Beam.applyAndGetBeams(voices[0], +1),
25
+ Beam.applyAndGetBeams(voices[1], -1),
26
+ Beam.applyAndGetBeams(voices[2], -1),
27
+ ].reduce(concat);
28
+ factory.Formatter().joinVoices(voices).formatToStave(voices, stave);
29
+ factory.draw();
30
+ for (let i = 0; i < beams.length; i++) {
31
+ beams[i].setContext(factory.getContext()).draw();
32
+ }
33
+ ok(true);
34
+ };
35
+ }
36
+ const threeVoices1 = createThreeVoicesTest(['e5/2, e5', { stem: 'up' }], ['(d4 a4 d#5)/8, b4, (d4 a4 c5), b4, (d4 a4 c5), b4, (d4 a4 c5), b4', { stem: 'down' }], ['b3/4, e3, f3, a3', { stem: 'down' }], (f, voices) => {
37
+ voices[0].getTickables()[0].addModifier(f.Fingering({ number: '0', position: 'left' }), 0);
38
+ voices[1]
39
+ .getTickables()[0]
40
+ .addModifier(f.Fingering({ number: '0', position: 'left' }), 0)
41
+ .addModifier(f.Fingering({ number: '4', position: 'left' }), 1);
42
+ });
43
+ const threeVoices2 = createThreeVoicesTest(['(a4 e5)/16, e5, e5, e5, e5/8, e5, e5/2', { stem: 'up' }], ['(d4 d#5)/16, (b4 c5), d5, e5, (d4 a4 c5)/8, b4, (d4 a4 c5), b4, (d4 a4 c5), b4', { stem: 'down' }], ['b3/8, b3, e3/4, f3, a3', { stem: 'down' }], (f, voices) => {
44
+ voices[0]
45
+ .getTickables()[0]
46
+ .addModifier(f.Fingering({ number: '2', position: 'left' }), 0)
47
+ .addModifier(f.Fingering({ number: '0', position: 'above' }), 1);
48
+ voices[1]
49
+ .getTickables()[0]
50
+ .addModifier(f.Fingering({ number: '0', position: 'left' }), 0)
51
+ .addModifier(f.Fingering({ number: '4', position: 'left' }), 1);
52
+ });
53
+ const threeVoices3 = createThreeVoicesTest(['(g4 e5)/4, e5, (g4 e5)/2', { stem: 'up' }], ['c#5/4, b4/8, b4/8/r, a4/4., g4/8', { stem: 'down' }], ['c4/4, b3, a3, g3', { stem: 'down' }], (f, voices) => {
54
+ voices[0]
55
+ .getTickables()[0]
56
+ .addModifier(f.Fingering({ number: '0', position: 'left' }), 0)
57
+ .addModifier(f.Fingering({ number: '0', position: 'left' }), 1);
58
+ voices[1].getTickables()[0].addModifier(f.Fingering({ number: '1', position: 'left' }), 0);
59
+ voices[2].getTickables()[0].addModifier(f.Fingering({ number: '3', position: 'left' }), 0);
60
+ });
61
+ function autoRestTwoVoices(options) {
62
+ const f = VexFlowTests.makeFactory(options, 900, 200);
63
+ const score = f.EasyScore();
64
+ let x = 10;
65
+ let beams = [];
66
+ function createMeasure(measureTitle, width, align_rests) {
67
+ const stave = f.Stave({ x: x, y: 50, width: width }).setBegBarType(1);
68
+ x += width;
69
+ const noteArrays = [
70
+ score.notes('b4/8/r, e5/16, b4/r, b4/8/r, e5/16, b4/r, b4/8/r, d5/16, b4/r, e5/4', { stem: 'up' }),
71
+ score.notes('c5/16, c4, b4/r, d4, e4, f4, b4/r, g4, g4[stem="up"], a4[stem="up"], b4/r, b4[stem="up"], e4/4', {
72
+ stem: 'down',
73
+ }),
74
+ [f.TextNote({ text: measureTitle, line: -1, duration: '1', smooth: true })],
75
+ ];
76
+ const voices = noteArrays.map((notes) => score.voice(notes));
77
+ beams = beams.concat(Beam.applyAndGetBeams(voices[0], 1)).concat(Beam.applyAndGetBeams(voices[1], -1));
78
+ f.Formatter().joinVoices(voices).formatToStave(voices, stave, { align_rests });
79
+ }
80
+ createMeasure('Default Rest Positions', 400, false);
81
+ createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
82
+ f.draw();
83
+ for (let i = 0; i < beams.length; i++) {
84
+ beams[i].setContext(f.getContext()).draw();
85
+ }
86
+ ok(true, 'Auto Adjust Rests - Two Voices');
87
+ }
88
+ function autoRestThreeVoices1(options) {
89
+ const f = VexFlowTests.makeFactory(options, 850, 200);
90
+ const score = f.EasyScore();
91
+ let x = 10;
92
+ function createMeasure(measureTitle, width, align_rests) {
93
+ const stave = f.Stave({ x: x, y: 50, width: width }).setBegBarType(1);
94
+ const voices = [
95
+ score.voice(score.notes('b4/4/r, e5, e5/r, e5/r, e5, e5, e5, e5/r', { stem: 'up' }), { time: '8/4' }),
96
+ score.voice(score.notes('b4/4/r, b4/r, b4/r, b4, b4/r, b4/r, b4, b4', { stem: 'down' }), { time: '8/4' }),
97
+ score.voice(score.notes('e4/4/r, e4/r, f4, b4/r, g4, c4, e4/r, c4', { stem: 'down' }), { time: '8/4' }),
98
+ score.voice([
99
+ f.TextNote({ text: measureTitle, duration: '1', line: -1, smooth: true }),
100
+ f.TextNote({ text: '', duration: '1', line: -1, smooth: true }),
101
+ ], { time: '8/4' }),
102
+ ];
103
+ f.Formatter().joinVoices(voices).formatToStave(voices, stave, { align_rests });
104
+ x += width;
105
+ }
106
+ createMeasure('Default Rest Positions', 400, false);
107
+ createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
108
+ f.draw();
109
+ ok(true);
110
+ }
111
+ function autoRestThreeVoices2(options) {
112
+ const f = VexFlowTests.makeFactory(options, 850, 200);
113
+ const score = f.EasyScore();
114
+ let x = 10;
115
+ function createMeasure(measureTitle, width, align_rests) {
116
+ const stave = f.Stave({ x: x, y: 50, width: width }).setBegBarType(1);
117
+ const voices = [
118
+ score.voice(score.notes('b4/16/r, e5, e5/r, e5/r, e5, e5, e5, e5/r'), { time: '2/4' }),
119
+ score.voice(score.notes('b4/16/r, b4/r, b4/r, b4, b4/r, b4/r, b4, b4'), { time: '2/4' }),
120
+ score.voice(score.notes('e4/16/r, e4/r, f4, b4/r, g4, c4, e4/r, c4'), { time: '2/4' }),
121
+ score.voice([f.TextNote({ text: measureTitle, duration: 'h', line: -1, smooth: true })], { time: '2/4' }),
122
+ ];
123
+ f.Formatter().joinVoices(voices).formatToStave(voices, stave, { align_rests });
124
+ x += width;
125
+ }
126
+ createMeasure('Default Rest Positions', 400, false);
127
+ createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
128
+ f.draw();
129
+ ok(true);
130
+ }
131
+ VexFlowTests.register(ThreeVoicesTests);
132
+ export { ThreeVoicesTests };