@mcqj/vexflow 0.0.1-alpha.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 (300) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +208 -0
  3. package/build/cjs/vexflow-bravura.js +2 -0
  4. package/build/cjs/vexflow-bravura.js.map +1 -0
  5. package/build/cjs/vexflow-core.js +2 -0
  6. package/build/cjs/vexflow-core.js.map +1 -0
  7. package/build/cjs/vexflow-debug-with-tests.js +43475 -0
  8. package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
  9. package/build/cjs/vexflow-debug.js +19194 -0
  10. package/build/cjs/vexflow-debug.js.map +1 -0
  11. package/build/cjs/vexflow.js +2 -0
  12. package/build/cjs/vexflow.js.map +1 -0
  13. package/build/esm/entry/vexflow-bravura.js +17 -0
  14. package/build/esm/entry/vexflow-core.js +4 -0
  15. package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
  16. package/build/esm/entry/vexflow-debug.js +31 -0
  17. package/build/esm/entry/vexflow.js +31 -0
  18. package/build/esm/package.json +3 -0
  19. package/build/esm/src/accidental.js +330 -0
  20. package/build/esm/src/annotation.js +231 -0
  21. package/build/esm/src/articulation.js +281 -0
  22. package/build/esm/src/barnote.js +56 -0
  23. package/build/esm/src/beam.js +644 -0
  24. package/build/esm/src/bend.js +186 -0
  25. package/build/esm/src/boundingbox.js +59 -0
  26. package/build/esm/src/canvascontext.js +216 -0
  27. package/build/esm/src/chordsymbol.js +325 -0
  28. package/build/esm/src/clef.js +120 -0
  29. package/build/esm/src/clefnote.js +35 -0
  30. package/build/esm/src/crescendo.js +78 -0
  31. package/build/esm/src/curve.js +126 -0
  32. package/build/esm/src/dot.js +129 -0
  33. package/build/esm/src/easyscore.js +374 -0
  34. package/build/esm/src/element.js +409 -0
  35. package/build/esm/src/factory.js +463 -0
  36. package/build/esm/src/flag.js +22 -0
  37. package/build/esm/src/font.js +237 -0
  38. package/build/esm/src/fonts/academico.js +1 -0
  39. package/build/esm/src/fonts/academicobold.js +1 -0
  40. package/build/esm/src/fonts/bravura.js +1 -0
  41. package/build/esm/src/fonts/gonville.js +1 -0
  42. package/build/esm/src/fonts/petaluma.js +1 -0
  43. package/build/esm/src/fonts/petalumascript.js +1 -0
  44. package/build/esm/src/formatter.js +610 -0
  45. package/build/esm/src/fraction.js +170 -0
  46. package/build/esm/src/frethandfinger.js +141 -0
  47. package/build/esm/src/ghostnote.js +50 -0
  48. package/build/esm/src/glyphnote.js +44 -0
  49. package/build/esm/src/glyphs.js +2936 -0
  50. package/build/esm/src/gracenote.js +106 -0
  51. package/build/esm/src/gracenotegroup.js +138 -0
  52. package/build/esm/src/gracetabnote.js +11 -0
  53. package/build/esm/src/index.js +86 -0
  54. package/build/esm/src/keymanager.js +99 -0
  55. package/build/esm/src/keysignature.js +220 -0
  56. package/build/esm/src/keysignote.js +28 -0
  57. package/build/esm/src/metrics.js +237 -0
  58. package/build/esm/src/modifier.js +121 -0
  59. package/build/esm/src/modifiercontext.js +110 -0
  60. package/build/esm/src/multimeasurerest.js +127 -0
  61. package/build/esm/src/music.js +322 -0
  62. package/build/esm/src/note.js +383 -0
  63. package/build/esm/src/notehead.js +89 -0
  64. package/build/esm/src/notesubgroup.js +59 -0
  65. package/build/esm/src/ornament.js +192 -0
  66. package/build/esm/src/parenthesis.js +61 -0
  67. package/build/esm/src/parser.js +164 -0
  68. package/build/esm/src/pedalmarking.js +168 -0
  69. package/build/esm/src/registry.js +81 -0
  70. package/build/esm/src/rendercontext.js +20 -0
  71. package/build/esm/src/renderer.js +112 -0
  72. package/build/esm/src/repeatnote.js +17 -0
  73. package/build/esm/src/stave.js +579 -0
  74. package/build/esm/src/stavebarline.js +237 -0
  75. package/build/esm/src/staveconnector.js +180 -0
  76. package/build/esm/src/stavehairpin.js +115 -0
  77. package/build/esm/src/staveline.js +199 -0
  78. package/build/esm/src/stavemodifier.js +56 -0
  79. package/build/esm/src/stavenote.js +861 -0
  80. package/build/esm/src/staverepetition.js +120 -0
  81. package/build/esm/src/stavesection.js +36 -0
  82. package/build/esm/src/stavetempo.js +110 -0
  83. package/build/esm/src/stavetext.js +55 -0
  84. package/build/esm/src/stavetie.js +186 -0
  85. package/build/esm/src/stavevolta.js +53 -0
  86. package/build/esm/src/stem.js +133 -0
  87. package/build/esm/src/stemmablenote.js +193 -0
  88. package/build/esm/src/stringnumber.js +228 -0
  89. package/build/esm/src/strokes.js +164 -0
  90. package/build/esm/src/svgcontext.js +402 -0
  91. package/build/esm/src/system.js +166 -0
  92. package/build/esm/src/tables.js +696 -0
  93. package/build/esm/src/tabnote.js +278 -0
  94. package/build/esm/src/tabslide.js +68 -0
  95. package/build/esm/src/tabstave.js +17 -0
  96. package/build/esm/src/tabtie.js +19 -0
  97. package/build/esm/src/textbracket.js +128 -0
  98. package/build/esm/src/textdynamics.js +53 -0
  99. package/build/esm/src/textnote.js +116 -0
  100. package/build/esm/src/tickable.js +224 -0
  101. package/build/esm/src/tickcontext.js +189 -0
  102. package/build/esm/src/timesignature.js +169 -0
  103. package/build/esm/src/timesignote.js +30 -0
  104. package/build/esm/src/tremolo.js +30 -0
  105. package/build/esm/src/tuning.js +55 -0
  106. package/build/esm/src/tuplet.js +258 -0
  107. package/build/esm/src/typeguard.js +30 -0
  108. package/build/esm/src/util.js +67 -0
  109. package/build/esm/src/version.js +3 -0
  110. package/build/esm/src/vexflow.js +309 -0
  111. package/build/esm/src/vibrato.js +68 -0
  112. package/build/esm/src/vibratobracket.js +44 -0
  113. package/build/esm/src/voice.js +178 -0
  114. package/build/esm/src/web.js +15 -0
  115. package/build/esm/tests/accidental_tests.js +1055 -0
  116. package/build/esm/tests/annotation_tests.js +381 -0
  117. package/build/esm/tests/articulation_tests.js +432 -0
  118. package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
  119. package/build/esm/tests/barline_tests.js +52 -0
  120. package/build/esm/tests/beam_tests.js +669 -0
  121. package/build/esm/tests/bend_tests.js +223 -0
  122. package/build/esm/tests/boundingbox_tests.js +53 -0
  123. package/build/esm/tests/browser_test_runner.js +128 -0
  124. package/build/esm/tests/chordsymbol_tests.js +405 -0
  125. package/build/esm/tests/clef_tests.js +141 -0
  126. package/build/esm/tests/crossbeam_tests.js +306 -0
  127. package/build/esm/tests/curve_tests.js +152 -0
  128. package/build/esm/tests/demo_petzold_tests.js +335 -0
  129. package/build/esm/tests/dot_tests.js +119 -0
  130. package/build/esm/tests/easyscore_tests.js +488 -0
  131. package/build/esm/tests/factory_tests.js +44 -0
  132. package/build/esm/tests/font_tests.js +134 -0
  133. package/build/esm/tests/formatter/framestack.js +61 -0
  134. package/build/esm/tests/formatter/tests.js +251 -0
  135. package/build/esm/tests/formatter_tests.js +759 -0
  136. package/build/esm/tests/fraction_tests.js +72 -0
  137. package/build/esm/tests/ghostnote_tests.js +77 -0
  138. package/build/esm/tests/glyphnote_tests.js +119 -0
  139. package/build/esm/tests/gracenote_tests.js +414 -0
  140. package/build/esm/tests/gracetabnote_tests.js +79 -0
  141. package/build/esm/tests/index.js +68 -0
  142. package/build/esm/tests/key_clef_tests.js +106 -0
  143. package/build/esm/tests/keymanager_tests.js +68 -0
  144. package/build/esm/tests/keysignature_tests.js +322 -0
  145. package/build/esm/tests/mocks.js +70 -0
  146. package/build/esm/tests/modifier_tests.js +24 -0
  147. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  148. package/build/esm/tests/music_tests.js +161 -0
  149. package/build/esm/tests/node_test_runner.js +31 -0
  150. package/build/esm/tests/notehead_tests.js +224 -0
  151. package/build/esm/tests/notesubgroup_tests.js +149 -0
  152. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  153. package/build/esm/tests/ornament_tests.js +333 -0
  154. package/build/esm/tests/parser_tests.js +122 -0
  155. package/build/esm/tests/pedalmarking_tests.js +91 -0
  156. package/build/esm/tests/percussion_tests.js +184 -0
  157. package/build/esm/tests/playwright/flow.spec.js +127 -0
  158. package/build/esm/tests/playwright/visual_helpers.js +30 -0
  159. package/build/esm/tests/registry_tests.js +64 -0
  160. package/build/esm/tests/renderer_tests.js +113 -0
  161. package/build/esm/tests/rests_tests.js +266 -0
  162. package/build/esm/tests/rhythm_tests.js +357 -0
  163. package/build/esm/tests/stave_tests.js +570 -0
  164. package/build/esm/tests/staveconnector_tests.js +402 -0
  165. package/build/esm/tests/stavehairpin_tests.js +90 -0
  166. package/build/esm/tests/staveline_tests.js +123 -0
  167. package/build/esm/tests/stavemodifier_tests.js +51 -0
  168. package/build/esm/tests/stavenote_tests.js +936 -0
  169. package/build/esm/tests/stavetie_tests.js +137 -0
  170. package/build/esm/tests/stringnumber_tests.js +283 -0
  171. package/build/esm/tests/strokes_tests.js +289 -0
  172. package/build/esm/tests/style_tests.js +96 -0
  173. package/build/esm/tests/tabnote_tests.js +462 -0
  174. package/build/esm/tests/tabslide_tests.js +133 -0
  175. package/build/esm/tests/tabstave_tests.js +24 -0
  176. package/build/esm/tests/tabtie_tests.js +171 -0
  177. package/build/esm/tests/test_runner.js +23 -0
  178. package/build/esm/tests/textbracket_tests.js +100 -0
  179. package/build/esm/tests/textnote_tests.js +216 -0
  180. package/build/esm/tests/threevoice_tests.js +132 -0
  181. package/build/esm/tests/tickcontext_tests.js +36 -0
  182. package/build/esm/tests/timesignature_tests.js +173 -0
  183. package/build/esm/tests/tremolo_tests.js +34 -0
  184. package/build/esm/tests/tuning_tests.js +56 -0
  185. package/build/esm/tests/tuplet_tests.js +711 -0
  186. package/build/esm/tests/typeguard_tests.js +82 -0
  187. package/build/esm/tests/unison_tests.js +74 -0
  188. package/build/esm/tests/vexflow_test_helpers.js +318 -0
  189. package/build/esm/tests/vf_prefix_tests.js +101 -0
  190. package/build/esm/tests/vibrato_tests.js +93 -0
  191. package/build/esm/tests/vibratobracket_tests.js +45 -0
  192. package/build/esm/tests/vitest/job-0.test.js +2 -0
  193. package/build/esm/tests/vitest/job-1.test.js +2 -0
  194. package/build/esm/tests/vitest/job-2.test.js +2 -0
  195. package/build/esm/tests/vitest/job-3.test.js +2 -0
  196. package/build/esm/tests/vitest/run.js +5 -0
  197. package/build/esm/tests/vitest.setup.js +44 -0
  198. package/build/esm/tests/voice_tests.js +69 -0
  199. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  200. package/build/types/entry/vexflow-core.d.ts +3 -0
  201. package/build/types/entry/vexflow-debug.d.ts +3 -0
  202. package/build/types/entry/vexflow.d.ts +3 -0
  203. package/build/types/src/accidental.d.ts +60 -0
  204. package/build/types/src/annotation.d.ts +58 -0
  205. package/build/types/src/articulation.d.ts +78 -0
  206. package/build/types/src/barnote.d.ts +29 -0
  207. package/build/types/src/beam.d.ts +158 -0
  208. package/build/types/src/bend.d.ts +67 -0
  209. package/build/types/src/boundingbox.d.ts +42 -0
  210. package/build/types/src/canvascontext.d.ts +93 -0
  211. package/build/types/src/chordsymbol.d.ts +109 -0
  212. package/build/types/src/clef.d.ts +38 -0
  213. package/build/types/src/clefnote.d.ts +17 -0
  214. package/build/types/src/crescendo.d.ts +26 -0
  215. package/build/types/src/curve.d.ts +42 -0
  216. package/build/types/src/dot.d.ts +19 -0
  217. package/build/types/src/easyscore.d.ts +152 -0
  218. package/build/types/src/element.d.ts +278 -0
  219. package/build/types/src/factory.d.ts +273 -0
  220. package/build/types/src/flag.d.ts +12 -0
  221. package/build/types/src/font.d.ts +96 -0
  222. package/build/types/src/fonts/academico.d.ts +1 -0
  223. package/build/types/src/fonts/academicobold.d.ts +1 -0
  224. package/build/types/src/fonts/bravura.d.ts +1 -0
  225. package/build/types/src/fonts/gonville.d.ts +1 -0
  226. package/build/types/src/fonts/petaluma.d.ts +1 -0
  227. package/build/types/src/fonts/petalumascript.d.ts +1 -0
  228. package/build/types/src/formatter.d.ts +226 -0
  229. package/build/types/src/fraction.d.ts +65 -0
  230. package/build/types/src/frethandfinger.d.ts +19 -0
  231. package/build/types/src/ghostnote.d.ts +16 -0
  232. package/build/types/src/glyphnote.d.ts +14 -0
  233. package/build/types/src/glyphs.d.ts +2935 -0
  234. package/build/types/src/gracenote.d.ts +17 -0
  235. package/build/types/src/gracenotegroup.d.ts +33 -0
  236. package/build/types/src/gracetabnote.d.ts +5 -0
  237. package/build/types/src/index.d.ts +86 -0
  238. package/build/types/src/keymanager.d.ts +25 -0
  239. package/build/types/src/keysignature.d.ts +50 -0
  240. package/build/types/src/keysignote.d.ts +11 -0
  241. package/build/types/src/metrics.d.ts +25 -0
  242. package/build/types/src/modifier.d.ts +90 -0
  243. package/build/types/src/modifiercontext.d.ts +48 -0
  244. package/build/types/src/multimeasurerest.d.ts +61 -0
  245. package/build/types/src/music.d.ts +91 -0
  246. package/build/types/src/note.d.ts +232 -0
  247. package/build/types/src/notehead.d.ts +50 -0
  248. package/build/types/src/notesubgroup.d.ts +18 -0
  249. package/build/types/src/ornament.d.ts +71 -0
  250. package/build/types/src/parenthesis.d.ts +21 -0
  251. package/build/types/src/parser.d.ts +45 -0
  252. package/build/types/src/pedalmarking.d.ts +63 -0
  253. package/build/types/src/registry.d.ts +40 -0
  254. package/build/types/src/rendercontext.d.ts +59 -0
  255. package/build/types/src/renderer.d.ts +35 -0
  256. package/build/types/src/repeatnote.d.ts +6 -0
  257. package/build/types/src/stave.d.ts +181 -0
  258. package/build/types/src/stavebarline.d.ts +38 -0
  259. package/build/types/src/staveconnector.d.ts +53 -0
  260. package/build/types/src/stavehairpin.d.ts +56 -0
  261. package/build/types/src/staveline.d.ts +49 -0
  262. package/build/types/src/stavemodifier.d.ts +35 -0
  263. package/build/types/src/stavenote.d.ts +150 -0
  264. package/build/types/src/staverepetition.d.ts +30 -0
  265. package/build/types/src/stavesection.d.ts +8 -0
  266. package/build/types/src/stavetempo.d.ts +43 -0
  267. package/build/types/src/stavetext.d.ts +11 -0
  268. package/build/types/src/stavetie.d.ts +104 -0
  269. package/build/types/src/stavevolta.d.ts +15 -0
  270. package/build/types/src/stem.d.ts +58 -0
  271. package/build/types/src/stemmablenote.d.ts +39 -0
  272. package/build/types/src/stringnumber.d.ts +26 -0
  273. package/build/types/src/strokes.d.ts +35 -0
  274. package/build/types/src/svgcontext.d.ts +135 -0
  275. package/build/types/src/system.d.ts +121 -0
  276. package/build/types/src/tables.d.ts +86 -0
  277. package/build/types/src/tabnote.d.ts +45 -0
  278. package/build/types/src/tabslide.d.ts +36 -0
  279. package/build/types/src/tabstave.d.ts +7 -0
  280. package/build/types/src/tabtie.d.ts +18 -0
  281. package/build/types/src/textbracket.d.ts +45 -0
  282. package/build/types/src/textdynamics.d.ts +34 -0
  283. package/build/types/src/textnote.d.ts +48 -0
  284. package/build/types/src/tickable.d.ts +149 -0
  285. package/build/types/src/tickcontext.d.ts +112 -0
  286. package/build/types/src/timesignature.d.ts +75 -0
  287. package/build/types/src/timesignote.d.ts +11 -0
  288. package/build/types/src/tremolo.d.ts +12 -0
  289. package/build/types/src/tuning.d.ts +23 -0
  290. package/build/types/src/tuplet.d.ts +98 -0
  291. package/build/types/src/typeguard.d.ts +100 -0
  292. package/build/types/src/util.d.ts +42 -0
  293. package/build/types/src/version.d.ts +3 -0
  294. package/build/types/src/vexflow.d.ts +261 -0
  295. package/build/types/src/vibrato.d.ts +20 -0
  296. package/build/types/src/vibratobracket.d.ts +28 -0
  297. package/build/types/src/voice.d.ts +109 -0
  298. package/build/types/src/web.d.ts +2 -0
  299. package/package.json +145 -0
  300. package/tests/flow.html +256 -0
