vexflow 5.4.0 → 5.6.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 (127) 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 +1740 -372
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +565 -258
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow.js +2 -2
  10. package/build/cjs/vexflow.js.map +1 -1
  11. package/build/esm/src/annotation.js +2 -1
  12. package/build/esm/src/continuouslayout.js +107 -16
  13. package/build/esm/src/continuousspan.js +9 -1
  14. package/build/esm/src/easyscore/composition.js +83 -18
  15. package/build/esm/src/factory.js +2 -9
  16. package/build/esm/src/formatter.js +1 -1
  17. package/build/esm/src/fretdiagram.js +6 -2
  18. package/build/esm/src/gracenotegroup.js +4 -3
  19. package/build/esm/src/guitarmodifiers.js +4 -1
  20. package/build/esm/src/metrics.js +24 -5
  21. package/build/esm/src/note.js +1 -0
  22. package/build/esm/src/notehead.js +21 -10
  23. package/build/esm/src/phraselayout.js +13 -5
  24. package/build/esm/src/publication.js +10 -5
  25. package/build/esm/src/publicationview.js +3 -2
  26. package/build/esm/src/stave.js +4 -2
  27. package/build/esm/src/stavenote.js +56 -13
  28. package/build/esm/src/stavesection.js +15 -10
  29. package/build/esm/src/stavetie.js +3 -2
  30. package/build/esm/src/strokes.js +1 -1
  31. package/build/esm/src/svgcontext.js +11 -3
  32. package/build/esm/src/tabnote.js +6 -8
  33. package/build/esm/src/tabtie.js +3 -0
  34. package/build/esm/src/version.js +3 -3
  35. package/build/esm/tests/chordsymbol_tests.js +4 -1
  36. package/build/esm/tests/demo_petzold_tests.js +26 -14
  37. package/build/esm/tests/demo_repertoire_tests.js +5 -1
  38. package/build/esm/tests/demos/ballade.js +15 -0
  39. package/build/esm/tests/demos/electric.js +1 -3
  40. package/build/esm/tests/demos/fugue.js +19 -0
  41. package/build/esm/tests/demos/greensleeves.js +1 -2
  42. package/build/esm/tests/demos/kesh.js +2 -3
  43. package/build/esm/tests/demos/saints.js +17 -5
  44. package/build/esm/tests/engraving/continuous-studies.mjs +24 -0
  45. package/build/esm/tests/engraving/publication-studies.mjs +30 -0
  46. package/build/esm/tests/font_tests.js +8 -0
  47. package/build/esm/tests/gracenote_tests.js +1 -1
  48. package/build/esm/tests/gracetabnote_tests.js +19 -3
  49. package/build/esm/tests/node/chord-kerning-tests.mjs +2 -2
  50. package/build/esm/tests/node/continuous-score-tests.mjs +157 -2
  51. package/build/esm/tests/node/easyscore-tests.mjs +38 -0
  52. package/build/esm/tests/node/engraving-layout-tests.mjs +33 -0
  53. package/build/esm/tests/node/instrument-profile-tests.mjs +40 -0
  54. package/build/esm/tests/node/local-engraving-tests.mjs +58 -0
  55. package/build/esm/tests/node/metrics-tests.mjs +2 -0
  56. package/build/esm/tests/node/phrase-layout-tests.mjs +58 -5
  57. package/build/esm/tests/node/publication-tests.mjs +158 -2
  58. package/build/esm/tests/node/svg-export-tests.mjs +50 -21
  59. package/build/esm/tests/scores/ballade.js +399 -0
  60. package/build/esm/tests/scores/drums.js +93 -0
  61. package/build/esm/tests/scores/electric.js +83 -0
  62. package/build/esm/tests/scores/falseta.js +46 -0
  63. package/build/esm/tests/scores/fugue.js +366 -0
  64. package/build/esm/tests/scores/guitar.js +32 -0
  65. package/build/esm/tests/scores/kesh.js +146 -0
  66. package/build/esm/tests/scores/prelude.js +84 -0
  67. package/build/esm/tests/scores/quartertones.js +78 -0
  68. package/build/esm/tests/scores/saints.js +70 -0
  69. package/build/esm/tests/scores/sumer.js +126 -0
  70. package/build/esm/tests/scores/viewer.js +162 -0
  71. package/build/esm/tests/tabnote_tests.js +43 -0
  72. package/build/esm/tests/vexflow_test_helpers.js +1 -0
  73. package/build/esm/tools/explorer/catalog/expression.mjs +16 -6
  74. package/build/esm/tools/explorer/catalog/guitar.mjs +2 -2
  75. package/build/types/src/continuouslayout.d.ts +4 -0
  76. package/build/types/src/continuousspan.d.ts +10 -2
  77. package/build/types/src/easyscore/composition.d.ts +19 -0
  78. package/build/types/src/fretdiagram.d.ts +2 -0
  79. package/build/types/src/instrumentprofile.d.ts +4 -0
  80. package/build/types/src/note.d.ts +2 -0
  81. package/build/types/src/notehead.d.ts +2 -0
  82. package/build/types/src/publication.d.ts +3 -1
  83. package/build/types/src/stave.d.ts +4 -2
  84. package/build/types/src/stavenote.d.ts +10 -0
  85. package/build/types/src/stavesection.d.ts +3 -0
  86. package/build/types/src/svgcontext.d.ts +2 -0
  87. package/build/types/src/typeguard.d.ts +1 -0
  88. package/changelog/CHANGELOG.md +16 -0
  89. package/package.json +4 -1
  90. package/tests/all.html +9 -0
  91. package/tests/demo_petzold_tests.ts +30 -16
  92. package/tests/demos/ballade.ts +36 -0
  93. package/tests/demos/ballade.webp +0 -0
  94. package/tests/demos/electric.ts +1 -3
  95. package/tests/demos/electric.webp +0 -0
  96. package/tests/demos/fugue.ts +27 -0
  97. package/tests/demos/fugue.webp +0 -0
  98. package/tests/demos/greensleeves.ts +1 -3
  99. package/tests/demos/greensleeves.webp +0 -0
  100. package/tests/demos/kesh.ts +2 -4
  101. package/tests/demos/kesh.webp +0 -0
  102. package/tests/demos/saints.ts +20 -7
  103. package/tests/demos/saints.webp +0 -0
  104. package/tests/flow.html +165 -52
  105. package/tests/minuet.webp +0 -0
  106. package/tests/scores/ballade.js +445 -0
  107. package/tests/scores/drums.js +101 -0
  108. package/tests/scores/drums.webp +0 -0
  109. package/tests/scores/electric.js +93 -0
  110. package/tests/scores/electric.webp +0 -0
  111. package/tests/scores/falseta.js +53 -0
  112. package/tests/scores/falseta.webp +0 -0
  113. package/tests/scores/fugue.js +433 -0
  114. package/tests/scores/guitar.js +34 -0
  115. package/tests/scores/index.html +48 -0
  116. package/tests/scores/kesh.js +171 -0
  117. package/tests/scores/kesh.webp +0 -0
  118. package/tests/scores/prelude.js +90 -0
  119. package/tests/scores/prelude.webp +0 -0
  120. package/tests/scores/quartertones.js +83 -0
  121. package/tests/scores/quartertones.webp +0 -0
  122. package/tests/scores/saints.js +85 -0
  123. package/tests/scores/saints.webp +0 -0
  124. package/tests/scores/sumer.js +139 -0
  125. package/tests/scores/sumer.webp +0 -0
  126. package/tests/scores/viewer.css +132 -0
  127. package/tests/scores/viewer.js +150 -0
