vexflow 5.2.0 → 5.4.0

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 (189) hide show
  1. package/README.md +2 -0
  2. package/build/cjs/vexflow-bravura.js +2 -2
  3. package/build/cjs/vexflow-bravura.js.map +1 -1
  4. package/build/cjs/vexflow-core.js +2 -2
  5. package/build/cjs/vexflow-core.js.map +1 -1
  6. package/build/cjs/vexflow-debug-with-tests.js +6502 -1708
  7. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  8. package/build/cjs/vexflow-debug.js +5622 -1618
  9. package/build/cjs/vexflow-debug.js.map +1 -1
  10. package/build/cjs/vexflow.js +2 -2
  11. package/build/cjs/vexflow.js.map +1 -1
  12. package/build/esm/src/accidental.js +10 -3
  13. package/build/esm/src/alternatingtremolo.js +68 -0
  14. package/build/esm/src/annotation.js +19 -3
  15. package/build/esm/src/articulation.js +28 -6
  16. package/build/esm/src/beam.js +171 -28
  17. package/build/esm/src/bend.js +79 -23
  18. package/build/esm/src/clef.js +3 -0
  19. package/build/esm/src/continuouslayout.js +681 -0
  20. package/build/esm/src/continuousspan.js +159 -0
  21. package/build/esm/src/curve.js +48 -55
  22. package/build/esm/src/dot.js +13 -4
  23. package/build/esm/src/easyscore/composition.js +52 -2
  24. package/build/esm/src/easyscore/policies.js +39 -8
  25. package/build/esm/src/element.js +4 -0
  26. package/build/esm/src/engravinggeometry.js +157 -0
  27. package/build/esm/src/engravingprofile.js +44 -0
  28. package/build/esm/src/factory.js +31 -11
  29. package/build/esm/src/font.js +9 -1
  30. package/build/esm/src/formatter.js +9 -1
  31. package/build/esm/src/fretdiagram.js +77 -0
  32. package/build/esm/src/gracenote.js +43 -38
  33. package/build/esm/src/gracenotegroup.js +53 -56
  34. package/build/esm/src/guitargesture.js +33 -0
  35. package/build/esm/src/guitarmodifiers.js +26 -0
  36. package/build/esm/src/index.js +10 -0
  37. package/build/esm/src/instrumentprofile.js +123 -0
  38. package/build/esm/src/keysignature.js +24 -2
  39. package/build/esm/src/modifiercontext.js +11 -0
  40. package/build/esm/src/notationspelling.js +73 -0
  41. package/build/esm/src/note.js +3 -0
  42. package/build/esm/src/notehead.js +11 -6
  43. package/build/esm/src/ornament.js +43 -18
  44. package/build/esm/src/pagebreaks.js +58 -0
  45. package/build/esm/src/pedalmarking.js +39 -17
  46. package/build/esm/src/phraselayout.js +503 -0
  47. package/build/esm/src/phraseribbon.js +28 -0
  48. package/build/esm/src/proportionalformatter.js +54 -6
  49. package/build/esm/src/publication.js +402 -0
  50. package/build/esm/src/publicationview.js +114 -0
  51. package/build/esm/src/scorenavigation.js +172 -0
  52. package/build/esm/src/sheet.js +14 -2
  53. package/build/esm/src/stave.js +33 -16
  54. package/build/esm/src/stavebarline.js +5 -7
  55. package/build/esm/src/staveconnector.js +1 -0
  56. package/build/esm/src/stavehairpin.js +53 -27
  57. package/build/esm/src/stavenote.js +134 -116
  58. package/build/esm/src/stavetie.js +66 -9
  59. package/build/esm/src/stem.js +26 -11
  60. package/build/esm/src/strokes.js +4 -0
  61. package/build/esm/src/system.js +19 -4
  62. package/build/esm/src/systembreaks.js +42 -0
  63. package/build/esm/src/tabnote.js +6 -1
  64. package/build/esm/src/textbracket.js +24 -5
  65. package/build/esm/src/tickcontext.js +19 -0
  66. package/build/esm/src/timesignature.js +20 -6
  67. package/build/esm/src/tuplet.js +58 -17
  68. package/build/esm/src/version.js +3 -3
  69. package/build/esm/src/vexflow.js +20 -0
  70. package/build/esm/src/voice.js +7 -3
  71. package/build/esm/tests/bend_tests.js +14 -1
  72. package/build/esm/tests/curve_tests.js +14 -4
  73. package/build/esm/tests/demo_repertoire_tests.js +27 -0
  74. package/build/esm/tests/demos/drums.js +54 -0
  75. package/build/esm/tests/demos/electric.js +63 -0
  76. package/build/esm/tests/demos/greensleeves.js +90 -0
  77. package/build/esm/tests/demos/joy.js +61 -0
  78. package/build/esm/tests/demos/kesh.js +80 -0
  79. package/build/esm/tests/demos/prelude.js +59 -0
  80. package/build/esm/tests/demos/quartertones.js +50 -0
  81. package/build/esm/tests/demos/saints.js +65 -0
  82. package/build/esm/tests/engraving/continuous-studies.mjs +140 -0
  83. package/build/esm/tests/engraving/instrument-studies.mjs +273 -0
  84. package/build/esm/tests/engraving/phrase-studies.mjs +63 -0
  85. package/build/esm/tests/engraving/publication-studies.mjs +87 -0
  86. package/build/esm/tests/engraving/score-layout.mjs +75 -0
  87. package/build/esm/tests/engraving/score-persistence.mjs +262 -0
  88. package/build/esm/tests/engraving/specialist-studies.mjs +347 -0
  89. package/build/esm/tests/engraving/studies.mjs +367 -0
  90. package/build/esm/tests/formatter_tests.js +10 -1
  91. package/build/esm/tests/index.js +1 -0
  92. package/build/esm/tests/node/audit-dependencies-tests.mjs +42 -0
  93. package/build/esm/tests/node/continuous-score-tests.mjs +282 -0
  94. package/build/esm/tests/node/easyscore-tests.mjs +71 -0
  95. package/build/esm/tests/node/engraving-layout-tests.mjs +449 -0
  96. package/build/esm/tests/node/instrument-profile-tests.mjs +224 -0
  97. package/build/esm/tests/node/local-engraving-tests.mjs +128 -0
  98. package/build/esm/tests/node/phrase-layout-tests.mjs +281 -0
  99. package/build/esm/tests/node/proportional-spacing-tests.mjs +64 -0
  100. package/build/esm/tests/node/publication-tests.mjs +219 -0
  101. package/build/esm/tests/node/rendering-tests.mjs +6 -2
  102. package/build/esm/tests/threevoice_tests.js +11 -1
  103. package/build/esm/tests/vexflow_test_helpers.js +19 -10
  104. package/build/esm/tools/audit-dependencies.mjs +61 -0
  105. package/build/esm/tools/easyscore-structure.mjs +1 -1
  106. package/build/esm/tools/explorer/catalog/entries.mjs +2 -1
  107. package/build/esm/tools/explorer/catalog/expression.mjs +14 -9
  108. package/build/esm/tools/explorer/catalog/guitar.mjs +238 -0
  109. package/build/esm/tools/explorer/catalog/layout.mjs +8 -6
  110. package/build/esm/tools/explorer/catalog/notes.mjs +16 -14
  111. package/build/esm/tools/explorer/catalog/staves.mjs +12 -6
  112. package/build/esm/tools/explorer/catalog/strings.mjs +10 -7
  113. package/build/esm/tools/score-fixtures.mjs +23 -6
  114. package/build/types/src/accidental.d.ts +4 -0
  115. package/build/types/src/alternatingtremolo.d.ts +13 -0
  116. package/build/types/src/annotation.d.ts +9 -0
  117. package/build/types/src/articulation.d.ts +9 -1
  118. package/build/types/src/beam.d.ts +16 -0
  119. package/build/types/src/bend.d.ts +8 -0
  120. package/build/types/src/clef.d.ts +3 -0
  121. package/build/types/src/continuouslayout.d.ts +103 -0
  122. package/build/types/src/continuousspan.d.ts +60 -0
  123. package/build/types/src/curve.d.ts +20 -0
  124. package/build/types/src/dot.d.ts +5 -0
  125. package/build/types/src/easyscore/composition.d.ts +27 -0
  126. package/build/types/src/easyscore/policies.d.ts +1 -1
  127. package/build/types/src/element.d.ts +2 -0
  128. package/build/types/src/engravinggeometry.d.ts +31 -0
  129. package/build/types/src/engravingprofile.d.ts +20 -0
  130. package/build/types/src/factory.d.ts +6 -1
  131. package/build/types/src/formatter.d.ts +3 -3
  132. package/build/types/src/fretdiagram.d.ts +23 -0
  133. package/build/types/src/gracenote.d.ts +7 -0
  134. package/build/types/src/gracenotegroup.d.ts +7 -2
  135. package/build/types/src/guitargesture.d.ts +26 -0
  136. package/build/types/src/guitarmodifiers.d.ts +3 -0
  137. package/build/types/src/index.d.ts +12 -0
  138. package/build/types/src/instrumentprofile.d.ts +124 -0
  139. package/build/types/src/keysignature.d.ts +9 -0
  140. package/build/types/src/modifiercontext.d.ts +4 -0
  141. package/build/types/src/notationspelling.d.ts +25 -0
  142. package/build/types/src/note.d.ts +15 -0
  143. package/build/types/src/notehead.d.ts +5 -0
  144. package/build/types/src/ornament.d.ts +10 -1
  145. package/build/types/src/pagebreaks.d.ts +26 -0
  146. package/build/types/src/pedalmarking.d.ts +9 -0
  147. package/build/types/src/phraselayout.d.ts +87 -0
  148. package/build/types/src/phraseribbon.d.ts +7 -0
  149. package/build/types/src/proportionalformatter.d.ts +11 -2
  150. package/build/types/src/publication.d.ts +61 -0
  151. package/build/types/src/publicationview.d.ts +27 -0
  152. package/build/types/src/scorenavigation.d.ts +33 -0
  153. package/build/types/src/sheet.d.ts +5 -0
  154. package/build/types/src/stave.d.ts +13 -0
  155. package/build/types/src/stavehairpin.d.ts +18 -0
  156. package/build/types/src/stavenote.d.ts +20 -2
  157. package/build/types/src/stavetie.d.ts +9 -0
  158. package/build/types/src/stem.d.ts +10 -1
  159. package/build/types/src/system.d.ts +8 -1
  160. package/build/types/src/systembreaks.d.ts +9 -0
  161. package/build/types/src/textbracket.d.ts +7 -0
  162. package/build/types/src/tickcontext.d.ts +5 -0
  163. package/build/types/src/timesignature.d.ts +6 -0
  164. package/build/types/src/tuplet.d.ts +5 -48
  165. package/build/types/src/vexflow.d.ts +20 -0
  166. package/build/types/src/voice.d.ts +2 -0
  167. package/changelog/CHANGELOG.md +25 -0
  168. package/package.json +15 -3
  169. package/tests/all.html +277 -0
  170. package/tests/demo_petzold_tests.ts +435 -0
  171. package/tests/demos/drums.ts +55 -0
  172. package/tests/demos/drums.webp +0 -0
  173. package/tests/demos/electric.ts +70 -0
  174. package/tests/demos/electric.webp +0 -0
  175. package/tests/demos/greensleeves.ts +97 -0
  176. package/tests/demos/greensleeves.webp +0 -0
  177. package/tests/demos/joy.ts +65 -0
  178. package/tests/demos/joy.webp +0 -0
  179. package/tests/demos/kesh.ts +86 -0
  180. package/tests/demos/kesh.webp +0 -0
  181. package/tests/demos/prelude.ts +65 -0
  182. package/tests/demos/prelude.webp +0 -0
  183. package/tests/demos/quartertones.ts +51 -0
  184. package/tests/demos/quartertones.webp +0 -0
  185. package/tests/demos/saints.ts +70 -0
  186. package/tests/demos/saints.webp +0 -0
  187. package/tests/flow.html +550 -239
  188. package/tests/fonts.css +493 -0
  189. package/tests/minuet.webp +0 -0
