vexflow 5.2.0 → 5.3.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.
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +2759 -1382
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +1814 -1227
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/accidental.js +10 -3
- package/build/esm/src/articulation.js +24 -6
- package/build/esm/src/beam.js +158 -28
- package/build/esm/src/bend.js +24 -19
- package/build/esm/src/curve.js +27 -53
- package/build/esm/src/dot.js +13 -4
- package/build/esm/src/easyscore/composition.js +40 -1
- package/build/esm/src/easyscore/policies.js +34 -6
- package/build/esm/src/element.js +4 -0
- package/build/esm/src/engravinggeometry.js +150 -0
- package/build/esm/src/engravingprofile.js +44 -0
- package/build/esm/src/factory.js +15 -7
- package/build/esm/src/formatter.js +9 -1
- package/build/esm/src/gracenote.js +43 -38
- package/build/esm/src/gracenotegroup.js +53 -56
- package/build/esm/src/index.js +2 -0
- package/build/esm/src/keysignature.js +1 -1
- package/build/esm/src/modifiercontext.js +11 -0
- package/build/esm/src/notehead.js +11 -6
- package/build/esm/src/ornament.js +38 -18
- package/build/esm/src/proportionalformatter.js +54 -6
- package/build/esm/src/stavenote.js +128 -115
- package/build/esm/src/stavetie.js +39 -7
- package/build/esm/src/stem.js +26 -11
- package/build/esm/src/tickcontext.js +19 -0
- package/build/esm/src/timesignature.js +5 -0
- package/build/esm/src/tuplet.js +57 -17
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +4 -0
- package/build/esm/tests/bend_tests.js +14 -1
- package/build/esm/tests/curve_tests.js +14 -4
- package/build/esm/tests/demo_repertoire_tests.js +27 -0
- package/build/esm/tests/demos/drums.js +54 -0
- package/build/esm/tests/demos/electric.js +63 -0
- package/build/esm/tests/demos/greensleeves.js +90 -0
- package/build/esm/tests/demos/joy.js +61 -0
- package/build/esm/tests/demos/kesh.js +80 -0
- package/build/esm/tests/demos/prelude.js +59 -0
- package/build/esm/tests/demos/quartertones.js +50 -0
- package/build/esm/tests/demos/saints.js +65 -0
- package/build/esm/tests/engraving/score-layout.mjs +75 -0
- package/build/esm/tests/engraving/score-persistence.mjs +262 -0
- package/build/esm/tests/engraving/studies.mjs +279 -0
- package/build/esm/tests/formatter_tests.js +10 -1
- package/build/esm/tests/index.js +1 -0
- package/build/esm/tests/node/audit-dependencies-tests.mjs +42 -0
- package/build/esm/tests/node/easyscore-tests.mjs +71 -0
- package/build/esm/tests/node/engraving-layout-tests.mjs +449 -0
- package/build/esm/tests/node/local-engraving-tests.mjs +128 -0
- package/build/esm/tests/node/proportional-spacing-tests.mjs +64 -0
- package/build/esm/tests/node/rendering-tests.mjs +6 -2
- package/build/esm/tests/threevoice_tests.js +11 -1
- package/build/esm/tests/vexflow_test_helpers.js +19 -10
- package/build/esm/tools/audit-dependencies.mjs +61 -0
- package/build/esm/tools/score-fixtures.mjs +23 -6
- package/build/types/src/accidental.d.ts +4 -0
- package/build/types/src/articulation.d.ts +6 -1
- package/build/types/src/beam.d.ts +14 -0
- package/build/types/src/curve.d.ts +9 -0
- package/build/types/src/dot.d.ts +5 -0
- package/build/types/src/easyscore/composition.d.ts +19 -0
- package/build/types/src/easyscore/policies.d.ts +1 -1
- package/build/types/src/element.d.ts +2 -0
- package/build/types/src/engravinggeometry.d.ts +31 -0
- package/build/types/src/engravingprofile.d.ts +20 -0
- package/build/types/src/factory.d.ts +6 -1
- package/build/types/src/formatter.d.ts +3 -3
- package/build/types/src/gracenote.d.ts +7 -0
- package/build/types/src/gracenotegroup.d.ts +7 -2
- package/build/types/src/index.d.ts +2 -0
- package/build/types/src/modifiercontext.d.ts +4 -0
- package/build/types/src/notehead.d.ts +5 -0
- package/build/types/src/ornament.d.ts +7 -0
- package/build/types/src/proportionalformatter.d.ts +11 -2
- package/build/types/src/stavenote.d.ts +20 -2
- package/build/types/src/stavetie.d.ts +4 -0
- package/build/types/src/stem.d.ts +10 -1
- package/build/types/src/tickcontext.d.ts +5 -0
- package/build/types/src/timesignature.d.ts +2 -0
- package/build/types/src/tuplet.d.ts +5 -48
- package/build/types/src/vexflow.d.ts +4 -0
- package/changelog/CHANGELOG.md +17 -0
- package/package.json +7 -2
- package/tests/all.html +277 -0
- package/tests/demo_petzold_tests.ts +435 -0
- package/tests/demos/drums.ts +55 -0
- package/tests/demos/drums.webp +0 -0
- package/tests/demos/electric.ts +70 -0
- package/tests/demos/electric.webp +0 -0
- package/tests/demos/greensleeves.ts +97 -0
- package/tests/demos/greensleeves.webp +0 -0
- package/tests/demos/joy.ts +65 -0
- package/tests/demos/joy.webp +0 -0
- package/tests/demos/kesh.ts +86 -0
- package/tests/demos/kesh.webp +0 -0
- package/tests/demos/prelude.ts +65 -0
- package/tests/demos/prelude.webp +0 -0
- package/tests/demos/quartertones.ts +51 -0
- package/tests/demos/quartertones.webp +0 -0
- package/tests/demos/saints.ts +70 -0
- package/tests/demos/saints.webp +0 -0
- package/tests/flow.html +550 -239
- package/tests/fonts.css +493 -0
- package/tests/minuet.webp +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// The finale theme from Beethoven's Ninth Symphony, arranged here for two cellos.
|
|
2
|
+
import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
|
|
3
|
+
|
|
4
|
+
import { BarlineType, StaveHairpin } from '../../src/index';
|
|
5
|
+
|
|
6
|
+
/** Give the first cello the eight-bar period and the second a slower answering bass line. */
|
|
7
|
+
export function joy(options: TestOptions): void {
|
|
8
|
+
const f = VexFlowTests.makeFactory(options, 900, 435);
|
|
9
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
10
|
+
score.set({ clef: 'bass', time: '4/4' });
|
|
11
|
+
// F and C are sharp throughout, as indicated by the D major key signature.
|
|
12
|
+
const duet = [
|
|
13
|
+
['F3/q, F3, G3, A3', 'D3/h, A2'],
|
|
14
|
+
['A3/q, G3, F3, E3', 'F2/h, A2'],
|
|
15
|
+
['D3/q, D3, E3, F3', 'B2/h, G2'],
|
|
16
|
+
['F3/q., E3/8, E3/h', 'A2/w'],
|
|
17
|
+
['F3/q, F3, G3, A3', 'D3/h, A2'],
|
|
18
|
+
['A3/q, G3, F3, E3', 'F2/h, A2'],
|
|
19
|
+
['D3/q, D3, E3, F3', 'G2/h, A2'],
|
|
20
|
+
['E3/q., D3/8, D3/h', 'A2/h, D2'],
|
|
21
|
+
];
|
|
22
|
+
duet.forEach(([tune, bass], i) => {
|
|
23
|
+
const notes = score.notes(tune);
|
|
24
|
+
const system = f.System({
|
|
25
|
+
x: 24 + (i % 4) * 213,
|
|
26
|
+
y: 10 + Math.floor(i / 4) * 210,
|
|
27
|
+
width: 213,
|
|
28
|
+
spaceBetweenStaves: 10,
|
|
29
|
+
});
|
|
30
|
+
const voices = [score.voice(notes)];
|
|
31
|
+
// Give the two phrases different starting colors and a written destination for each swell.
|
|
32
|
+
if (i % 2 === 0) {
|
|
33
|
+
const dynamic = ['p', 'mf', 'mp', 'f'][i / 2];
|
|
34
|
+
voices.push(score.voice([score.make.textDynamics({ text: dynamic, duration: 'w', line: 10 })]));
|
|
35
|
+
}
|
|
36
|
+
const first = system.addStave({ voices });
|
|
37
|
+
const second = system.addStave({ voices: [score.voice(score.notes(bass))] });
|
|
38
|
+
if (i % 4 === 0) {
|
|
39
|
+
first.addClef('bass').addKeySignature('D');
|
|
40
|
+
second.addClef('bass').addKeySignature('D');
|
|
41
|
+
if (i === 0) {
|
|
42
|
+
first.addTimeSignature('4/4');
|
|
43
|
+
second.addTimeSignature('4/4');
|
|
44
|
+
}
|
|
45
|
+
system.addConnector('bracket');
|
|
46
|
+
}
|
|
47
|
+
if (i === 1 || i === 5) {
|
|
48
|
+
score.make.hairpin({
|
|
49
|
+
from: notes[0],
|
|
50
|
+
to: notes[3],
|
|
51
|
+
type: StaveHairpin.type.CRESC,
|
|
52
|
+
options: { height: 8, yShift: -21 },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (i === 0 || i === 4) notes[0].addModifier(score.make.articulation({ type: 'tenuto', position: 'above' }));
|
|
56
|
+
if (i === 3 || i === 7) score.make.curve({ from: notes[0], to: notes[1] });
|
|
57
|
+
if (i === 7) {
|
|
58
|
+
first.setEndBarType(BarlineType.END);
|
|
59
|
+
second.setEndBarType(BarlineType.END);
|
|
60
|
+
}
|
|
61
|
+
system.addConnector('singleRight');
|
|
62
|
+
});
|
|
63
|
+
f.draw();
|
|
64
|
+
options.assert.ok(true, 'Two cello parts aligned through the cadence');
|
|
65
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The Kesh Jig, arranged as a session chart with chord changes and alternate endings.
|
|
2
|
+
import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
|
|
3
|
+
|
|
4
|
+
import { BarlineType, VoltaType } from '../../src/index';
|
|
5
|
+
|
|
6
|
+
/** Each dotted-quarter beat has its own music and optional change of harmony. */
|
|
7
|
+
type JigBar = [firstBeat: string, secondBeat: string, chord: string, nextChord?: string];
|
|
8
|
+
|
|
9
|
+
/** Play each strain twice. The last eighth of each ending leads into the next strain or repeat. */
|
|
10
|
+
export function kesh(options: TestOptions): void {
|
|
11
|
+
const f = VexFlowTests.makeFactory(options, 900, 580);
|
|
12
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
13
|
+
score.set({ time: '6/8' });
|
|
14
|
+
// Use the same upright lettering for a change on either beat of the bar.
|
|
15
|
+
const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
|
|
16
|
+
// The McNeela chart suggests two changes within some bars and different pickups at the repeats.
|
|
17
|
+
const strains: JigBar[][] = [
|
|
18
|
+
[
|
|
19
|
+
['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
|
|
20
|
+
['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
|
|
21
|
+
['E5/8, D5, D5', 'G5/8, D5, D5', 'G'],
|
|
22
|
+
['E5/8, D5, B4', 'D5/8, B4, A4', '', 'D'],
|
|
23
|
+
['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
|
|
24
|
+
['A4/q, A4/8', 'A4/8, B4, D5', 'D'],
|
|
25
|
+
['E5/8, D5, D5', 'G5/8, D5, B4', 'G'],
|
|
26
|
+
['A4/8, G4, F4', 'G4/q, D4/8', 'D', 'G'],
|
|
27
|
+
['A4/8, G4, F4', 'G4/q, A4/8', 'D', 'G'],
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
['B4/q, B4/8', 'D5/8, B4, D5', 'G'],
|
|
31
|
+
['E5/8, G5, E5', 'D5/8, B4, G4', 'C', 'G'],
|
|
32
|
+
['B4/q, B4/8', 'D5/8, B4, G4', ''],
|
|
33
|
+
['A4/8, B4, A4', 'A4/8, G4, A4', 'Am'],
|
|
34
|
+
['B4/8, A4, B4', 'D5/8, B4, D5', 'G'],
|
|
35
|
+
['E5/8, G5, E5', 'D5/8, B4, D5', 'C', 'G'],
|
|
36
|
+
['E5/q.', 'A5/8, G5, A5', 'C', 'D'],
|
|
37
|
+
['B5/8, G5, G5', 'G5/q, A4/8', 'G'],
|
|
38
|
+
['B5/8, G5, G5', 'G5/q', 'G'],
|
|
39
|
+
],
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// The upbeat precedes the first repeat and shares a full measure with the shortened final bar.
|
|
43
|
+
const pickupWidth = 130;
|
|
44
|
+
const firstY = 36;
|
|
45
|
+
f.System({ x: 16, y: firstY, width: pickupWidth })
|
|
46
|
+
.addStave({ voices: [score.voice(score.notes('D4/8'), { time: '1/8' })] })
|
|
47
|
+
.addClef('treble')
|
|
48
|
+
.addKeySignature('G')
|
|
49
|
+
.addTimeSignature('6/8');
|
|
50
|
+
strains.forEach((bars, part) =>
|
|
51
|
+
bars.forEach(([firstBeat, secondBeat, chord, nextChord], i) => {
|
|
52
|
+
const beats = [score.notes(firstBeat), score.notes(secondBeat)];
|
|
53
|
+
const notes = beats.flat();
|
|
54
|
+
for (const beat of beats) {
|
|
55
|
+
if (beat.length === 3) score.beam(beat);
|
|
56
|
+
}
|
|
57
|
+
if (chord) beats[0][0].addModifier(score.make.chordSymbol(chordFont).addText(chord));
|
|
58
|
+
if (nextChord) beats[1][0].addModifier(score.make.chordSymbol(chordFont).addText(nextChord));
|
|
59
|
+
if (i === 0 || i === 4) {
|
|
60
|
+
const grace = score.make.graceNote({ keys: [part ? 'd/5' : 'b/4'], duration: '8', slash: true });
|
|
61
|
+
notes[1].addModifier(score.make.graceNoteGroup({ notes: [grace], slur: true }));
|
|
62
|
+
}
|
|
63
|
+
if (i === 2 || i === 6) {
|
|
64
|
+
const bow = beats[0].length === 3 ? beats[0] : beats[1];
|
|
65
|
+
score.make.curve({ from: bow[0], to: bow[2] });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const firstLine = i < 4;
|
|
69
|
+
const pickup = part === 0 && firstLine ? pickupWidth : 0;
|
|
70
|
+
const width = (868 - pickup) / (firstLine ? 4 : 5);
|
|
71
|
+
const x = 16 + pickup + (firstLine ? i : i - 4) * width;
|
|
72
|
+
const row = part * 2 + (firstLine ? 0 : 1);
|
|
73
|
+
const lastBar = part === 1 && i === 8;
|
|
74
|
+
const stave = f
|
|
75
|
+
.System({ x, y: firstY + row * 142, width })
|
|
76
|
+
.addStave({ voices: [score.voice(notes, { time: lastBar ? '5/8' : '6/8' })], options: { topTextPosition: 2 } });
|
|
77
|
+
if (i === 4 || (part === 1 && i === 0)) stave.addClef('treble').addKeySignature('G');
|
|
78
|
+
if (i === 0) stave.setBegBarType(BarlineType.REPEAT_BEGIN).setSection(part ? 'B' : 'A', 0);
|
|
79
|
+
if (i === 7) stave.setVoltaType(VoltaType.BEGIN_END, '1.', 0).setEndBarType(BarlineType.REPEAT_END);
|
|
80
|
+
if (i === 8) stave.setVoltaType(VoltaType.BEGIN, '2.', 0);
|
|
81
|
+
if (lastBar) stave.setEndBarType(BarlineType.END);
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
f.draw();
|
|
85
|
+
options.assert.ok(true, 'Accompanied A and B strains with first and second endings');
|
|
86
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// BWV 846 in an editorial two-hand distribution. A single voice moves between the staves.
|
|
2
|
+
import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
|
|
3
|
+
|
|
4
|
+
import { StaveHairpin, StemmableNote } from '../../src/index';
|
|
5
|
+
|
|
6
|
+
/** Group by the quarter-note pulse, preserving Bach's eight-note arpeggio in each half-bar. */
|
|
7
|
+
export function prelude(options: TestOptions): void {
|
|
8
|
+
const f = VexFlowTests.makeFactory(options, 900, 525);
|
|
9
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
10
|
+
const harmonies = [
|
|
11
|
+
['C4', 'E4', 'G4', 'C5', 'E5'],
|
|
12
|
+
['C4', 'D4', 'A4', 'D5', 'F5'],
|
|
13
|
+
['B3', 'D4', 'G4', 'D5', 'F5'],
|
|
14
|
+
['C4', 'E4', 'G4', 'C5', 'E5'],
|
|
15
|
+
];
|
|
16
|
+
harmonies.forEach(([bass, inner, a, b, c], i) => {
|
|
17
|
+
const system = f.System({
|
|
18
|
+
x: 24 + (i % 2) * 428,
|
|
19
|
+
y: 40 + Math.floor(i / 2) * 250,
|
|
20
|
+
width: 428,
|
|
21
|
+
spaceBetweenStaves: 9,
|
|
22
|
+
});
|
|
23
|
+
const treble = system.addStave({ voices: [] });
|
|
24
|
+
// Dynamics sit below the bass stave, leaving the space between the hands clear for the beams.
|
|
25
|
+
const dynamic = ['p', '', 'mf', 'p'][i];
|
|
26
|
+
const lower = system.addStave({
|
|
27
|
+
voices: dynamic ? [score.voice([score.make.textDynamics({ text: dynamic, line: 10, duration: 'w' })])] : [],
|
|
28
|
+
});
|
|
29
|
+
if (i % 2 === 0) {
|
|
30
|
+
treble.addClef('treble');
|
|
31
|
+
lower.addClef('bass');
|
|
32
|
+
system.addConnector('brace');
|
|
33
|
+
if (i === 0) {
|
|
34
|
+
treble.addTimeSignature('C').setTempo({ name: 'Andante, legato', duration: 'q', bpm: 72 }, -9);
|
|
35
|
+
lower.addTimeSignature('C');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const arpeggio: StemmableNote[] = [];
|
|
39
|
+
for (let half = 0; half < 2; half++) {
|
|
40
|
+
const left = score.notes(`${bass}/16, ${inner}`, { clef: 'bass', stem: 'up' });
|
|
41
|
+
const right = score.notes(`${a}/16, ${b}`, { stem: 'down' });
|
|
42
|
+
const answer = score.notes(`${c}/16, ${a}, ${b}, ${c}`, { stem: 'down' });
|
|
43
|
+
left.forEach((note) => note.setStave(lower));
|
|
44
|
+
[...right, ...answer].forEach((note) => note.setStave(treble));
|
|
45
|
+
score.beam([...left, ...right]);
|
|
46
|
+
score.beam(answer);
|
|
47
|
+
// Lean into the upper F at the dominant, then give the resolving E its full length.
|
|
48
|
+
if (half === 0 && i >= 2)
|
|
49
|
+
answer[0].addModifier(score.make.articulation({ type: i === 2 ? 'accent' : 'tenuto', position: 'above' }));
|
|
50
|
+
arpeggio.push(...left, ...right, ...answer);
|
|
51
|
+
}
|
|
52
|
+
if (i === 1 || i === 2) {
|
|
53
|
+
score.make.hairpin({
|
|
54
|
+
from: arpeggio[0],
|
|
55
|
+
to: arpeggio[8],
|
|
56
|
+
type: i === 1 ? StaveHairpin.type.CRESC : StaveHairpin.type.DECRESC,
|
|
57
|
+
options: { leftShiftPx: i === 2 ? 30 : 0, yShift: -6, height: 7 },
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
system.addVoices([score.voice(arpeggio)]);
|
|
61
|
+
system.addConnector('singleRight');
|
|
62
|
+
});
|
|
63
|
+
f.draw();
|
|
64
|
+
options.assert.ok(true, 'Both hands share a beam on beats one and three');
|
|
65
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Narrow Steps is an original unaccompanied viola miniature in 24 equal divisions of the octave.
|
|
2
|
+
import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
|
|
3
|
+
|
|
4
|
+
import { BarlineType, StaveHairpin } from '../../src/index';
|
|
5
|
+
|
|
6
|
+
/** Repeated letters let the listener follow a single pitch bending in quarter-tone steps. */
|
|
7
|
+
export function quartertones(options: TestOptions): void {
|
|
8
|
+
const f = VexFlowTests.makeFactory(options, 900, 340);
|
|
9
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
10
|
+
score.set({ time: '5/8', clef: 'alto' });
|
|
11
|
+
// Each mark belongs to one attack. Stein's half-sharp (+) and half-flat (d) are 50 cents.
|
|
12
|
+
const bars = [
|
|
13
|
+
{ music: 'D4/8, D4, E4, F4/q', signs: ['', '+', 'd', ''] },
|
|
14
|
+
{ music: 'F4/8, F4, G4, A4/q', signs: ['', '+', '', 'd'] },
|
|
15
|
+
{ music: 'A4/q., G4/q', signs: ['n', '+'] },
|
|
16
|
+
{ music: 'G4/8, G4, F4, E4/q', signs: ['', 'd', '+', ''] },
|
|
17
|
+
{ music: 'E4/8, E4, D4, C4/q', signs: ['', 'd', '+', '++'] },
|
|
18
|
+
{ music: 'D4/q., D4/q', signs: ['d', 'n'] },
|
|
19
|
+
];
|
|
20
|
+
bars.forEach(({ music, signs }, i) => {
|
|
21
|
+
const notes = score.notes(music);
|
|
22
|
+
signs.forEach((type, n) => {
|
|
23
|
+
if (!type) return;
|
|
24
|
+
const mark = score.make.accidental({ type });
|
|
25
|
+
if (i === 2 && n === 0) mark.setAsCautionary();
|
|
26
|
+
notes[n].addModifier(mark);
|
|
27
|
+
});
|
|
28
|
+
if (notes.length === 4) {
|
|
29
|
+
score.beam(notes.slice(0, 3));
|
|
30
|
+
score.make.curve({ from: notes[0], to: notes[2] });
|
|
31
|
+
}
|
|
32
|
+
if (i === 0 || i === 4)
|
|
33
|
+
score.make.hairpin({
|
|
34
|
+
from: notes[0],
|
|
35
|
+
to: notes[3],
|
|
36
|
+
type: i === 0 ? StaveHairpin.type.CRESC : StaveHairpin.type.DECRESC,
|
|
37
|
+
options: { height: 7, yShift: -4 },
|
|
38
|
+
});
|
|
39
|
+
const stave = f
|
|
40
|
+
.System({ x: 16 + (i % 3) * 288, y: 24 + Math.floor(i / 3) * 154, width: 288 })
|
|
41
|
+
.addStave({ voices: [score.voice(notes)] });
|
|
42
|
+
if (i % 3 === 0) stave.addClef('alto');
|
|
43
|
+
if (i === 0) stave.addTimeSignature('5/8').setTempo({ name: 'Sotto voce', duration: '8', bpm: 108 }, -4);
|
|
44
|
+
if (i === 5) {
|
|
45
|
+
notes[1].addModifier(score.make.articulation({ type: 'fermata', position: 'above' }));
|
|
46
|
+
stave.setEndBarType(BarlineType.END);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
f.draw();
|
|
50
|
+
options.assert.ok(true, 'Quarter-tone inflections in two phrases of three measures');
|
|
51
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// A New Orleans lead-sheet chorus. EasyScore supplies the melody; native modifiers carry the words and changes.
|
|
2
|
+
import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
|
|
3
|
+
|
|
4
|
+
import { BarlineType, ChordSymbol, StemmableNote } from '../../src/index';
|
|
5
|
+
|
|
6
|
+
/** Render a compact, sixteen-bar setting of the traditional refrain, with its three-note pickup. */
|
|
7
|
+
export function saints(options: TestOptions): void {
|
|
8
|
+
const factory = VexFlowTests.makeFactory(options, 900, 540);
|
|
9
|
+
const score = factory.EasyScore({ throwOnError: true });
|
|
10
|
+
const bars = [
|
|
11
|
+
['G4/w', 'saints', 'C:6/9'],
|
|
12
|
+
['B4/q/r, C4/q, E4, F4', '|go|march-|ing', 'Am:7'],
|
|
13
|
+
['G4/w', 'in', 'Dm:11'],
|
|
14
|
+
['B4/q/r, C4/q, E4, F4', '|Oh|when|the', 'G:13'],
|
|
15
|
+
['G4/q, E4, C4, E4', 'saints|go|march-|ing', 'C:maj9'],
|
|
16
|
+
['D4/w', 'in', 'Am:11'],
|
|
17
|
+
['D4/w', '', 'D:9'],
|
|
18
|
+
['B4/q/r, E4/q, E4, D4', '|Oh|Lord,|I', 'G:13'],
|
|
19
|
+
['C4/h, C4/q, E4', 'want|to|be', 'Gm:13'],
|
|
20
|
+
['G4/h, G4/q, G4', 'in|that|num-', 'C:9'],
|
|
21
|
+
['F4/w', 'ber', 'F:maj9'],
|
|
22
|
+
['B4/q/r, C4/q, E4, F4', '|Oh|when|the', 'Fm:maj7'],
|
|
23
|
+
['G4/h, E4/q, C4', 'saints|go|march-', 'Em:7'],
|
|
24
|
+
['D4/w', 'ing', 'Db:7b9'],
|
|
25
|
+
['C4/w', 'in', 'C:6/9'],
|
|
26
|
+
['C4/q', '', ''],
|
|
27
|
+
];
|
|
28
|
+
// The first system includes a short anacrusis before its four complete measures.
|
|
29
|
+
const pickup = score.notes('C4/q, E4, F4');
|
|
30
|
+
const pickupLabels = ['Oh', 'when', 'the'];
|
|
31
|
+
pickup.forEach((note, i) =>
|
|
32
|
+
note.addModifier(factory.Annotation({ text: pickupLabels[i], vJustify: 'bottom' }).setTextBaseline(123))
|
|
33
|
+
);
|
|
34
|
+
factory
|
|
35
|
+
.System({ x: 10, y: 16, width: 180 })
|
|
36
|
+
.addStave({ voices: [score.voice(pickup, { time: '3/4' })] })
|
|
37
|
+
.addClef('treble')
|
|
38
|
+
.addTimeSignature('4/4');
|
|
39
|
+
|
|
40
|
+
let sustained: StemmableNote | undefined;
|
|
41
|
+
bars.forEach(([music, words, harmony], i) => {
|
|
42
|
+
const row = Math.floor(i / 4);
|
|
43
|
+
const column = i % 4;
|
|
44
|
+
const y = 16 + row * 130;
|
|
45
|
+
const width = row === 0 ? 174 : 219;
|
|
46
|
+
const notes = score.notes(music);
|
|
47
|
+
// Carry the sustained D and the final tonic across the barline without repeating a syllable.
|
|
48
|
+
if (i === 5 || i === 14) sustained = notes[0];
|
|
49
|
+
if ((i === 6 || i === 15) && sustained) score.make.tie({ from: sustained, to: notes[0] });
|
|
50
|
+
words.split('|').forEach((text, n) => {
|
|
51
|
+
if (text) notes[n].addModifier(factory.Annotation({ text, vJustify: 'bottom' }).setTextBaseline(y + 107));
|
|
52
|
+
});
|
|
53
|
+
// Split the chord into root and extension so Petaluma supplies proper accidental glyphs.
|
|
54
|
+
if (harmony) {
|
|
55
|
+
const [root, extension] = harmony.split(':');
|
|
56
|
+
const chord = factory
|
|
57
|
+
.ChordSymbol()
|
|
58
|
+
.addGlyphOrText(root)
|
|
59
|
+
.addGlyphOrText(extension, { symbolModifier: ChordSymbol.symbolModifiers.SUPERSCRIPT });
|
|
60
|
+
notes[0].addModifier(chord);
|
|
61
|
+
}
|
|
62
|
+
const stave = factory
|
|
63
|
+
.System({ x: (row === 0 ? 190 : 10) + column * width, y, width })
|
|
64
|
+
.addStave({ voices: [score.voice(notes, { time: i === 15 ? '1/4' : '4/4' })] });
|
|
65
|
+
if (column === 0 && row > 0) stave.addClef('treble');
|
|
66
|
+
if (i === bars.length - 1) stave.setEndBarType(BarlineType.END);
|
|
67
|
+
});
|
|
68
|
+
factory.draw();
|
|
69
|
+
options.assert.ok(true, 'Petaluma lead sheet with aligned lyrics');
|
|
70
|
+
}
|
|
Binary file
|