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