@@ -0,0 +1,63 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, Bend, Stem } from '../../src/index.js';
3
+ export function electric(options) {
4
+ const f = VexFlowTests.makeFactory(options, 900, 380);
5
+ const score = f.EasyScore({ throwOnError: true });
6
+ const makeNote = (duration, ...frets) => score.make.tabNote({ duration, stemDirection: Stem.DOWN, positions: frets.map(([str, fret]) => ({ str, fret })) }, true);
7
+ const bars = [
8
+ [
9
+ makeNote('q', [6, 5], [5, 7], [4, 7]),
10
+ makeNote('8', [3, 5]),
11
+ makeNote('8', [3, 7]),
12
+ makeNote('q', [2, 5]),
13
+ makeNote('q', [2, 8]),
14
+ ],
15
+ [makeNote('h', [3, 7]), makeNote('8', [3, 5]), makeNote('8', [3, 7]), makeNote('q', [4, 7])],
16
+ [5, 8, 12, 8, 5, 8, 12, 8].map((fret) => makeNote('8', [1, fret])),
17
+ [makeNote('q', [1, 5]), makeNote('8', [2, 8]), makeNote('8', [2, 5]), makeNote('h', [4, 7], [3, 9], [2, 10])],
18
+ ];
19
+ bars.forEach((notes, i) => {
20
+ const x = 16 + (i % 2) * 432;
21
+ const y = 35 + Math.floor(i / 2) * 176;
22
+ const stave = score.make.tabStave({ x, y, width: 432 });
23
+ if (i % 2 === 0)
24
+ stave.addClef('tab');
25
+ if (i === 0)
26
+ stave.addTimeSignature('4/4').setTempo({ duration: 'q', bpm: 96 }, -8);
27
+ if (i === 3)
28
+ stave.setEndBarType(BarlineType.END);
29
+ const legato = (start, label) => score.make
30
+ .tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label)
31
+ .setFont('Arial, Helvetica, sans-serif', 9, 'bold');
32
+ if (i === 0) {
33
+ score.beam(notes.slice(1, 3));
34
+ legato(1, 'H');
35
+ notes[4].addModifier(score.make.vibrato().setVibratoWidth(30));
36
+ }
37
+ else if (i === 1) {
38
+ notes[0].addModifier(score.make.bend([
39
+ { type: Bend.UP, text: 'Full' },
40
+ { type: Bend.DOWN, text: '' },
41
+ ]));
42
+ score.beam(notes.slice(1, 3));
43
+ score.make.tabSlide({ firstNote: notes[1], lastNote: notes[2] });
44
+ }
45
+ else if (i === 2) {
46
+ score.beam(notes.slice(0, 4));
47
+ score.beam(notes.slice(4));
48
+ for (const start of [0, 4]) {
49
+ legato(start, 'H');
50
+ legato(start + 1, 'T');
51
+ legato(start + 2, 'P');
52
+ }
53
+ legato(3, 'P');
54
+ }
55
+ else {
56
+ score.beam(notes.slice(1, 3));
57
+ legato(1, 'P');
58
+ }
59
+ f.System({ x, y, width: 432 }).addStave({ stave, voices: [score.voice(notes)] });
60
+ });
61
+ f.draw();
62
+ options.assert.ok(true, 'Four bars of rhythmic tab with native guitar techniques');
63
+ }
@@ -0,0 +1,90 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, Stroke } from '../../src/index.js';
3
+ const positions = {
4
+ E3: [6, 0],
5
+ F3: [6, 1],
6
+ G3: [6, 3],
7
+ A3: [5, 0],
8
+ B3: [5, 2],
9
+ C4: [5, 3],
10
+ D4: [4, 0],
11
+ E4: [4, 2],
12
+ F4: [4, 3],
13
+ G4: [3, 0],
14
+ 'G#4': [3, 1],
15
+ A4: [3, 2],
16
+ B4: [2, 0],
17
+ C5: [2, 1],
18
+ D5: [2, 3],
19
+ E5: [1, 0],
20
+ F5: [1, 1],
21
+ };
22
+ export function greensleeves(options) {
23
+ const f = VexFlowTests.makeFactory(options, 900, 486);
24
+ const score = f.EasyScore({ throwOnError: true });
25
+ const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
26
+ const bars = [
27
+ ['', 'A4/q'],
28
+ ['Am', 'A3+E4+A4+C5/h D5/q'],
29
+ ['C', 'C4+G4+C5+E5/q. F5/8 E5/q'],
30
+ ['G', 'G3+D4+G4+D5/h B4/q'],
31
+ ['Em', 'E3+B3+G4/q. A4/8 B4/q'],
32
+ ['Am', 'A3+E4+A4+C5/h A4/q'],
33
+ ['Dm/F', 'F3+D4+A4/q. G#4/8 A4/q'],
34
+ ['E', 'E3+E4+B4/h G#4/q'],
35
+ ['E5', 'E3+B3+E4/h'],
36
+ ];
37
+ bars.forEach(([chordName, bar], i) => {
38
+ const row = i >= 5 ? 1 : 0;
39
+ const width = row ? 218 : i === 0 ? 112 : 190;
40
+ const x = row ? 12 + (i - 5) * width : i === 0 ? 12 : 124 + (i - 1) * width;
41
+ const y = 28 + row * 230;
42
+ const events = bar.split(' ').map((token) => {
43
+ const [chord, duration] = token.split('/');
44
+ return { pitches: chord.split('+'), duration };
45
+ });
46
+ const music = events.map(({ pitches, duration }) => {
47
+ const chord = pitches.length === 1 ? pitches[0] : `(${pitches.join(' ')})`;
48
+ return `${chord}/${duration}`;
49
+ });
50
+ const notes = score.notes(music.join(', '));
51
+ if (chordName)
52
+ notes[0].addModifier(score.make.chordSymbol(chordFont).addText(chordName));
53
+ const tab = events.map(({ pitches, duration }) => score.make.tabNote({
54
+ positions: pitches.map((pitch) => {
55
+ const [str, fret] = positions[pitch];
56
+ return { str, fret };
57
+ }),
58
+ duration: duration.replace('.', ''),
59
+ dots: duration.includes('.') ? 1 : 0,
60
+ }));
61
+ if (i === 1 || i === 5) {
62
+ notes[0].addModifier(score.make.fingering({ number: '1', position: 'left' }), 3);
63
+ notes[0].addModifier(score.make.fingering({ number: '2', position: 'left' }), 1);
64
+ }
65
+ if (i === 2 || i === 8)
66
+ notes[0].addModifier(score.make.stroke(Stroke.Type.ARPEGGIO_DIRECTIONLESS));
67
+ if (i === 2 || i === 6)
68
+ score.make.curve({ from: notes[1], to: notes[2] });
69
+ const time = i === 0 ? '1/4' : i === bars.length - 1 ? '2/4' : '3/4';
70
+ const system = f.System({ x, y, width, spaceBetweenStaves: 8 });
71
+ const stave = system.addStave({ voices: [score.voice(notes, { time })], options: { topTextPosition: 3.5 } });
72
+ const tablature = system.addStave({
73
+ stave: score.make.tabStave({ x, y, width }),
74
+ voices: [score.voice(tab, { time })],
75
+ });
76
+ if (i === 0 || i === 5) {
77
+ stave.addClef('treble', 'default', '8vb');
78
+ if (i === 0)
79
+ stave.addTimeSignature('3/4');
80
+ tablature.addClef('tab');
81
+ system.addConnector('bracket');
82
+ }
83
+ if (i === bars.length - 1) {
84
+ stave.setEndBarType(BarlineType.END);
85
+ tablature.setEndBarType(BarlineType.END);
86
+ }
87
+ });
88
+ f.draw();
89
+ options.assert.ok(true, 'Chord melody and tab share the same rhythmic grid');
90
+ }
@@ -0,0 +1,61 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, StaveHairpin } from '../../src/index.js';
3
+ export function joy(options) {
4
+ const f = VexFlowTests.makeFactory(options, 900, 435);
5
+ const score = f.EasyScore({ throwOnError: true });
6
+ score.set({ clef: 'bass', time: '4/4' });
7
+ const duet = [
8
+ ['F3/q, F3, G3, A3', 'D3/h, A2'],
9
+ ['A3/q, G3, F3, E3', 'F2/h, A2'],
10
+ ['D3/q, D3, E3, F3', 'B2/h, G2'],
11
+ ['F3/q., E3/8, E3/h', 'A2/w'],
12
+ ['F3/q, F3, G3, A3', 'D3/h, A2'],
13
+ ['A3/q, G3, F3, E3', 'F2/h, A2'],
14
+ ['D3/q, D3, E3, F3', 'G2/h, A2'],
15
+ ['E3/q., D3/8, D3/h', 'A2/h, D2'],
16
+ ];
17
+ duet.forEach(([tune, bass], i) => {
18
+ const notes = score.notes(tune);
19
+ const system = f.System({
20
+ x: 24 + (i % 4) * 213,
21
+ y: 10 + Math.floor(i / 4) * 210,
22
+ width: 213,
23
+ spaceBetweenStaves: 10,
24
+ });
25
+ const voices = [score.voice(notes)];
26
+ if (i % 2 === 0) {
27
+ const dynamic = ['p', 'mf', 'mp', 'f'][i / 2];
28
+ voices.push(score.voice([score.make.textDynamics({ text: dynamic, duration: 'w', line: 10 })]));
29
+ }
30
+ const first = system.addStave({ voices });
31
+ const second = system.addStave({ voices: [score.voice(score.notes(bass))] });
32
+ if (i % 4 === 0) {
33
+ first.addClef('bass').addKeySignature('D');
34
+ second.addClef('bass').addKeySignature('D');
35
+ if (i === 0) {
36
+ first.addTimeSignature('4/4');
37
+ second.addTimeSignature('4/4');
38
+ }
39
+ system.addConnector('bracket');
40
+ }
41
+ if (i === 1 || i === 5) {
42
+ score.make.hairpin({
43
+ from: notes[0],
44
+ to: notes[3],
45
+ type: StaveHairpin.type.CRESC,
46
+ options: { height: 8, yShift: -21 },
47
+ });
48
+ }
49
+ if (i === 0 || i === 4)
50
+ notes[0].addModifier(score.make.articulation({ type: 'tenuto', position: 'above' }));
51
+ if (i === 3 || i === 7)
52
+ score.make.curve({ from: notes[0], to: notes[1] });
53
+ if (i === 7) {
54
+ first.setEndBarType(BarlineType.END);
55
+ second.setEndBarType(BarlineType.END);
56
+ }
57
+ system.addConnector('singleRight');
58
+ });
59
+ f.draw();
60
+ options.assert.ok(true, 'Two cello parts aligned through the cadence');
61
+ }
@@ -0,0 +1,80 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, VoltaType } from '../../src/index.js';
3
+ export function kesh(options) {
4
+ const f = VexFlowTests.makeFactory(options, 900, 580);
5
+ const score = f.EasyScore({ throwOnError: true });
6
+ score.set({ time: '6/8' });
7
+ const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
8
+ const strains = [
9
+ [
10
+ ['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
11
+ ['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
12
+ ['E5/8, D5, D5', 'G5/8, D5, D5', 'G'],
13
+ ['E5/8, D5, B4', 'D5/8, B4, A4', '', 'D'],
14
+ ['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
15
+ ['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
16
+ ['E5/8, D5, D5', 'G5/8, D5, B4', 'G'],
17
+ ['A4/8, G4, F4', 'G4/q, D4/8', 'D', 'G'],
18
+ ['A4/8, G4, F4', 'G4/q, A4/8', 'D', 'G'],
19
+ ],
20
+ [
21
+ ['B4/q, B4/8', 'D5/8, B4, D5', 'G'],
22
+ ['E5/8, G5, E5', 'D5/8, B4, G4', 'C', 'G'],
23
+ ['B4/q, B4/8', 'D5/8, B4, G4', ''],
24
+ ['A4/8, B4, A4', 'A4/8, G4, A4', 'Am'],
25
+ ['B4/8, A4, B4', 'D5/8, B4, D5', 'G'],
26
+ ['E5/8, G5, E5', 'D5/8, B4, D5', 'C', 'G'],
27
+ ['E5/q.', 'A5/8, G5, A5', 'C', 'D'],
28
+ ['B5/8, G5, G5', 'G5/q, A4/8', 'G'],
29
+ ['B5/8, G5, G5', 'G5/q', 'G'],
30
+ ],
31
+ ];
32
+ const pickupWidth = 130;
33
+ const firstY = 36;
34
+ f.System({ x: 16, y: firstY, width: pickupWidth })
35
+ .addStave({ voices: [score.voice(score.notes('D4/8'), { time: '1/8' })] })
36
+ .addClef('treble')
37
+ .addKeySignature('G')
38
+ .addTimeSignature('6/8');
39
+ strains.forEach((bars, part) => bars.forEach(([firstBeat, secondBeat, chord, nextChord], i) => {
40
+ const beats = [score.notes(firstBeat), score.notes(secondBeat)];
41
+ const notes = beats.flat();
42
+ for (const beat of beats) {
43
+ if (beat.length === 3)
44
+ score.beam(beat);
45
+ }
46
+ if (chord)
47
+ beats[0][0].addModifier(score.make.chordSymbol(chordFont).addText(chord));
48
+ if (nextChord)
49
+ beats[1][0].addModifier(score.make.chordSymbol(chordFont).addText(nextChord));
50
+ if (i === 0 || i === 4) {
51
+ const grace = score.make.graceNote({ keys: [part ? 'd/5' : 'b/4'], duration: '8', slash: true });
52
+ notes[1].addModifier(score.make.graceNoteGroup({ notes: [grace], slur: true }));
53
+ }
54
+ if (i === 2 || i === 6) {
55
+ const bow = beats[0].length === 3 ? beats[0] : beats[1];
56
+ score.make.curve({ from: bow[0], to: bow[2] });
57
+ }
58
+ const firstLine = i < 4;
59
+ const pickup = part === 0 && firstLine ? pickupWidth : 0;
60
+ const width = (868 - pickup) / (firstLine ? 4 : 5);
61
+ const x = 16 + pickup + (firstLine ? i : i - 4) * width;
62
+ const row = part * 2 + (firstLine ? 0 : 1);
63
+ const lastBar = part === 1 && i === 8;
64
+ const stave = f
65
+ .System({ x, y: firstY + row * 142, width })
66
+ .addStave({ voices: [score.voice(notes, { time: lastBar ? '5/8' : '6/8' })], options: { topTextPosition: 2 } });
67
+ if (i === 4 || (part === 1 && i === 0))
68
+ stave.addClef('treble').addKeySignature('G');
69
+ if (i === 0)
70
+ stave.setBegBarType(BarlineType.REPEAT_BEGIN).setSection(part ? 'B' : 'A', 0);
71
+ if (i === 7)
72
+ stave.setVoltaType(VoltaType.BEGIN_END, '1.', 0).setEndBarType(BarlineType.REPEAT_END);
73
+ if (i === 8)
74
+ stave.setVoltaType(VoltaType.BEGIN, '2.', 0);
75
+ if (lastBar)
76
+ stave.setEndBarType(BarlineType.END);
77
+ }));
78
+ f.draw();
79
+ options.assert.ok(true, 'Accompanied A and B strains with first and second endings');
80
+ }
@@ -0,0 +1,59 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { StaveHairpin } from '../../src/index.js';
3
+ export function prelude(options) {
4
+ const f = VexFlowTests.makeFactory(options, 900, 525);
5
+ const score = f.EasyScore({ throwOnError: true });
6
+ const harmonies = [
7
+ ['C4', 'E4', 'G4', 'C5', 'E5'],
8
+ ['C4', 'D4', 'A4', 'D5', 'F5'],
9
+ ['B3', 'D4', 'G4', 'D5', 'F5'],
10
+ ['C4', 'E4', 'G4', 'C5', 'E5'],
11
+ ];
12
+ harmonies.forEach(([bass, inner, a, b, c], i) => {
13
+ const system = f.System({
14
+ x: 24 + (i % 2) * 428,
15
+ y: 40 + Math.floor(i / 2) * 250,
16
+ width: 428,
17
+ spaceBetweenStaves: 9,
18
+ });
19
+ const treble = system.addStave({ voices: [] });
20
+ const dynamic = ['p', '', 'mf', 'p'][i];
21
+ const lower = system.addStave({
22
+ voices: dynamic ? [score.voice([score.make.textDynamics({ text: dynamic, line: 10, duration: 'w' })])] : [],
23
+ });
24
+ if (i % 2 === 0) {
25
+ treble.addClef('treble');
26
+ lower.addClef('bass');
27
+ system.addConnector('brace');
28
+ if (i === 0) {
29
+ treble.addTimeSignature('C').setTempo({ name: 'Andante, legato', duration: 'q', bpm: 72 }, -9);
30
+ lower.addTimeSignature('C');
31
+ }
32
+ }
33
+ const arpeggio = [];
34
+ for (let half = 0; half < 2; half++) {
35
+ const left = score.notes(`${bass}/16, ${inner}`, { clef: 'bass', stem: 'up' });
36
+ const right = score.notes(`${a}/16, ${b}`, { stem: 'down' });
37
+ const answer = score.notes(`${c}/16, ${a}, ${b}, ${c}`, { stem: 'down' });
38
+ left.forEach((note) => note.setStave(lower));
39
+ [...right, ...answer].forEach((note) => note.setStave(treble));
40
+ score.beam([...left, ...right]);
41
+ score.beam(answer);
42
+ if (half === 0 && i >= 2)
43
+ answer[0].addModifier(score.make.articulation({ type: i === 2 ? 'accent' : 'tenuto', position: 'above' }));
44
+ arpeggio.push(...left, ...right, ...answer);
45
+ }
46
+ if (i === 1 || i === 2) {
47
+ score.make.hairpin({
48
+ from: arpeggio[0],
49
+ to: arpeggio[8],
50
+ type: i === 1 ? StaveHairpin.type.CRESC : StaveHairpin.type.DECRESC,
51
+ options: { leftShiftPx: i === 2 ? 30 : 0, yShift: -6, height: 7 },
52
+ });
53
+ }
54
+ system.addVoices([score.voice(arpeggio)]);
55
+ system.addConnector('singleRight');
56
+ });
57
+ f.draw();
58
+ options.assert.ok(true, 'Both hands share a beam on beats one and three');
59
+ }
@@ -0,0 +1,50 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, StaveHairpin } from '../../src/index.js';
3
+ export function quartertones(options) {
4
+ const f = VexFlowTests.makeFactory(options, 900, 340);
5
+ const score = f.EasyScore({ throwOnError: true });
6
+ score.set({ time: '5/8', clef: 'alto' });
7
+ const bars = [
8
+ { music: 'D4/8, D4, E4, F4/q', signs: ['', '+', 'd', ''] },
9
+ { music: 'F4/8, F4, G4, A4/q', signs: ['', '+', '', 'd'] },
10
+ { music: 'A4/q., G4/q', signs: ['n', '+'] },
11
+ { music: 'G4/8, G4, F4, E4/q', signs: ['', 'd', '+', ''] },
12
+ { music: 'E4/8, E4, D4, C4/q', signs: ['', 'd', '+', '++'] },
13
+ { music: 'D4/q., D4/q', signs: ['d', 'n'] },
14
+ ];
15
+ bars.forEach(({ music, signs }, i) => {
16
+ const notes = score.notes(music);
17
+ signs.forEach((type, n) => {
18
+ if (!type)
19
+ return;
20
+ const mark = score.make.accidental({ type });
21
+ if (i === 2 && n === 0)
22
+ mark.setAsCautionary();
23
+ notes[n].addModifier(mark);
24
+ });
25
+ if (notes.length === 4) {
26
+ score.beam(notes.slice(0, 3));
27
+ score.make.curve({ from: notes[0], to: notes[2] });
28
+ }
29
+ if (i === 0 || i === 4)
30
+ score.make.hairpin({
31
+ from: notes[0],
32
+ to: notes[3],
33
+ type: i === 0 ? StaveHairpin.type.CRESC : StaveHairpin.type.DECRESC,
34
+ options: { height: 7, yShift: -4 },
35
+ });
36
+ const stave = f
37
+ .System({ x: 16 + (i % 3) * 288, y: 24 + Math.floor(i / 3) * 154, width: 288 })
38
+ .addStave({ voices: [score.voice(notes)] });
39
+ if (i % 3 === 0)
40
+ stave.addClef('alto');
41
+ if (i === 0)
42
+ stave.addTimeSignature('5/8').setTempo({ name: 'Sotto voce', duration: '8', bpm: 108 }, -4);
43
+ if (i === 5) {
44
+ notes[1].addModifier(score.make.articulation({ type: 'fermata', position: 'above' }));
45
+ stave.setEndBarType(BarlineType.END);
46
+ }
47
+ });
48
+ f.draw();
49
+ options.assert.ok(true, 'Quarter-tone inflections in two phrases of three measures');
50
+ }
@@ -0,0 +1,65 @@
1
+ import { VexFlowTests } from '../vexflow_test_helpers.js';
2
+ import { BarlineType, ChordSymbol } from '../../src/index.js';
3
+ export function saints(options) {
4
+ const factory = VexFlowTests.makeFactory(options, 900, 540);
5
+ const score = factory.EasyScore({ throwOnError: true });
6
+ const bars = [
7
+ ['G4/w', 'saints', 'C:6/9'],
8
+ ['B4/q/r, C4/q, E4, F4', '|go|march-|ing', 'Am:7'],
9
+ ['G4/w', 'in', 'Dm:11'],
10
+ ['B4/q/r, C4/q, E4, F4', '|Oh|when|the', 'G:13'],
11
+ ['G4/q, E4, C4, E4', 'saints|go|march-|ing', 'C:maj9'],
12
+ ['D4/w', 'in', 'Am:11'],
13
+ ['D4/w', '', 'D:9'],
14
+ ['B4/q/r, E4/q, E4, D4', '|Oh|Lord,|I', 'G:13'],
15
+ ['C4/h, C4/q, E4', 'want|to|be', 'Gm:13'],
16
+ ['G4/h, G4/q, G4', 'in|that|num-', 'C:9'],
17
+ ['F4/w', 'ber', 'F:maj9'],
18
+ ['B4/q/r, C4/q, E4, F4', '|Oh|when|the', 'Fm:maj7'],
19
+ ['G4/h, E4/q, C4', 'saints|go|march-', 'Em:7'],
20
+ ['D4/w', 'ing', 'Db:7b9'],
21
+ ['C4/w', 'in', 'C:6/9'],
22
+ ['C4/q', '', ''],
23
+ ];
24
+ const pickup = score.notes('C4/q, E4, F4');
25
+ const pickupLabels = ['Oh', 'when', 'the'];
26
+ pickup.forEach((note, i) => note.addModifier(factory.Annotation({ text: pickupLabels[i], vJustify: 'bottom' }).setTextBaseline(123)));
27
+ factory
28
+ .System({ x: 10, y: 16, width: 180 })
29
+ .addStave({ voices: [score.voice(pickup, { time: '3/4' })] })
30
+ .addClef('treble')
31
+ .addTimeSignature('4/4');
32
+ let sustained;
33
+ bars.forEach(([music, words, harmony], i) => {
34
+ const row = Math.floor(i / 4);
35
+ const column = i % 4;
36
+ const y = 16 + row * 130;
37
+ const width = row === 0 ? 174 : 219;
38
+ const notes = score.notes(music);
39
+ if (i === 5 || i === 14)
40
+ sustained = notes[0];
41
+ if ((i === 6 || i === 15) && sustained)
42
+ score.make.tie({ from: sustained, to: notes[0] });
43
+ words.split('|').forEach((text, n) => {
44
+ if (text)
45
+ notes[n].addModifier(factory.Annotation({ text, vJustify: 'bottom' }).setTextBaseline(y + 107));
46
+ });
47
+ if (harmony) {
48
+ const [root, extension] = harmony.split(':');
49
+ const chord = factory
50
+ .ChordSymbol()
51
+ .addGlyphOrText(root)
52
+ .addGlyphOrText(extension, { symbolModifier: ChordSymbol.symbolModifiers.SUPERSCRIPT });
53
+ notes[0].addModifier(chord);
54
+ }
55
+ const stave = factory
56
+ .System({ x: (row === 0 ? 190 : 10) + column * width, y, width })
57
+ .addStave({ voices: [score.voice(notes, { time: i === 15 ? '1/4' : '4/4' })] });
58
+ if (column === 0 && row > 0)
59
+ stave.addClef('treble');
60
+ if (i === bars.length - 1)
61
+ stave.setEndBarType(BarlineType.END);
62
+ });
63
+ factory.draw();
64
+ options.assert.ok(true, 'Petaluma lead sheet with aligned lyrics');
65
+ }
@@ -0,0 +1,140 @@
1
+ export function makeContinuousStudy(VF, factory, kind, width, mode = 'balanced') {
2
+ const score = factory.EasyScore();
3
+ const measure = (notes, changes = {}) => (Object.assign(Object.assign({}, changes), { voices: [{ notes }] }));
4
+ const event = (key, duration, id, stave, clef) => ({
5
+ note: Object.assign({ keys: Array.isArray(key) ? key : [key], duration }, (clef ? { clef } : {})),
6
+ id,
7
+ stave,
8
+ });
9
+ const main = typeof VF.Sheet.prototype.getContinuousLayout === 'function';
10
+ let staves, spans = [], boundaries = [], groups = [];
11
+ if (kind === 'choir') {
12
+ const pitches = [
13
+ ['g/4', 'a/4'],
14
+ ['b/4', 'a/4'],
15
+ ['g/4', 'e/4'],
16
+ ['a/4', 'b/4'],
17
+ ['a/4', 'g/4'],
18
+ ['f#/4', 'g/4'],
19
+ ];
20
+ staves = [
21
+ {
22
+ id: 'voice',
23
+ name: 'Voice',
24
+ shortName: 'V.',
25
+ measures: pitches.map((p, i) => measure(p.map((k, j) => event(k, 'h', 'v' + i + j)), i === 2 ? { key: 'D' } : {})),
26
+ },
27
+ ];
28
+ spans = [
29
+ { id: 'sung-word', kind: 'lyric', text: 'Sing', from: 'v00', to: 'v51' },
30
+ { id: 'phrase', kind: 'slur', from: 'v00', to: 'v51', side: 'above' },
31
+ ];
32
+ }
33
+ else if (kind === 'keyboard') {
34
+ const upper = [
35
+ ['e/5', 'd/5'],
36
+ ['c/5', 'b/4'],
37
+ ['a/4', 'g/4'],
38
+ ['f/4', 'e/4'],
39
+ ];
40
+ const lower = ['c/3', 'e/3', 'f/3', 'c/3'];
41
+ staves = [
42
+ {
43
+ id: 'right',
44
+ name: 'Piano',
45
+ shortName: 'Pno.',
46
+ measures: upper.map((p, i) => measure(p.map((k, j) => event(k, 'h', 'r' + i + j)))),
47
+ },
48
+ { id: 'left', clef: 'bass', measures: lower.map((k, i) => measure([event(k, 'w', 'l' + i)])) },
49
+ ];
50
+ staves[0].measures[0].voices = [
51
+ {
52
+ autoBeam: true,
53
+ stem: 'down',
54
+ notes: [
55
+ event('e/5', '8', 'r00'),
56
+ event('b/3', '8', 'cross', 'left', 'bass'),
57
+ event('d/5', 'q', 'r01'),
58
+ event('c/5', 'h', 'rch'),
59
+ ],
60
+ },
61
+ ];
62
+ spans = [
63
+ { id: 'swell', kind: 'crescendo', from: 'r01', to: 'r31' },
64
+ { id: 'sustain', kind: 'pedal', from: 'l0', to: 'l3' },
65
+ ];
66
+ groups = [{ first: 'right', last: 'left', type: 'brace', barlines: true }];
67
+ boundaries = [{ measure: 3, breakBefore: 'force', rehearsal: 'B' }];
68
+ }
69
+ else if (kind === 'chord') {
70
+ const part = (staff, clef, pitches) => ({
71
+ id: staff,
72
+ clef,
73
+ measures: pitches.map((pair, i) => measure(pair.map((key, k) => ({ id: staff + i + k, note: { keys: [key], duration: 'h', stemDirection: 1 } })))),
74
+ });
75
+ staves = [
76
+ part('rh', 'treble', [
77
+ ['e/4', 'g/4'],
78
+ ['a/4', 'b/4'],
79
+ ]),
80
+ part('lh', 'bass', [
81
+ ['c/3', 'e/3'],
82
+ ['f/3', 'g/3'],
83
+ ]),
84
+ ];
85
+ groups = [{ first: 'rh', last: 'lh', type: 'brace', barlines: true }];
86
+ }
87
+ else if (kind === 'ensemble') {
88
+ const rest = () => measure([event('b/4', 'wr')]);
89
+ const make = (staff, pitches) => pitches.map((p, i) => (p ? measure([event(p, 'w', staff + i)]) : rest()));
90
+ staves = [
91
+ { id: 'fl', name: 'Flute', shortName: 'Fl.', measures: make('fl', ['e/5', null, null, null, 'd/5', 'e/5']) },
92
+ {
93
+ id: 'vc',
94
+ clef: 'bass',
95
+ name: 'Cello',
96
+ shortName: 'Vc.',
97
+ measures: make('vc', [null, null, null, null, 'g/2', 'c/3']),
98
+ },
99
+ ];
100
+ boundaries = [
101
+ { measure: 5, breakBefore: 'force', rehearsal: 'B', repeatStart: true },
102
+ { measure: 6, repeatEnd: true },
103
+ ];
104
+ groups = [{ first: 'fl', last: 'vc', type: 'bracket' }];
105
+ }
106
+ else {
107
+ const content = ['C4/q, D4/q, E4/q, F4/q', 'G4/w', 'F4/w', 'E4/w', 'D4/w', 'C4/w', 'G4/w'];
108
+ staves = [{ id: 'line', measures: content.map((n) => measure(n)) }];
109
+ }
110
+ const result = score.compose({
111
+ sheet: { width, x: 12, y: 8, rowGap: 14, measurePadding: 14 },
112
+ system: { spaceBetweenStaves: 8 },
113
+ accidentals: 'key-aware',
114
+ staves,
115
+ continuous: {
116
+ mode,
117
+ groups,
118
+ spans,
119
+ boundaries,
120
+ measureNumbers: true,
121
+ hideEmptyStaves: kind === 'ensemble',
122
+ splitChords: kind === 'chord' ? [{ id: 'split', upper: 'rh00', lower: 'lh00' }] : [],
123
+ compressRests: kind === 'ensemble',
124
+ },
125
+ });
126
+ if (kind === 'chord') {
127
+ const arpeggio = factory
128
+ .Stroke(VF.Stroke.Type.ARPEGGIO_DIRECTIONLESS, { allVoices: false })
129
+ .addEndNote(result.getNote('lh00'));
130
+ result.getNote('rh00').addModifier(arpeggio, 0);
131
+ }
132
+ if (kind === 'keyboard') {
133
+ const cross = result.getNote('cross'), beam = cross.getBeam();
134
+ if (beam)
135
+ cross.setStemDirection(1).setBeam(beam);
136
+ }
137
+ if (!main && kind === 'choir')
138
+ result.getNote('v00').addModifier(factory.Annotation({ text: 'Sing' }), 0);
139
+ return result;
140
+ }