@@ -0,0 +1,171 @@
1
+ import { VexFlow } from '../src/vexflow.js';
2
+ import { VexFlowTests } from './vexflow_test_helpers.js';
3
+ import { Annotation } from '../src/annotation.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
+ VexFlowTests.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.setFont('Arial', VexFlowTests.Font.size);
24
+ const stave = new TabStave(10, 10, w || 350).addTabGlyph().setContext(context).drawWithStyle();
25
+ return { context, stave };
26
+ }
27
+ function tieNotes(notes, indexes, stave, ctx, text) {
28
+ const voice = new Voice(VexFlow.TIME4_4);
29
+ voice.addTickables(notes);
30
+ new Formatter().joinVoices([voice]).format([voice], 100);
31
+ voice.draw(ctx, stave);
32
+ const tie = new TabTie({
33
+ firstNote: notes[0],
34
+ lastNote: notes[1],
35
+ firstIndexes: indexes,
36
+ lastIndexes: indexes,
37
+ }, text !== null && text !== void 0 ? text : 'Annotation');
38
+ tie.setContext(ctx);
39
+ tie.drawWithStyle();
40
+ }
41
+ function simple(options, contextBuilder) {
42
+ options.contextBuilder = contextBuilder;
43
+ const { context, stave } = setupContext(options);
44
+ const note1 = tabNote({ positions: [{ str: 4, fret: 4 }], duration: 'h' });
45
+ const note2 = tabNote({ positions: [{ str: 4, fret: 6 }], duration: 'h' });
46
+ tieNotes([note1, note2], [0], stave, context);
47
+ options.assert.ok(true, 'Simple Test');
48
+ }
49
+ function simpleHammerOn(options, contextBuilder) {
50
+ options.contextBuilder = contextBuilder;
51
+ multiTest(options, TabTie.createHammeron);
52
+ }
53
+ function simplePullOff(options, contextBuilder) {
54
+ options.contextBuilder = contextBuilder;
55
+ multiTest(options, TabTie.createPulloff);
56
+ }
57
+ function multiTest(options, createTabTie) {
58
+ const { context, stave } = setupContext(options, 440, 140);
59
+ const notes = [
60
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: '8' }),
61
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: '8' }),
62
+ tabNote({
63
+ positions: [
64
+ { str: 4, fret: 4 },
65
+ { str: 5, fret: 4 },
66
+ ],
67
+ duration: '8',
68
+ }),
69
+ tabNote({
70
+ positions: [
71
+ { str: 4, fret: 6 },
72
+ { str: 5, fret: 6 },
73
+ ],
74
+ duration: '8',
75
+ }),
76
+ tabNote({ positions: [{ str: 2, fret: 14 }], duration: '8' }),
77
+ tabNote({ positions: [{ str: 2, fret: 16 }], duration: '8' }),
78
+ tabNote({
79
+ positions: [
80
+ { str: 2, fret: 14 },
81
+ { str: 3, fret: 14 },
82
+ ],
83
+ duration: '8',
84
+ }),
85
+ tabNote({
86
+ positions: [
87
+ { str: 2, fret: 16 },
88
+ { str: 3, fret: 16 },
89
+ ],
90
+ duration: '8',
91
+ }),
92
+ ];
93
+ const voice = new Voice(VexFlow.TIME4_4).addTickables(notes);
94
+ new Formatter().joinVoices([voice]).format([voice], 300);
95
+ voice.draw(context, stave);
96
+ createTabTie({
97
+ firstNote: notes[0],
98
+ lastNote: notes[1],
99
+ firstIndexes: [0],
100
+ lastIndexes: [0],
101
+ })
102
+ .setContext(context)
103
+ .drawWithStyle();
104
+ options.assert.ok(true, 'Single note');
105
+ createTabTie({
106
+ firstNote: notes[2],
107
+ lastNote: notes[3],
108
+ firstIndexes: [0, 1],
109
+ lastIndexes: [0, 1],
110
+ })
111
+ .setContext(context)
112
+ .drawWithStyle();
113
+ options.assert.ok(true, 'Chord');
114
+ createTabTie({
115
+ firstNote: notes[4],
116
+ lastNote: notes[5],
117
+ firstIndexes: [0],
118
+ lastIndexes: [0],
119
+ })
120
+ .setContext(context)
121
+ .drawWithStyle();
122
+ options.assert.ok(true, 'Single note high-fret');
123
+ createTabTie({
124
+ firstNote: notes[6],
125
+ lastNote: notes[7],
126
+ firstIndexes: [0, 1],
127
+ lastIndexes: [0, 1],
128
+ })
129
+ .setContext(context)
130
+ .drawWithStyle();
131
+ options.assert.ok(true, 'Chord high-fret');
132
+ }
133
+ function tap(options, contextBuilder) {
134
+ options.contextBuilder = contextBuilder;
135
+ const { context, stave } = setupContext(options);
136
+ const note1 = tabNote({ positions: [{ str: 4, fret: 12 }], duration: 'h' }).addModifier(new Annotation('T'), 0);
137
+ const note2 = tabNote({ positions: [{ str: 4, fret: 10 }], duration: 'h' });
138
+ tieNotes([note1, note2], [0], stave, context, 'P');
139
+ options.assert.ok(true, 'Tapping Test');
140
+ }
141
+ function continuous(options, contextBuilder) {
142
+ options.contextBuilder = contextBuilder;
143
+ const { context, stave } = setupContext(options, 440, 140);
144
+ const notes = [
145
+ tabNote({ positions: [{ str: 4, fret: 4 }], duration: 'q' }),
146
+ tabNote({ positions: [{ str: 4, fret: 5 }], duration: 'q' }),
147
+ tabNote({ positions: [{ str: 4, fret: 6 }], duration: 'h' }),
148
+ ];
149
+ const voice = new Voice(VexFlow.TIME4_4).addTickables(notes);
150
+ new Formatter().joinVoices([voice]).format([voice], 300);
151
+ voice.draw(context, stave);
152
+ TabTie.createHammeron({
153
+ firstNote: notes[0],
154
+ lastNote: notes[1],
155
+ firstIndexes: [0],
156
+ lastIndexes: [0],
157
+ })
158
+ .setContext(context)
159
+ .drawWithStyle();
160
+ TabTie.createPulloff({
161
+ firstNote: notes[1],
162
+ lastNote: notes[2],
163
+ firstIndexes: [0],
164
+ lastIndexes: [0],
165
+ })
166
+ .setContext(context)
167
+ .drawWithStyle();
168
+ options.assert.ok(true, 'Continuous Hammeron');
169
+ }
170
+ VexFlowTests.register(TabTieTests);
171
+ export { TabTieTests };
@@ -0,0 +1,23 @@
1
+ const missingBackend = {
2
+ module: () => {
3
+ throw new Error('No test runner has been installed.');
4
+ },
5
+ test: () => {
6
+ throw new Error('No test runner has been installed.');
7
+ },
8
+ };
9
+ let backend = missingBackend;
10
+ export const TestRunner = {
11
+ install(nextBackend) {
12
+ backend = nextBackend;
13
+ },
14
+ reset() {
15
+ backend = missingBackend;
16
+ },
17
+ module(name) {
18
+ backend.module(name);
19
+ },
20
+ test(name, callback) {
21
+ backend.test(name, callback);
22
+ },
23
+ };
@@ -0,0 +1,100 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ const TextBracketTests = {
3
+ Start() {
4
+ VexFlowTests.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
+ options.assert.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].renderOptions.lineWidth = 2;
90
+ topOctaves[1].renderOptions.showBracket = false;
91
+ bottomOctaves[0].renderOptions.underlineSuperscript = false;
92
+ bottomOctaves[0].setDashed(false);
93
+ bottomOctaves[1].renderOptions.bracketHeight = 40;
94
+ bottomOctaves[1].setDashed(true, [2, 2]);
95
+ f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
96
+ f.draw();
97
+ options.assert.ok(true);
98
+ }
99
+ VexFlowTests.register(TextBracketTests);
100
+ export { TextBracketTests };
@@ -0,0 +1,216 @@
1
+ import { VexFlow } from '../src/vexflow.js';
2
+ import { VexFlowTests } from './vexflow_test_helpers.js';
3
+ import { Crescendo } from '../src/crescendo.js';
4
+ import { Note } from '../src/note.js';
5
+ import { Stave } from '../src/stave.js';
6
+ import { TextNote } from '../src/textnote.js';
7
+ const TextNoteTests = {
8
+ Start() {
9
+ VexFlowTests.module('TextNote');
10
+ const run = VexFlowTests.runTests;
11
+ run('TextNote Formatting', formatTextNotes);
12
+ run('TextNote Formatting 2', formatTextNotes2);
13
+ run('TextNote Superscript and Subscript', superscriptAndSubscript);
14
+ run('TextNote Formatting With Glyphs 0', formatTextGlyphs0);
15
+ run('TextNote Formatting With Glyphs 1', formatTextGlyphs1);
16
+ run('Crescendo', crescendo);
17
+ run('Text Dynamics', textDynamics);
18
+ },
19
+ };
20
+ function formatTextNotes(options) {
21
+ const f = VexFlowTests.makeFactory(options, 400, 200);
22
+ const stave = f.Stave({ y: 40 });
23
+ const score = f.EasyScore();
24
+ const voice1 = score.voice([
25
+ f
26
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: -1, duration: 'h' })
27
+ .addModifier(f.Accidental({ type: 'b' }), 0)
28
+ .addModifier(f.Accidental({ type: '#' }), 1),
29
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stemDirection: -1, duration: 'q' }),
30
+ f
31
+ .StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: 'q' })
32
+ .addModifier(f.Accidental({ type: 'n' }), 0)
33
+ .addModifier(f.Accidental({ type: '#' }), 1),
34
+ ]);
35
+ const voice2 = score.voice([
36
+ f.TextNote({ text: 'Center Justification', duration: 'h' }).setJustification(TextNote.Justification.CENTER),
37
+ f.TextNote({ text: 'Left Line 1', duration: 'q' }).setLine(1),
38
+ f.TextNote({ text: 'Right', duration: 'q' }).setJustification(TextNote.Justification.RIGHT),
39
+ ]);
40
+ const formatter = f.Formatter();
41
+ formatter.joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
42
+ f.draw();
43
+ options.assert.ok(true);
44
+ }
45
+ function formatTextNotes2(options) {
46
+ const f = VexFlowTests.makeFactory(options, 600, 200);
47
+ const stave = f.Stave({ y: 40 });
48
+ const score = f.EasyScore();
49
+ const voice1 = score.voice([
50
+ f.StaveNote({ keys: ['g/4'], stemDirection: 1, duration: '16' }),
51
+ f.StaveNote({ keys: ['g/4'], stemDirection: 1, duration: '16' }),
52
+ f.StaveNote({ keys: ['g/4'], stemDirection: 1, duration: '16' }),
53
+ f.StaveNote({ keys: ['g/5'], stemDirection: -1, duration: '16' }),
54
+ f.StaveNote({ keys: ['g/5'], stemDirection: -1, duration: '16' }),
55
+ f.StaveNote({ keys: ['g/5'], stemDirection: -1, duration: '16' }),
56
+ f.StaveNote({ keys: ['g/5', 'a/5'], stemDirection: -1, duration: '16' }),
57
+ f.StaveNote({ keys: ['g/5', 'a/5'], stemDirection: -1, duration: '16' }),
58
+ f.StaveNote({ keys: ['g/5', 'a/5'], stemDirection: -1, duration: '16' }),
59
+ f.StaveNote({ keys: ['g/4', 'a/4'], stemDirection: 1, duration: '16' }),
60
+ f.StaveNote({ keys: ['g/4', 'a/4'], stemDirection: 1, duration: '16' }),
61
+ f.StaveNote({ keys: ['g/4', 'a/4'], stemDirection: 1, duration: '16' }),
62
+ f.StaveNote({ keys: ['g/4', 'a/4'], stemDirection: 1, duration: 'q' }),
63
+ ]);
64
+ const voice2 = score.voice([
65
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
66
+ f.TextNote({ text: 'L', duration: '16' }),
67
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
68
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
69
+ f.TextNote({ text: 'L', duration: '16' }),
70
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
71
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
72
+ f.TextNote({ text: 'L', duration: '16' }),
73
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
74
+ f.TextNote({ text: 'C', duration: '16' }).setJustification(TextNote.Justification.CENTER),
75
+ f.TextNote({ text: 'L', duration: '16' }),
76
+ f.TextNote({ text: 'R', duration: '16' }).setJustification(TextNote.Justification.RIGHT),
77
+ f.TextNote({ text: 'R', duration: 'q' }).setJustification(TextNote.Justification.RIGHT),
78
+ ]);
79
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
80
+ voice2.getTickables().forEach((note) => Note.plotMetrics(f.getContext(), note, 170));
81
+ f.draw();
82
+ options.assert.ok(true);
83
+ }
84
+ function superscriptAndSubscript(options) {
85
+ const f = VexFlowTests.makeFactory(options, 600, 230);
86
+ const stave = f.Stave({ y: 40 });
87
+ const score = f.EasyScore();
88
+ const voice1 = score.voice([
89
+ f
90
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: 1, duration: 'h' })
91
+ .addModifier(f.Accidental({ type: 'b' }), 0)
92
+ .addModifier(f.Accidental({ type: '#' }), 1),
93
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stemDirection: 1, duration: 'q' }),
94
+ f
95
+ .StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: 1, duration: 'q' })
96
+ .addModifier(f.Accidental({ type: 'n' }), 0)
97
+ .addModifier(f.Accidental({ type: '#' }), 1),
98
+ ]);
99
+ const notes2 = [
100
+ f.TextNote({ text: VexFlow.unicode.flat + 'I', superscript: '+5', duration: '8' }),
101
+ f.TextNote({ text: 'D' + VexFlow.unicode.sharp + '/F', duration: '4d', superscript: 'sus2' }),
102
+ f.TextNote({ text: 'ii', superscript: '6', subscript: '4', duration: '8' }),
103
+ f.TextNote({ text: 'C', superscript: VexFlow.unicode.triangle + '7', subscript: '', duration: '8' }),
104
+ f.TextNote({ text: 'vii', superscript: VexFlow.unicode['o-with-slash'] + '7', duration: '8' }),
105
+ f.TextNote({ text: 'V', superscript: '7', duration: '8' }),
106
+ ];
107
+ options.assert.equal(notes2[0].getText(), VexFlow.unicode.flat + 'I', 'TextNote.getText() return .text');
108
+ const voice2 = score.voice(notes2);
109
+ voice2.getTickables().forEach((note) => {
110
+ const textNote = note;
111
+ textNote.setFontSize(15);
112
+ textNote.setLine(13);
113
+ textNote.setJustification(TextNote.Justification.LEFT);
114
+ });
115
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
116
+ f.draw();
117
+ options.assert.ok(true);
118
+ }
119
+ function formatTextGlyphs0(options) {
120
+ const f = VexFlowTests.makeFactory(options, 600, 230);
121
+ const stave = f.Stave({ y: 40 });
122
+ const score = f.EasyScore();
123
+ const voice1 = score.voice([
124
+ f
125
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: -1, duration: 'h' })
126
+ .addModifier(f.Accidental({ type: 'b' }), 0)
127
+ .addModifier(f.Accidental({ type: '#' }), 1),
128
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stemDirection: -1, duration: '8' }),
129
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
130
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
131
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
132
+ ]);
133
+ const voice2 = score.voice([
134
+ f.TextNote({ text: 'Center', duration: '8' }).setJustification(TextNote.Justification.CENTER),
135
+ f.TextNote({ glyph: 'f', duration: '8' }),
136
+ f.TextNote({ glyph: 'p', duration: '8' }),
137
+ f.TextNote({ glyph: 'm', duration: '8' }),
138
+ f.TextNote({ glyph: 'z', duration: '8' }),
139
+ f.TextNote({ glyph: 'mordentUpper', duration: '16' }),
140
+ f.TextNote({ glyph: 'mordentLower', duration: '16' }),
141
+ f.TextNote({ glyph: 'segno', duration: '8' }),
142
+ f.TextNote({ glyph: 'coda', duration: '8' }),
143
+ ]);
144
+ voice2.getTickables().forEach((n) => n.setJustification(TextNote.Justification.CENTER));
145
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
146
+ f.draw();
147
+ options.assert.ok(true);
148
+ }
149
+ function formatTextGlyphs1(options) {
150
+ const f = VexFlowTests.makeFactory(options, 600, 230);
151
+ const stave = f.Stave({ y: 40 });
152
+ const score = f.EasyScore();
153
+ const voice1 = score.voice([
154
+ f
155
+ .StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: -1, duration: 'h' })
156
+ .addModifier(f.Accidental({ type: 'b' }), 0)
157
+ .addModifier(f.Accidental({ type: '#' }), 1),
158
+ f.StaveNote({ keys: ['d/4', 'e/4', 'f/4'], stemDirection: -1, duration: '8' }),
159
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
160
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
161
+ f.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: '8' }),
162
+ ]);
163
+ const voice2 = score.voice([
164
+ f.TextNote({ glyph: 'turn', duration: '16' }),
165
+ f.TextNote({ glyph: 'turnInverted', duration: '16' }),
166
+ f.TextNote({ glyph: 'pedalOpen', duration: '8' }).setLine(10),
167
+ f.TextNote({ glyph: 'pedalClose', duration: '8' }).setLine(10),
168
+ f.TextNote({ glyph: 'caesuraCurved', duration: '8' }).setLine(3),
169
+ f.TextNote({ glyph: 'caesuraStraight', duration: '8' }).setLine(3),
170
+ f.TextNote({ glyph: 'breath', duration: '8' }).setLine(2),
171
+ f.TextNote({ glyph: 'tick', duration: '8' }).setLine(3),
172
+ f.TextNote({ glyph: 'tr', duration: '8', smooth: true }).setJustification(TextNote.Justification.CENTER),
173
+ ]);
174
+ voice2.getTickables().forEach((n) => n.setJustification(TextNote.Justification.CENTER));
175
+ f.Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
176
+ f.draw();
177
+ options.assert.ok(true);
178
+ }
179
+ function crescendo(options) {
180
+ const f = VexFlowTests.makeFactory(options, 600, 230);
181
+ const stave = f.Stave({ y: 40 });
182
+ const score = f.EasyScore();
183
+ const voice = score.voice([
184
+ f.TextNote({ glyph: 'p', duration: '16' }),
185
+ new Crescendo({ duration: '4d' }).setLine(0).setHeight(25).setStave(stave),
186
+ f.TextNote({ glyph: 'f', duration: '16' }),
187
+ new Crescendo({ duration: '4' }).setLine(5).setStave(stave),
188
+ new Crescendo({ duration: '4' }).setLine(10).setDecrescendo(true).setHeight(5).setStave(stave),
189
+ ]);
190
+ f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
191
+ f.draw();
192
+ options.assert.ok(true);
193
+ }
194
+ function textDynamics(options) {
195
+ const f = VexFlowTests.makeFactory(options, 600, 230);
196
+ const score = f.EasyScore();
197
+ const voice = score.voice([
198
+ f.TextDynamics({ text: 'sfz', duration: '4' }),
199
+ f.TextDynamics({ text: 'rfz', duration: '4' }),
200
+ f.TextDynamics({ text: 'mp', duration: '4' }),
201
+ f.TextDynamics({ text: 'ppp', duration: '4' }),
202
+ f.TextDynamics({ text: 'fff', duration: '4' }),
203
+ f.TextDynamics({ text: 'mf', duration: '4' }),
204
+ f.TextDynamics({ text: 'sff', duration: '4' }),
205
+ ], { time: '7/4' });
206
+ const formatter = f.Formatter();
207
+ formatter.joinVoices([voice]);
208
+ const width = formatter.preCalculateMinTotalWidth([voice]);
209
+ formatter.format([voice]);
210
+ const stave = f.Stave({ y: 40, width: width + Stave.defaultPadding });
211
+ stave.drawWithStyle();
212
+ voice.draw(f.getContext(), stave);
213
+ options.assert.ok(true);
214
+ }
215
+ VexFlowTests.register(TextNoteTests);
216
+ 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
+ VexFlowTests.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()).drawWithStyle();
32
+ }
33
+ options.assert.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, alignRests) {
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, { alignRests });
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()).drawWithStyle();
85
+ }
86
+ options.assert.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, alignRests) {
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, { alignRests });
104
+ x += width;
105
+ }
106
+ createMeasure('Default Rest Positions', 400, false);
107
+ createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
108
+ f.draw();
109
+ options.assert.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, alignRests) {
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, { alignRests });
124
+ x += width;
125
+ }
126
+ createMeasure('Default Rest Positions', 400, false);
127
+ createMeasure('Rests Repositioned To Avoid Collisions', 400, true);
128
+ f.draw();
129
+ options.assert.ok(true);
130
+ }
131
+ VexFlowTests.register(ThreeVoicesTests);
132
+ export { ThreeVoicesTests };