vexflow 5.1.2 → 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/README.md +7 -6
- 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 +5325 -1730
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +4228 -1545
- 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 +13 -3
- package/build/esm/src/articulation.js +51 -20
- package/build/esm/src/beam.js +170 -30
- package/build/esm/src/bend.js +24 -19
- package/build/esm/src/clef.js +3 -0
- package/build/esm/src/clefnote.js +5 -1
- package/build/esm/src/curve.js +27 -53
- package/build/esm/src/dot.js +14 -5
- package/build/esm/src/easyscore/composition.js +336 -0
- package/build/esm/src/easyscore/elementindex.js +81 -0
- package/build/esm/src/easyscore/elements.js +324 -0
- package/build/esm/src/easyscore/policies.js +97 -0
- package/build/esm/src/easyscore/rhythm.js +42 -0
- package/build/esm/src/easyscore.js +448 -26
- package/build/esm/src/element.js +17 -2
- package/build/esm/src/engravinggeometry.js +150 -0
- package/build/esm/src/engravingprofile.js +44 -0
- package/build/esm/src/factory.js +268 -64
- package/build/esm/src/formatter.js +40 -4
- 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 +10 -2
- package/build/esm/src/keysignote.js +2 -2
- package/build/esm/src/modifiercontext.js +11 -0
- package/build/esm/src/note.js +5 -0
- package/build/esm/src/notehead.js +11 -6
- package/build/esm/src/ornament.js +38 -18
- package/build/esm/src/parenthesis.js +1 -1
- package/build/esm/src/parser.js +6 -1
- package/build/esm/src/proportionalformatter.js +234 -0
- package/build/esm/src/registry.js +27 -0
- package/build/esm/src/sheet.js +20 -3
- package/build/esm/src/stave.js +9 -2
- package/build/esm/src/stavenote.js +140 -127
- package/build/esm/src/stavetie.js +39 -7
- package/build/esm/src/stem.js +26 -11
- package/build/esm/src/stemmablenote.js +6 -1
- package/build/esm/src/tickable.js +5 -0
- package/build/esm/src/tickcontext.js +19 -0
- package/build/esm/src/timesignature.js +5 -0
- package/build/esm/src/tuplet.js +60 -19
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +6 -1
- package/build/esm/tests/beam_tests.js +35 -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/easyscore_tests.js +40 -0
- package/build/esm/tests/easyscore_types.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 +51 -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-rendering-tests.mjs +332 -0
- package/build/esm/tests/node/easyscore-tests.mjs +1024 -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 +278 -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/easyscore-api-audit.mjs +58 -0
- package/build/esm/tools/easyscore-composition.mjs +62 -0
- package/build/esm/tools/easyscore-example.mjs +16 -0
- package/build/esm/tools/easyscore-families.mjs +61 -0
- package/build/esm/tools/easyscore-references-example.mjs +26 -0
- package/build/esm/tools/easyscore-rhythm.mjs +58 -0
- package/build/esm/tools/easyscore-structure.mjs +88 -0
- package/build/esm/tools/explorer/catalog/entries.mjs +6 -0
- package/build/esm/tools/explorer/catalog/expression.mjs +68 -0
- package/build/esm/tools/explorer/catalog/helpers.mjs +29 -0
- package/build/esm/tools/explorer/catalog/layout.mjs +109 -0
- package/build/esm/tools/explorer/catalog/notes.mjs +61 -0
- package/build/esm/tools/explorer/catalog/staves.mjs +85 -0
- package/build/esm/tools/explorer/catalog/strings.mjs +25 -0
- package/build/esm/tools/explorer/catalog.mjs +14 -0
- package/build/esm/tools/score-fixtures.mjs +23 -6
- package/build/types/src/accidental.d.ts +6 -0
- package/build/types/src/articulation.d.ts +12 -1
- package/build/types/src/beam.d.ts +16 -0
- package/build/types/src/clef.d.ts +2 -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 +126 -0
- package/build/types/src/easyscore/elementindex.d.ts +30 -0
- package/build/types/src/easyscore/elements.d.ts +156 -0
- package/build/types/src/easyscore/policies.d.ts +12 -0
- package/build/types/src/easyscore/rhythm.d.ts +9 -0
- package/build/types/src/easyscore.d.ts +153 -11
- package/build/types/src/element.d.ts +7 -1
- 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 +97 -9
- package/build/types/src/formatter.d.ts +7 -1
- 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/keysignature.d.ts +3 -0
- package/build/types/src/keysignote.d.ts +1 -1
- package/build/types/src/modifiercontext.d.ts +4 -0
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/notehead.d.ts +5 -0
- package/build/types/src/ornament.d.ts +7 -0
- package/build/types/src/parser.d.ts +5 -0
- package/build/types/src/proportionalformatter.d.ts +39 -0
- package/build/types/src/registry.d.ts +4 -0
- package/build/types/src/stave.d.ts +2 -0
- package/build/types/src/stavenote.d.ts +21 -3
- package/build/types/src/stavetie.d.ts +4 -0
- package/build/types/src/stem.d.ts +10 -1
- package/build/types/src/stemmablenote.d.ts +6 -1
- package/build/types/src/tickable.d.ts +2 -0
- 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 +6 -1
- package/changelog/CHANGELOG.md +52 -0
- package/package.json +13 -3
- 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,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
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
2
|
import { Articulation } from '../src/articulation.js';
|
|
3
3
|
import { EasyScore } from '../src/easyscore.js';
|
|
4
|
+
import { Factory } from '../src/factory.js';
|
|
4
5
|
import { FretHandFinger } from '../src/frethandfinger.js';
|
|
5
6
|
import { Modifier } from '../src/modifier.js';
|
|
6
7
|
import { Parenthesis } from '../src/parenthesis.js';
|
|
@@ -17,6 +18,7 @@ const EasyScoreTests = {
|
|
|
17
18
|
QUnit.test('Dots', dots);
|
|
18
19
|
QUnit.test('Types', types);
|
|
19
20
|
QUnit.test('Options', options);
|
|
21
|
+
QUnit.test('Automatic beam stem policy', beamStemPolicy);
|
|
20
22
|
const run = VexFlowTests.runTests;
|
|
21
23
|
run('Draw Basic', drawBasicTest);
|
|
22
24
|
run('Draw Different KeySignature', drawDiffKeysig);
|
|
@@ -486,3 +488,41 @@ function keys(options) {
|
|
|
486
488
|
}
|
|
487
489
|
VexFlowTests.register(EasyScoreTests);
|
|
488
490
|
export { EasyScoreTests };
|
|
491
|
+
function beamStemPolicy(assert) {
|
|
492
|
+
const factory = new Factory({ renderer: { elementId: null, width: 500, height: 200 } });
|
|
493
|
+
const score = factory.EasyScore();
|
|
494
|
+
const phrase = 'C4/8, D4, E4, F4, G4, A4, B4';
|
|
495
|
+
const directions = (notes) => notes.map((note) => note.getStemDirection());
|
|
496
|
+
const automatic = score.notes(phrase);
|
|
497
|
+
assert.equal(new Set(directions(automatic)).size, 2, 'Unbeamed phrase crosses stem boundary');
|
|
498
|
+
score.beam(automatic);
|
|
499
|
+
assert.ok(automatic.every((note) => note.getStemDirection() === Stem.UP), 'Group chooses up stems');
|
|
500
|
+
assert.ok(automatic.every((note) => note.isAutoStem()), 'Beaming retains automatic policy');
|
|
501
|
+
const extended = [...automatic, ...score.notes('C6/8, C6, C6, C6, C6, C6, C6, C6')];
|
|
502
|
+
score.beam(extended);
|
|
503
|
+
assert.ok(extended.every((note) => note.getStemDirection() === Stem.DOWN), 'Regrouping recalculates direction');
|
|
504
|
+
const explicit = score.notes(phrase, { stem: 'down' });
|
|
505
|
+
score.beam(explicit);
|
|
506
|
+
assert.ok(explicit.every((note) => note.getStemDirection() === Stem.DOWN && !note.isAutoStem()), 'Explicit voice stays down');
|
|
507
|
+
score.beam(explicit, { autoStem: true });
|
|
508
|
+
assert.ok(explicit.every((note) => note.getStemDirection() === Stem.UP), 'Explicit beam override selects group direction');
|
|
509
|
+
const pinned = score.notes('C4/8, D4[stem="down"], E4');
|
|
510
|
+
score.beam(pinned);
|
|
511
|
+
assert.deepEqual(directions(pinned), [Stem.DOWN, Stem.DOWN, Stem.DOWN], 'Automatic stems follow one explicit pitch');
|
|
512
|
+
assert.notOk(pinned[1].isAutoStem(), 'Per-note override stays explicit');
|
|
513
|
+
const manual = score.notes('C4/8, D4, E4');
|
|
514
|
+
manual[0].setStemDirection(Stem.DOWN);
|
|
515
|
+
score.beam(manual);
|
|
516
|
+
assert.deepEqual(directions(manual), [Stem.DOWN, Stem.DOWN, Stem.DOWN], 'Setter opts out of automatic direction');
|
|
517
|
+
const mixed = score.notes('C4/8[stem="up"], B4[stem="down"], D4');
|
|
518
|
+
const before = directions(mixed);
|
|
519
|
+
score.beam(mixed);
|
|
520
|
+
assert.deepEqual(directions(mixed), before, 'Conflicting explicit directions remain mixed');
|
|
521
|
+
const preserved = score.notes(phrase);
|
|
522
|
+
const individual = directions(preserved);
|
|
523
|
+
score.beam(preserved, { autoStem: false });
|
|
524
|
+
assert.deepEqual(directions(preserved), individual, 'Explicit false preserves per-note automatic directions');
|
|
525
|
+
const lowLevel = score.notes(phrase);
|
|
526
|
+
factory.Beam({ notes: lowLevel });
|
|
527
|
+
assert.deepEqual(directions(lowLevel), individual, 'Factory keeps its low-level direction-preserving default');
|
|
528
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Annotation, EasyScore, Fraction } from '../src/index.js';
|
|
11
|
+
export function easyScoreTypes() {
|
|
12
|
+
const score = EasyScore.create({ renderer: { elementId: 'score', width: 500, height: 240 } });
|
|
13
|
+
score.autoBeam(score.notes('C4/8, D4'), { groups: [new Fraction(2, 8)], autoStem: false });
|
|
14
|
+
score.make.tuplet({ notes: score.notes('C4/8, D4, E4'), options: { numNotes: 3, notesOccupied: 2 } });
|
|
15
|
+
score.make.hairpin({ type: 1 });
|
|
16
|
+
const composed = score.compose({
|
|
17
|
+
staves: [
|
|
18
|
+
{ id: 'staff', measures: [{ voices: [{ notes: [{ note: { keys: ['c/4'], duration: 'w' }, id: 'whole' }] }] }] },
|
|
19
|
+
],
|
|
20
|
+
spans: [{ kind: 'tie', from: 'whole' }],
|
|
21
|
+
});
|
|
22
|
+
composed.sheet.setWidth(400);
|
|
23
|
+
score.withDefaults({ clef: 'bass' }, (s) => s.notes('C3/w'));
|
|
24
|
+
score.compose({ staves: [], accidentals: 'automatic' });
|
|
25
|
+
score.withDefaults({}, () => __awaiter(this, void 0, void 0, function* () { return 1; }));
|
|
26
|
+
const tab = score.make.tabNote({ positions: [{ str: 2, fret: 'X' }], duration: 'q' }, true);
|
|
27
|
+
score.make.tabTie({ firstNote: tab }, 'H');
|
|
28
|
+
score.make.tabTie({ firstNote: score.make.note({ keys: ['c/4'], duration: 'q' }) });
|
|
29
|
+
score.attachToStave(score.make.tabStave(), score.make.clef('tab'));
|
|
30
|
+
score.make.tabNote({ positions: [{ str: 'one', fret: 3 }], duration: 'q' });
|
|
31
|
+
score.attach(tab, score.make.clef('tab'));
|
|
32
|
+
const nativeNote = score.make.note({ keys: ['c/4/x'], duration: 'q', autoStem: true });
|
|
33
|
+
score.sequence(['C4/q', nativeNote, { keys: ['d/4'], duration: 'q' }]);
|
|
34
|
+
score.make.graceNoteGroup({ notes: [score.make.graceNote({ keys: ['d/4'], duration: '16', slash: true })] });
|
|
35
|
+
score.make.articulation({ type: 'fermata' }).setBetweenLines(false);
|
|
36
|
+
score.make.ornament('tr', { upperAccidental: '#' });
|
|
37
|
+
score.make.tremolo(3);
|
|
38
|
+
score.make.note({ keys: ['c/4'] });
|
|
39
|
+
score.make.tremolo('three');
|
|
40
|
+
const notes = score.notes('C4/h, C4', { octaveShift: 1, durationOverride: new Fraction(1, 2) });
|
|
41
|
+
const annotation = score.make.annotation({ text: 'dolce' });
|
|
42
|
+
score.attach(notes[0], annotation);
|
|
43
|
+
const tie = score.make.tie({ from: notes[0], to: notes[1] });
|
|
44
|
+
tie.setDirection(1);
|
|
45
|
+
const adopted = score.adopt(new Annotation('extension'), 'modifier');
|
|
46
|
+
const resolved = score.getElement(adopted.getAttribute('id'));
|
|
47
|
+
const named = score.getNote(notes[0].getAttribute('id'));
|
|
48
|
+
const source = score.getSource(named);
|
|
49
|
+
if (resolved && source)
|
|
50
|
+
EasyScore.getSource(resolved);
|
|
51
|
+
score.make.tie({ from: named });
|
|
52
|
+
score.adopt(annotation, 'automatic');
|
|
53
|
+
score.make.tie({ from: score.getElement('note') });
|
|
54
|
+
const voice = score.voice(notes, { time: { numBeats: 4, beatValue: 4 }, mode: 'soft', softmaxFactor: 1 });
|
|
55
|
+
const system = score.system();
|
|
56
|
+
score.sheet({ width: 600 }).addSystem();
|
|
57
|
+
const built = score.build((builder) => builder.make.annotation({ text: 'batch' }));
|
|
58
|
+
built.setText('native');
|
|
59
|
+
score.build(() => __awaiter(this, void 0, void 0, function* () { return 1; }));
|
|
60
|
+
system.addStave({ voices: [voice] });
|
|
61
|
+
score.notes('C4/q', { octaveShift: 'one' });
|
|
62
|
+
score.voice(notes, { mode: 'relaxed' });
|
|
63
|
+
score.make.annotation({ text: 123 });
|
|
64
|
+
score.make.tie({ from: annotation });
|
|
65
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { compositionInput } from './score-persistence.mjs';
|
|
2
|
+
export function passageView(VF, factory, score) {
|
|
3
|
+
const composition = factory.EasyScore().compose(compositionInput(score));
|
|
4
|
+
const bar = (id) => score.measures.findIndex((m) => m.id === id);
|
|
5
|
+
const staff = (id) => score.staves.findIndex((s) => s.id === id);
|
|
6
|
+
const dynamics = [];
|
|
7
|
+
for (const mark of score.marks) {
|
|
8
|
+
if (mark.kind === 'rehearsal')
|
|
9
|
+
composition.staves[bar(mark.measure)][staff(mark.staff)].setSection(mark.text, 0);
|
|
10
|
+
if (mark.kind === 'dynamic') {
|
|
11
|
+
const owner = composition.getNote(mark.event);
|
|
12
|
+
const glyph = factory
|
|
13
|
+
.Annotation({ text: VF.VexFlow.Glyphs.dynamicPiano, vJustify: 'bottom' })
|
|
14
|
+
.setFont(owner.fontInfo);
|
|
15
|
+
glyph.setYShift(mark.offset * owner.checkStave().getSpacingBetweenLines());
|
|
16
|
+
owner.addModifier(glyph, 0);
|
|
17
|
+
dynamics.push({ id: mark.id, owner, glyph });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function anchorX(anchor, stave) {
|
|
21
|
+
if (anchor.continuation)
|
|
22
|
+
return anchor.at === '0/1' ? stave.getX() : stave.getX() + stave.getWidth();
|
|
23
|
+
if (anchor.at === '1/1')
|
|
24
|
+
return stave.getX() + stave.getWidth();
|
|
25
|
+
const event = Object.values(score.measures[bar(anchor.measure)].voices)
|
|
26
|
+
.flat()
|
|
27
|
+
.find((e) => e.at === anchor.at);
|
|
28
|
+
if (!event)
|
|
29
|
+
throw new Error(`The M1 adapter requires a formatted attack at ${anchor.measure} ${anchor.at}`);
|
|
30
|
+
return composition.getNote(event.id).getAbsoluteX();
|
|
31
|
+
}
|
|
32
|
+
function drawPedal(mark, rows) {
|
|
33
|
+
const start = bar(mark.start.measure), end = bar(mark.end.measure);
|
|
34
|
+
const ctx = factory.getContext();
|
|
35
|
+
const fragments = [];
|
|
36
|
+
for (const row of rows) {
|
|
37
|
+
const first = Math.max(row[0], start), last = Math.min(row.at(-1), end);
|
|
38
|
+
if (first > last)
|
|
39
|
+
continue;
|
|
40
|
+
const left = composition.staves[first][staff(mark.staff)], right = composition.staves[last][staff(mark.staff)];
|
|
41
|
+
const x1 = first === start ? anchorX(mark.start, left) : left.getX();
|
|
42
|
+
const x2 = last === end ? anchorX(mark.end, right) : right.getX() + right.getWidth();
|
|
43
|
+
const y = left.getYForBottomText(2), hook = left.getSpacingBetweenLines() / 2;
|
|
44
|
+
const depress = first === start && !mark.start.continuation, release = last === end && !mark.end.continuation;
|
|
45
|
+
ctx.save();
|
|
46
|
+
ctx.setLineWidth(1);
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.moveTo(x1, depress ? y - hook : y);
|
|
49
|
+
ctx.lineTo(x1, y);
|
|
50
|
+
ctx.lineTo(x2, y);
|
|
51
|
+
if (release)
|
|
52
|
+
ctx.lineTo(x2, y - hook);
|
|
53
|
+
ctx.stroke();
|
|
54
|
+
ctx.restore();
|
|
55
|
+
fragments.push({ id: mark.id, x1, x2, y, depress, release });
|
|
56
|
+
}
|
|
57
|
+
return fragments;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
composition,
|
|
61
|
+
dynamics,
|
|
62
|
+
draw(width) {
|
|
63
|
+
composition.sheet.setWidth(width);
|
|
64
|
+
factory.getContext().clear();
|
|
65
|
+
factory.draw({ retain: true });
|
|
66
|
+
const rows = composition.sheet
|
|
67
|
+
.getRows()
|
|
68
|
+
.map((row) => row.systems.map((system) => composition.systems.indexOf(system)));
|
|
69
|
+
return {
|
|
70
|
+
rows,
|
|
71
|
+
fragments: score.marks.filter((mark) => mark.kind === 'pedal').flatMap((mark) => drawPedal(mark, rows)),
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|