@@ -0,0 +1,171 @@
1
+ // The Kesh Jig, with bowing, cuts and alternate endings. Publication projects this same score into the flute part.
2
+ (() => {
3
+ const title = 'The Kesh Jig';
4
+ const credit = 'Traditional Irish jig · Fiddle, flute and cello';
5
+ const intro =
6
+ 'The fiddle leads strain A. The flute counts its rest, reads the fiddle’s second ending as a cue, then joins at B. Print either edition.';
7
+ const choices = ['Full score', 'Flute part'];
8
+ const control = 'Edition';
9
+
10
+ // A pair of dotted-quarter beats per bar. A chord can change on either beat.
11
+ const strains = [
12
+ [
13
+ ['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
14
+ ['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
15
+ ['E5/8, D5, D5', 'G5/8, D5, D5', 'G'],
16
+ ['E5/8, D5, B4', 'D5/8, B4, A4', '', 'D'],
17
+ ['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
18
+ ['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
19
+ ['E5/8, D5, D5', 'G5/8, D5, B4', 'G'],
20
+ ['A4/8, G4, F#4', 'G4/q, D4/8', 'D', 'G'],
21
+ ['A4/8, G4, F#4', 'G4/q, A4/8', 'D', 'G'],
22
+ ],
23
+ [
24
+ ['B4/q, B4/8', 'D5/8, B4, D5', 'G'],
25
+ ['E5/8, G5, E5', 'D5/8, B4, G4', 'C', 'G'],
26
+ ['B4/q, B4/8', 'D5/8, B4, G4'],
27
+ ['A4/8, B4, A4', 'A4/8, G4, A4', 'Am'],
28
+ ['B4/8, A4, B4', 'D5/8, B4, D5', 'G'],
29
+ ['E5/8, G5, E5', 'D5/8, B4, D5', 'C', 'G'],
30
+ ['E5/q.', 'A5/8, G5, A5', 'C', 'D'],
31
+ ['B5/8, G5, G5', 'G5/q, A4/8', 'G'],
32
+ ['B5/8, G5, G5', 'G5/q.', 'G'],
33
+ ],
34
+ ];
35
+
36
+ /** Build the native marks in the factory that owns this particular score or cue. */
37
+ function fiddleMarks({ chord, cut }, note, builder) {
38
+ const f = builder.getFactory();
39
+ if (chord) note.addModifier(f.ChordSymbol().addText(chord));
40
+ if (cut) {
41
+ const grace = f.GraceNote({ keys: [cut], duration: '8', slash: true });
42
+ note.addModifier(f.GraceNoteGroup({ notes: [grace], slur: true }));
43
+ }
44
+ }
45
+
46
+ /** Keep the printed harmony and bow marks attached to the beat that owns them. */
47
+ function fiddleStrain(bars, strain, spans) {
48
+ return bars.map(([first, second, chord, change], bar) => {
49
+ const beats = [first.split(', '), second.split(', ')];
50
+ const id = (beat, i) => ['bow', strain, bar, beat, i].join('-');
51
+ if (bar === 2 || bar === 6) {
52
+ const beat = beats[0].length === 3 ? 0 : 1;
53
+ spans.push({ id: id(beat, 0), kind: 'slur', from: id(beat, 0), to: id(beat, 2) });
54
+ }
55
+ if (bar >= 7)
56
+ spans.push({
57
+ id: 'ending-' + strain + '-' + bar,
58
+ kind: 'volta',
59
+ text: bar === 7 ? '1.' : '2.',
60
+ from: id(0, 0),
61
+ to: id(1, beats[1].length - 1),
62
+ });
63
+ return beats
64
+ .flatMap((notes, beat) =>
65
+ notes.map((token, i) => {
66
+ const marks = ['id="' + id(beat, i) + '"'];
67
+ const harmony = beat === 0 ? chord : change;
68
+ if (i === 0 && harmony) marks.push('chord="' + harmony + '"');
69
+ if (beat === 0 && i === 1 && (bar === 0 || bar === 4 || bar === 8))
70
+ marks.push('cut="' + (strain ? 'd/5' : 'b/4') + '"');
71
+ return token + '[' + marks.join(',') + ']';
72
+ })
73
+ )
74
+ .join(', ');
75
+ });
76
+ }
77
+ const flute = [
78
+ 'G4/q., B4/q.',
79
+ 'C5/q., B4/q.',
80
+ 'G4/q., B4/q.',
81
+ 'E5/q., D5/q.',
82
+ 'G4/q., B4/q.',
83
+ 'C5/q., B4/q.',
84
+ 'G4/q., F#5/q.',
85
+ 'G5/q., A4/q.',
86
+ 'G5/q., G4/q.',
87
+ ];
88
+ const roots = [
89
+ 'G2',
90
+ 'D3',
91
+ 'G2',
92
+ 'D3',
93
+ 'G2',
94
+ 'D3',
95
+ 'G2',
96
+ 'D3',
97
+ 'D3',
98
+ 'G2',
99
+ 'C3',
100
+ 'G2',
101
+ 'A2',
102
+ 'G2',
103
+ 'C3',
104
+ 'D3',
105
+ 'G2',
106
+ 'G2',
107
+ ];
108
+
109
+ /** The cue belongs to the printed flute view. Its performing staff still rests through the second ending of A. */
110
+ function publication(choice, VF) {
111
+ const staff = (id, name, clef, bars) => ({
112
+ id,
113
+ name,
114
+ shortName: name.slice(0, 2) + '.',
115
+ clef,
116
+ key: 'G',
117
+ time: '6/8',
118
+ measures: bars.map((notes) => ({ voices: [{ notes, autoBeam: true }] })),
119
+ });
120
+ // A whole-bar rest has the duration of this 6/8 measure and no attached dot.
121
+ // This lets Publication collect silent bars into a counted rest before the cue.
122
+ const silence = [{ keys: ['d/5'], duration: 'wr', durationOverride: new VF.Fraction(6, 8) }];
123
+ const spans = [];
124
+ const melody = strains.flatMap((bars, i) => fiddleStrain(bars, i, spans));
125
+ const spec = {
126
+ accidentals: 'key-aware',
127
+ continuous: {
128
+ measureNumbers: true,
129
+ compressRests: true,
130
+ spans,
131
+ boundaries: [
132
+ { measure: 1, rehearsal: 'A', repeatStart: true },
133
+ { measure: 8, repeatEnd: true },
134
+ { measure: 10, rehearsal: 'B', repeatStart: true, breakBefore: 'force' },
135
+ { measure: 17, repeatEnd: true },
136
+ ],
137
+ },
138
+ staves: [
139
+ staff('vn', 'Fiddle', 'treble', melody),
140
+ staff('fl', 'Flute', 'treble', [...Array(9).fill(silence), ...flute]),
141
+ staff(
142
+ 'vc',
143
+ 'Cello',
144
+ 'bass',
145
+ roots.map((root, i) => root + '/q., ' + (i === 17 ? 'G2' : i % 2 ? 'A2' : 'D3') + '/q.')
146
+ ),
147
+ ],
148
+ };
149
+ const part = choice === 'Flute part';
150
+ return {
151
+ spec,
152
+ options: {
153
+ paper: 'A4',
154
+ noteHooks: [fiddleMarks],
155
+ title,
156
+ subtitle: part ? 'Flute part' : 'Fiddle, flute and cello',
157
+ header: title,
158
+ staffSize: part ? 8 : 6.5,
159
+ ...(part
160
+ ? {
161
+ staves: ['fl'],
162
+ systemBreaks: [14],
163
+ regions: [{ kind: 'cue', staff: 'vn', measure: 9, label: 'Fiddle cue' }],
164
+ }
165
+ : { systemBreaks: [5, 10, 14] }),
166
+ },
167
+ };
168
+ }
169
+
170
+ window.FeaturedScores.kesh = { title, credit, intro, choices, control, publication };
171
+ })();
Binary file
@@ -0,0 +1,90 @@
1
+ // BWV 846, bars 1–8. Editorial hand distribution follows the existing gallery arrangement.
2
+ (() => {
3
+ const title = 'Prelude in C major';
4
+ const credit = 'Johann Sebastian Bach · The Well-Tempered Clavier, BWV 846';
5
+ const intro =
6
+ 'Andante, legato · ♩ = 72. Follow the first arpeggio from the bass staff into the treble. Select a note and narrow the page to follow the same attack after reflow.';
7
+ const focus = 'arp-0-1';
8
+ const action = 'Inspect the arpeggio';
9
+ const harmony = [
10
+ ['c/4', 'e/4', 'g/4', 'c/5', 'e/5'],
11
+ ['c/4', 'd/4', 'a/4', 'd/5', 'f/5'],
12
+ ['b/3', 'd/4', 'g/4', 'd/5', 'f/5'],
13
+ ['c/4', 'e/4', 'g/4', 'c/5', 'e/5'],
14
+ ['c/4', 'e/4', 'a/4', 'e/5', 'a/5'],
15
+ ['c/4', 'd/4', 'f#/4', 'a/4', 'd/5'],
16
+ ['b/3', 'd/4', 'g/4', 'd/5', 'g/5'],
17
+ ['b/3', 'c/4', 'e/4', 'g/4', 'c/5'],
18
+ ];
19
+
20
+ function create(VF, score) {
21
+ const measures = harmony.map(([bass, inner, a, b, c], m) => {
22
+ const half = [bass, inner, a, b, c, a, b, c];
23
+ const notes = [...half, ...half].map((key, i) => ({
24
+ id: 'arp-' + m + '-' + i,
25
+ stave: i % 8 < 2 ? 'lh' : 'rh',
26
+ note: { keys: [key], clef: i % 8 < 2 ? 'bass' : 'treble', duration: '16', stemDirection: i % 8 < 2 ? 1 : -1 },
27
+ }));
28
+ return { voices: [{ notes }] };
29
+ });
30
+ const dynamics = ['p', '', 'mf', 'p', 'mp', '', 'mf', 'p'];
31
+ return {
32
+ spec: {
33
+ // Optical spacing fits two evenly pulsed arpeggios per line at a reading width.
34
+ system: { spaceBetweenStaves: 8, details: { spacing: { mode: 'optical' } } },
35
+ staves: [
36
+ { id: 'rh', name: 'Piano', shortName: '', measures },
37
+ {
38
+ id: 'lh',
39
+ clef: 'bass',
40
+ // Keep the space between the hands free for their shared beams.
41
+ measures: dynamics.map((text) => ({
42
+ voices: [
43
+ {
44
+ notes: [
45
+ text
46
+ ? score.make.textDynamics({ text, line: 10, duration: 'w' })
47
+ : score.make.ghostNote({ duration: 'w' }),
48
+ ],
49
+ },
50
+ ],
51
+ })),
52
+ },
53
+ ],
54
+ continuous: {
55
+ boundaries: [3, 5, 7].map((measure) => ({ measure, breakBefore: 'force' })),
56
+ groups: [{ first: 'rh', last: 'lh', type: 'brace', barlines: true }],
57
+ },
58
+ },
59
+ decorate(c) {
60
+ for (const [m] of harmony.entries())
61
+ for (let i = 0; i < 16; i += 4) {
62
+ const group = [0, 1, 2, 3].map((j) => c.getNote('arp-' + m + '-' + (i + j)));
63
+ score.beam(group, { autoStem: false });
64
+ const beam = group[0].getBeam();
65
+ beam.renderOptions.flatBeams = i % 8 === 4;
66
+ beam.renderOptions.minSlope = -0.035;
67
+ beam.renderOptions.maxSlope = 0.035;
68
+ }
69
+ c.staves[0][0].setTempo({ name: 'Andante, legato', duration: 'q', bpm: 72 }, -22);
70
+ c.getNote('arp-5-2').addModifier(score.make.accidental({ type: '#' }));
71
+ c.getNote('arp-2-4').addModifier(score.make.articulation({ type: 'accent', position: 'above' }));
72
+ c.getNote('arp-3-4').addModifier(score.make.articulation({ type: 'tenuto', position: 'above' }));
73
+ // The wedges follow the bass-staff notes in the first half of each measure.
74
+ for (const [m, type] of [
75
+ [1, VF.StaveHairpin.type.CRESC],
76
+ [2, VF.StaveHairpin.type.DECRESC],
77
+ ]) {
78
+ score.make.hairpin({
79
+ from: c.getNote('arp-' + m + '-0'),
80
+ to: c.getNote('arp-' + m + '-8'),
81
+ type,
82
+ options: { leftShiftPx: m === 2 ? 30 : 0, yShift: -6, height: 7 },
83
+ });
84
+ }
85
+ },
86
+ };
87
+ }
88
+
89
+ window.FeaturedScores.prelude = { title, credit, intro, focus, action, create };
90
+ })();
Binary file
@@ -0,0 +1,83 @@
1
+ // Narrow Steps. The same 5/8 viola phrase written with explicit signs and with an ordered signature.
2
+ (() => {
3
+ const title = 'Narrow Steps';
4
+ const credit = 'Example piece · Solo viola in 24 equal divisions of the octave';
5
+ const intro =
6
+ 'Read the motif twice. In the second phrase the signature raises D and lowers E by a quarter tone. The natural cancels the raised D. Parentheses remind the player of the lowered E.';
7
+ const focus = 'viola-3-2';
8
+ const action = 'Find the cancellation';
9
+ const motif = [
10
+ [
11
+ ['d/4', '+'],
12
+ ['e/4', 'd'],
13
+ ['d/4', 'n'],
14
+ ['e/4', 'd'],
15
+ ],
16
+ [
17
+ ['f/4', 'n'],
18
+ ['e/4', 'd'],
19
+ ['d/4', '+'],
20
+ ['c/4', 'n'],
21
+ ],
22
+ [
23
+ ['c/4', 'n'],
24
+ ['d/4', '+'],
25
+ ['e/4', 'd'],
26
+ ['d/4', '+'],
27
+ ],
28
+ ];
29
+ function create(VF, score) {
30
+ const measures = [...motif, ...motif].map((bar, m) => ({
31
+ voices: [
32
+ {
33
+ autoBeam: true,
34
+ notes: bar.map(([key, sign], i) => ({
35
+ id: 'viola-' + m + '-' + i,
36
+ note: {
37
+ keys: [key],
38
+ duration: i === 3 ? 'q' : '8',
39
+ clef: 'alto',
40
+ notation: [
41
+ {
42
+ kind: 'accidental',
43
+ id: sign,
44
+ label: { '+': 'quarter sharp', d: 'quarter flat', n: 'natural' }[sign],
45
+ },
46
+ ],
47
+ },
48
+ })),
49
+ },
50
+ ],
51
+ }));
52
+ return {
53
+ spec: {
54
+ staves: [{ id: 'Viola', clef: 'alto', time: '5/8', measures }],
55
+ continuous: { boundaries: [{ measure: 4, breakBefore: 'force' }] },
56
+ },
57
+ decorate(c) {
58
+ for (let m = 0; m < 6; m++) {
59
+ const signed = m >= 3;
60
+ const state = new VF.WrittenAccidentalState(signed ? { d: '+', e: 'd' } : {});
61
+ motif[m % 3].forEach(([key, sign], i) => {
62
+ const courtesy = m === 3 && i === 3;
63
+ const printed = state.sign(key, sign, courtesy);
64
+ if (printed) {
65
+ const mark = score.make.accidental({ type: printed });
66
+ c.getNote('viola-' + m + '-' + i).addModifier(courtesy ? mark.setAsCautionary() : mark);
67
+ }
68
+ });
69
+ // Repeat the two-sign signature at each signed bar so it survives any mobile line break.
70
+ if (signed)
71
+ c.staves[m][0].addModifier(
72
+ new VF.KeySignature('C').setOrdered([
73
+ { type: '+', line: 1.5 },
74
+ { type: 'd', line: 1 },
75
+ ])
76
+ );
77
+ }
78
+ },
79
+ };
80
+ }
81
+
82
+ window.FeaturedScores.quartertones = { title, credit, intro, focus, action, create };
83
+ })();
Binary file
@@ -0,0 +1,85 @@
1
+ // One melody, two harmonic readings. Event IDs keep the reader on the same syllable.
2
+ (() => {
3
+ const title = 'When the Saints Go Marching In';
4
+ const credit = 'Traditional African American spiritual · Petaluma lead sheet';
5
+ const intro =
6
+ 'Follow the held “in.” Compare the traditional dominant with the D♭7(♭9) turnaround, then narrow the page to carry the lyric across a system.';
7
+ const choices = ['Reharmonized', 'Traditional'];
8
+ const control = 'Harmony';
9
+ const focus = 'v6-0';
10
+ const fonts = ['Petaluma', 'Academico'];
11
+
12
+ // The opening pickup and final quarter together complete a bar.
13
+ const bars = [
14
+ ['C4/q, E4, F4', 'Oh when the', '', ''],
15
+ ['G4/w', 'saints', 'C', 'C:6/9'],
16
+ ['B4/q/r, C4/q, E4, F4', '_ go march- ing', 'C', 'Am:7'],
17
+ ['G4/w', 'in', 'C', 'Dm:11'],
18
+ ['B4/q/r, C4/q, E4, F4', '_ Oh when the', 'C', 'G:13'],
19
+ ['G4/q, E4, C4, E4', 'saints go march- ing', 'C', 'C:maj9'],
20
+ ['D4/w', 'in', 'G:7', 'Am:11'],
21
+ ['D4/w', '', 'G:7', 'D:9'],
22
+ ['B4/q/r, E4/q, E4, D4', '_ Oh Lord I', 'G:7', 'G:13'],
23
+ ['C4/h, C4/q, E4', 'want to be', 'C', 'Gm:13'],
24
+ ['G4/h, G4/q, G4', 'in that num-', 'C:7', 'C:9'],
25
+ ['F4/w', 'ber', 'F', 'F:maj9'],
26
+ ['B4/q/r, C4/q, E4, F4', '_ Oh when the', 'F', 'Fm:maj7'],
27
+ ['G4/h, E4/q, C4', 'saints go march-', 'C', 'Em:7'],
28
+ ['D4/w', 'ing', 'G:7', 'Db:7b9'],
29
+ ['C4/w', 'in', 'C', 'C:6/9'],
30
+ ['C4/q', '', '', ''],
31
+ ];
32
+
33
+ function create(VF, score, choice) {
34
+ const measures = bars.map(([music], m) => ({
35
+ span: m === 0 ? '3/4' : m === 16 ? '1/4' : undefined,
36
+ voices: [
37
+ {
38
+ notes: music
39
+ .split(',')
40
+ .map((token, i) => token.trim() + '[id="v' + m + '-' + i + '"]')
41
+ .join(', '),
42
+ },
43
+ ],
44
+ }));
45
+ const heldBars = [6, 15];
46
+ const spans = heldBars.flatMap((m) =>
47
+ ['lyric', 'tie'].map((kind) => ({
48
+ id: kind + m,
49
+ kind,
50
+ from: 'v' + m + '-0',
51
+ to: 'v' + (m + 1) + '-0',
52
+ ...(kind === 'lyric' ? { syllableId: 'held-in-' + m } : {}),
53
+ }))
54
+ );
55
+ return {
56
+ spec: { staves: [{ id: 'Voice', time: '4/4', measures }], continuous: { spans } },
57
+ decorate(composition) {
58
+ bars.forEach((bar, m) => {
59
+ const harmony = bar[choice === 'Traditional' ? 2 : 3];
60
+ if (harmony) {
61
+ const [root, extension] = harmony.split(':');
62
+ const symbol = score.make.chordSymbol().addGlyphOrText(root);
63
+ if (extension)
64
+ symbol.addGlyphOrText(extension, { symbolModifier: VF.ChordSymbol.symbolModifiers.SUPERSCRIPT });
65
+ composition.getNote('v' + m + '-0').addModifier(symbol);
66
+ }
67
+ const syllables = bar[1]
68
+ .split(' ')
69
+ .flatMap((text, i) =>
70
+ text && text !== '_' ? [{ text, note: composition.getNote('v' + m + '-' + i) }] : []
71
+ );
72
+ if (syllables.length) {
73
+ // A single verse line sits below the lowest pickup. Hold the vowel across the next bar.
74
+ const words = composition.systems[m].getPhraseLayout().addVerse(composition.staves[m][0], syllables, {
75
+ baselineSpaces: 7.5,
76
+ });
77
+ if (heldBars.includes(m)) words[0].setAttribute('id', 'held-in-' + m);
78
+ }
79
+ });
80
+ },
81
+ };
82
+ }
83
+
84
+ window.FeaturedScores.saints = { title, credit, intro, choices, control, focus, fonts, create };
85
+ })();
Binary file
@@ -0,0 +1,139 @@
1
+ // Performing edition of the Reading rota, Harley MS 978, fol. 11v.
2
+ // Modern 6/8 divides the opening cross (the next singer's cue) at two bars.
3
+ (() => {
4
+ const title = 'Sumer is icumen in';
5
+ const credit = 'Anonymous · English rota, 13th century';
6
+ const intro =
7
+ 'Enter two bars after the previous singer. Read one line alone, then reveal the four overlapping entries and the two repeating bass parts, the pes.';
8
+ const choices = ['Singer 1', 'Full ensemble', 'Singer 2', 'Singer 3', 'Singer 4', 'Pes 1', 'Pes 2'];
9
+ const control = 'Vocal part';
10
+
11
+ // Each pair contains a bar of music and its syllables. Underscores carry a vowel or mark a rest.
12
+ const tune = [
13
+ ['F5/q, E5/8, D5/q, E5/8', 'Su- mer is i-'],
14
+ ['F5/q, F5/8, E5/8, D5, C5', 'cum- en in _ _'],
15
+ ['A4/q, A4/8, Bb4/q, G4/8', 'Lhu- de sing cuc-'],
16
+ ['A4/q., B4/q/r.', 'cu _'],
17
+ ['F4/q, A4/8, G4/q, Bb4/8', 'Grow- eth sed and'],
18
+ ['A4/q, A4/8, G4/q, F4/8', 'blow- eth med and'],
19
+ ['A4/q, C5/8, D5/q, D5/8', 'springth the wu- de'],
20
+ ['C5/q., B4/q/r.', 'nu _'],
21
+ ['F5/q., D5/q.', 'Sing cuc-'],
22
+ ['F5/q., B4/q/r.', 'cu _'],
23
+ ['C5/q, A4/8, Bb4/q, G4/8', 'A- we ble- teth'],
24
+ ['A4/q, C5/8, Bb4/q, A4/8', 'af- ter lomb _'],
25
+ ['F4/q, A4/8, G4/q, E4/8', 'Lhouth af- ter calve'],
26
+ ['F4/q., B4/q/r.', 'cu _'],
27
+ ['A4/q, A4/8, G4/q, Bb4/8', 'Bul- luc ster- teth'],
28
+ ['C5/q, C5/8, D5/q, E5/8', 'buck- e ver- teth'],
29
+ ['F5/q, E5/8, D5/q, E5/8', 'mu- rie sing cuc-'],
30
+ ['F5/q., B4/q/r.', 'cu _'],
31
+ ['C5/q., D5/q.', 'Cuc- cu'],
32
+ ['C5/q., Bb4/q, A4/8', 'cuc- cu _'],
33
+ ['F4/q, A4/8, Bb4/q, G4/8', 'Wel sing- es thu'],
34
+ ['A4/q., Bb4/q, C5/8', 'cuc- cu _'],
35
+ ['A4/q, C5/8, G4/q, E4/8', 'Ne swik thu na-ver'],
36
+ ['F4/q., B4/q/r.', 'nu _'],
37
+ ];
38
+ const bass = [
39
+ ['F3/q., G3/q.', 'Sing cuc-'],
40
+ ['F3/q., G3/q, A3/8', 'cu nu _'],
41
+ ['C4/q., Bb3/q.', 'Sing cuc-'],
42
+ ['C4/q., D3/q/r.', 'cu _'],
43
+ ];
44
+ const silence = ['B4/h/r.', '_'];
45
+
46
+ /** Starting and ending rests retain identical bar numbers in each singer's part. */
47
+ function create(VF, score, choice) {
48
+ const verses = [];
49
+ const staves = [];
50
+ const spans = [];
51
+ for (const [voice, name] of ['Singer 1', 'Singer 2', 'Singer 3', 'Singer 4', 'Pes 1', 'Pes 2'].entries()) {
52
+ if (choice !== 'Full ensemble' && choice !== name) continue;
53
+ const id = 'part' + voice;
54
+ // The melismas and swell travel with the tune at each successive entrance.
55
+ if (voice < 4) {
56
+ const anchor = (bar, note) => [id, voice * 2 + bar, note].join('-');
57
+ for (const [bar, first, last] of [
58
+ [1, 2, 4],
59
+ [11, 2, 3],
60
+ [19, 1, 2],
61
+ ]) {
62
+ spans.push({ id: id + '-melisma-' + bar, kind: 'slur', from: anchor(bar, first), to: anchor(bar, last) });
63
+ }
64
+ spans.push({ id: id + '-swell', kind: 'crescendo', side: 'above', from: anchor(4, 0), to: anchor(5, 3) });
65
+ }
66
+ const measures = Array.from({ length: tune.length + 6 }, (_, m) => {
67
+ const [music, text] = voice < 4 ? (tune[m - voice * 2] ?? silence) : bass[(m + (voice - 4) * 2) % 4];
68
+ const syllables = [];
69
+ const notes = music
70
+ .split(',')
71
+ .map((token, n) => {
72
+ const event = [id, m, n].join('-');
73
+ const syllable = text.split(' ')[n];
74
+ if (syllable && syllable !== '_') syllables.push([event, syllable]);
75
+ return token.trim() + '[id="' + event + '"]';
76
+ })
77
+ .join(', ');
78
+ if (syllables.length) verses.push({ m, staff: staves.length, syllables });
79
+ return { voices: [{ notes, autoBeam: true }] };
80
+ });
81
+ staves.push({
82
+ id,
83
+ name,
84
+ shortName: voice < 4 ? 'V' + (voice + 1) : name,
85
+ clef: voice < 4 ? 'treble' : 'bass',
86
+ key: 'F',
87
+ time: '6/8',
88
+ measures,
89
+ });
90
+ }
91
+ return {
92
+ spec: { staves, accidentals: 'key-aware', continuous: { measureNumbers: true, compressRests: true, spans } },
93
+ decorate(c) {
94
+ c.staves[0][0].setTempo({ name: 'With a lilt', duration: 'q', dots: 1, bpm: 76 }, -35);
95
+ // Dynamics sit above a singer's staff to leave the words and melismas legible below.
96
+ for (const { id } of staves) {
97
+ const voice = Number(id.slice(4));
98
+ const note = (bar, i = 0) => c.getNote([id, bar + (voice < 4 ? 2 * voice : 0), i].join('-'));
99
+ const dynamic = (bar, text) =>
100
+ note(bar).addModifier(
101
+ score.make
102
+ .annotation({
103
+ text: [...text].map((letter) => VF.TextDynamics.GLYPHS[letter]).join(''),
104
+ vJustify: 'top',
105
+ })
106
+ .setFont('Bravura', 24)
107
+ .setYShift(-6)
108
+ );
109
+ if (voice >= 4) {
110
+ dynamic(0, 'p');
111
+ for (let bar = 0; bar < 30; bar += 4)
112
+ note(bar).addModifier(score.make.articulation({ type: 'tenuto', position: 'above' }));
113
+ continue;
114
+ }
115
+ dynamic(0, 'mp');
116
+ dynamic(6, 'mf');
117
+ dynamic(18, 'p');
118
+ for (const bar of [2, 8, 16])
119
+ note(bar, bar === 8 ? 1 : 3).addModifier(score.make.articulation({ type: 'accent', position: 'above' }));
120
+ for (const bar of [3, 13]) note(bar).addModifier(score.make.ornament('mordent'));
121
+ note(23).addModifier(score.make.articulation({ type: 'a@a', position: 'above' }));
122
+ }
123
+ for (const { m, staff, syllables } of verses) {
124
+ // Keep each singer’s line level through the lowest stems, including in the extracted part.
125
+ const stave = c.staves[m][staff];
126
+ const words = c.systems[m].getPhraseLayout().addVerse(
127
+ stave,
128
+ syllables.map(([id, text]) => ({ note: c.getNote(id), text })),
129
+ { baselineSpaces: 7.75 }
130
+ );
131
+ // Give the short syllables on consecutive eighth notes room to read as separate words.
132
+ words.forEach((word) => word.setConnectorPadding(stave.space(0.2)));
133
+ }
134
+ },
135
+ };
136
+ }
137
+
138
+ window.FeaturedScores.sumer = { title, credit, intro, choices, control, create };
139
+ })();
Binary file