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,61 @@
|
|
|
1
|
+
export function renderEasyScoreFamilies(VF, renderer, kind = 'modifiers', ink = '#24312c') {
|
|
2
|
+
const score = VF.EasyScore.create({ renderer });
|
|
3
|
+
score.setStyle({ fillStyle: ink, strokeStyle: ink });
|
|
4
|
+
const notes = (['percussion', 'sequence'].includes(kind) ? [] : ['c/5', 'd/5', 'e/5', 'f/5']).map((key) => score.make.note({ keys: [key], duration: 'q' }));
|
|
5
|
+
const marks = [];
|
|
6
|
+
const attach = (index, modifier) => {
|
|
7
|
+
marks.push(modifier);
|
|
8
|
+
score.attach(notes[index], modifier);
|
|
9
|
+
};
|
|
10
|
+
let clef = 'treble';
|
|
11
|
+
if (kind === 'modifiers') {
|
|
12
|
+
attach(0, score.make.articulation({ type: 'fermata' }));
|
|
13
|
+
attach(1, score.make.ornament('tr'));
|
|
14
|
+
attach(2, score.make.tremolo(3));
|
|
15
|
+
attach(3, score.make.vibrato().setVibratoWidth(24));
|
|
16
|
+
}
|
|
17
|
+
else if (kind === 'accidentals') {
|
|
18
|
+
attach(0, score.make.accidental({ type: '#' }).setAsCautionary());
|
|
19
|
+
attach(1, score.make.accidental({ type: '++' }));
|
|
20
|
+
attach(2, score.make.parenthesis(VF.Modifier.Position.LEFT));
|
|
21
|
+
attach(2, score.make.parenthesis(VF.Modifier.Position.RIGHT));
|
|
22
|
+
attach(3, score.make.dot());
|
|
23
|
+
}
|
|
24
|
+
else if (kind === 'text') {
|
|
25
|
+
attach(0, score.make.annotation({ text: 'dolce', vJustify: 'top' }));
|
|
26
|
+
attach(1, score.make.chordSymbol().setKerning('auto').addText('Dm7'));
|
|
27
|
+
attach(2, score.make.fingering({ number: '2', position: 'left' }));
|
|
28
|
+
attach(3, score.make.stringNumber({ number: '3', position: 'above' }));
|
|
29
|
+
}
|
|
30
|
+
else if (kind === 'grace') {
|
|
31
|
+
const grace = ['b/4', 'c/5'].map((key) => score.make.graceNote({ keys: [key], duration: '16', slash: true }));
|
|
32
|
+
attach(0, score.make.graceNoteGroup({ notes: grace, slur: true }).beamNotes());
|
|
33
|
+
attach(2, score.make.noteSubGroup({ notes: [score.make.graceNote({ keys: ['d/5'], duration: '8' })] }));
|
|
34
|
+
attach(3, score.make.stroke(VF.Stroke.Type.ROLL_UP));
|
|
35
|
+
}
|
|
36
|
+
else if (kind === 'sequence') {
|
|
37
|
+
notes.push(...score.sequence([
|
|
38
|
+
'C5/q',
|
|
39
|
+
score.make.ghostNote('q'),
|
|
40
|
+
score.make.textNote({ text: 'rit.', duration: 'q', smooth: true }),
|
|
41
|
+
{ keys: ['f/5'], duration: 'q' },
|
|
42
|
+
]));
|
|
43
|
+
}
|
|
44
|
+
else if (kind === 'percussion') {
|
|
45
|
+
clef = 'percussion';
|
|
46
|
+
notes.splice(0, notes.length, ...score.sequence([
|
|
47
|
+
{ keys: ['g/5/x'], duration: 'q', clef, stemDirection: VF.Stem.UP },
|
|
48
|
+
{ keys: ['c/5'], duration: 'q', clef, stemDirection: VF.Stem.DOWN },
|
|
49
|
+
{ keys: ['g/5/x', 'c/5'], duration: 'q', clef, stemDirection: VF.Stem.UP },
|
|
50
|
+
{ keys: ['b/4'], duration: 'q', type: 'r', clef, line: 2 },
|
|
51
|
+
]));
|
|
52
|
+
}
|
|
53
|
+
const voice = score.voice(notes, { time: '4/4' });
|
|
54
|
+
const system = score.system({ x: 20, y: 65, width: renderer.width - 40 });
|
|
55
|
+
system
|
|
56
|
+
.addStave({ voices: [voice] })
|
|
57
|
+
.addClef(clef)
|
|
58
|
+
.addTimeSignature('4/4');
|
|
59
|
+
score.draw({ retain: true });
|
|
60
|
+
return { score, notes, marks, voice, system };
|
|
61
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function createEasyScoreReferencesExample(VF, renderer, ink = '#24312c') {
|
|
2
|
+
const score = VF.EasyScore.create({ renderer });
|
|
3
|
+
score.setStyle({ fillStyle: ink, strokeStyle: ink });
|
|
4
|
+
const notes = score.notes('C4/h[id="start"], C4/q[id="end"]');
|
|
5
|
+
const native = score.adopt(new VF.StaveNote({ keys: ['e/4'], duration: 'q', autoStem: true }), 'note');
|
|
6
|
+
native.setAttribute('id', 'native');
|
|
7
|
+
notes.push(native);
|
|
8
|
+
class PhraseLabel extends VF.Annotation {
|
|
9
|
+
constructor() {
|
|
10
|
+
super('dolce');
|
|
11
|
+
this.setVerticalJustification(VF.Annotation.VerticalJustify.TOP);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const label = score.adopt(new PhraseLabel(), 'modifier');
|
|
15
|
+
score.attach(score.getNote('start'), label);
|
|
16
|
+
const tie = score.make.tie({ from: score.getNote('start'), to: score.getNote('end') });
|
|
17
|
+
const curve = score.adopt(new VF.Curve(score.getNote('end'), native), 'drawable');
|
|
18
|
+
const voice = score.voice(notes, { time: '4/4' });
|
|
19
|
+
const system = score.system({ x: 20, y: 70, width: renderer.width - 40 });
|
|
20
|
+
system
|
|
21
|
+
.addStave({ voices: [voice] })
|
|
22
|
+
.addClef('treble')
|
|
23
|
+
.addTimeSignature('4/4');
|
|
24
|
+
score.draw({ retain: true });
|
|
25
|
+
return { score, notes, label, tie, curve, voice, system };
|
|
26
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function renderEasyScoreRhythm(VF, renderer, kind = 'odd-meter', ink = '#24312c') {
|
|
2
|
+
const score = VF.EasyScore.create({ renderer });
|
|
3
|
+
score.setStyle({ fillStyle: ink, strokeStyle: ink });
|
|
4
|
+
const marks = [];
|
|
5
|
+
let notes, voices, time = '4/4';
|
|
6
|
+
if (kind === 'odd-meter') {
|
|
7
|
+
time = '7/8';
|
|
8
|
+
score.set({ time });
|
|
9
|
+
notes = score.notes('C5/8, D5, E5, F5, G5, A5, B5', { stem: 'up' });
|
|
10
|
+
marks.push(...score.autoBeam(notes, { groups: [new VF.Fraction(2, 8), new VF.Fraction(2, 8), new VF.Fraction(3, 8)] }));
|
|
11
|
+
const bass = score.notes('C4/h, G3/q.', { stem: 'down' });
|
|
12
|
+
voices = [score.voice(notes), score.voice(bass)];
|
|
13
|
+
}
|
|
14
|
+
else if (kind === 'tuplets') {
|
|
15
|
+
time = '2/4';
|
|
16
|
+
notes = score.notes('C5/8, D5, E5, F5, G5, A5');
|
|
17
|
+
marks.push(score.make.tuplet({ notes: notes.slice(0, 3), options: { numNotes: 3, notesOccupied: 2 } }));
|
|
18
|
+
marks.push(score.make.tuplet({ notes, options: { numNotes: 5, notesOccupied: 4, ratioed: true } }));
|
|
19
|
+
marks.push(...score.autoBeam(notes, { groups: [new VF.Fraction(1, 4)] }));
|
|
20
|
+
voices = [score.voice(notes, { time })];
|
|
21
|
+
}
|
|
22
|
+
else if (kind === 'dynamics') {
|
|
23
|
+
notes = [
|
|
24
|
+
score.make.textDynamics({ text: 'p', duration: 'q', line: 2 }),
|
|
25
|
+
score.make.crescendo({ duration: 'h', line: 2 }).setHeight(8),
|
|
26
|
+
score.make.textDynamics({ text: 'ff', duration: 'q', line: 2 }),
|
|
27
|
+
];
|
|
28
|
+
voices = [score.voice(notes)];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
notes = score.notes(kind === 'ties' ? 'C5/q, C5, E5, G5' : 'C5/q, D5, E5, G5');
|
|
32
|
+
const [from, , , to] = notes;
|
|
33
|
+
if (kind === 'ties')
|
|
34
|
+
marks.push(score.make.tie({ from: notes[0], to: notes[1] }));
|
|
35
|
+
if (kind === 'curves')
|
|
36
|
+
marks.push(score.make.curve({ from, to, options: { thickness: 2 } }));
|
|
37
|
+
if (kind === 'hairpins')
|
|
38
|
+
marks.push(score.make.hairpin({ from, to, type: 1, options: { height: 10 } }));
|
|
39
|
+
if (kind === 'lines')
|
|
40
|
+
marks.push(score.make.line({ from, to, firstIndexes: [0], lastIndexes: [0], options: { text: 'gliss.' } }));
|
|
41
|
+
if (kind === 'brackets') {
|
|
42
|
+
marks.push(score.make.textBracket({ from, to, text: '8', options: { superscript: 'va', position: 'top', line: 1 } }));
|
|
43
|
+
marks.push(score.make.vibratoBracket({ from, to, options: { line: 3 } }));
|
|
44
|
+
}
|
|
45
|
+
if (kind === 'pedal')
|
|
46
|
+
marks.push(score.make.pedalMarking({ notes: [from, to], options: { style: 'mixed' } }));
|
|
47
|
+
if (kind === 'partial-spans') {
|
|
48
|
+
marks.push(score.make.tie({ to: from }), score.make.tie({ from: to }));
|
|
49
|
+
marks.push(score.make.curve({ from: to }));
|
|
50
|
+
marks.push(score.make.vibratoBracket({ from: null, to: from, options: { line: 2 } }));
|
|
51
|
+
}
|
|
52
|
+
voices = [score.voice(notes)];
|
|
53
|
+
}
|
|
54
|
+
const system = score.system({ x: 20, y: 75, width: renderer.width - 40 });
|
|
55
|
+
system.addStave({ voices }).addClef('treble').addTimeSignature(time);
|
|
56
|
+
score.draw({ retain: true });
|
|
57
|
+
return { score, notes, marks, voices, system };
|
|
58
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export function renderEasyScoreStructure(VF, renderer, kind = 'tab', ink = '#24312c') {
|
|
2
|
+
const score = VF.EasyScore.create({ renderer });
|
|
3
|
+
score.setStyle({ fillStyle: ink, strokeStyle: ink });
|
|
4
|
+
const marks = [];
|
|
5
|
+
let notes = [];
|
|
6
|
+
const system = score.system({ x: 20, y: 75, width: renderer.width - 40 });
|
|
7
|
+
const tab = ['tab', 'grace-tab'].includes(kind);
|
|
8
|
+
const bounds = { x: 20, width: renderer.width - 40 };
|
|
9
|
+
const stave = tab ? score.make.tabStave(bounds) : score.make.stave(bounds);
|
|
10
|
+
const attach = (mark, position) => {
|
|
11
|
+
score.attachToStave(stave, mark, position);
|
|
12
|
+
marks.push(mark);
|
|
13
|
+
};
|
|
14
|
+
if (tab) {
|
|
15
|
+
notes = [3, 5, 7, 7].map((fret) => score.make.tabNote({ positions: [{ str: 2, fret }], duration: 'q' }));
|
|
16
|
+
attach(score.make.clef('tab'));
|
|
17
|
+
if (kind === 'tab') {
|
|
18
|
+
const bend = score.make.bend([
|
|
19
|
+
{ type: VF.Bend.UP, text: 'Full' },
|
|
20
|
+
{ type: VF.Bend.DOWN, text: '' },
|
|
21
|
+
]);
|
|
22
|
+
score.attach(notes[0], bend);
|
|
23
|
+
marks.push(bend);
|
|
24
|
+
marks.push(score.make.tabSlide({ firstNote: notes[1], lastNote: notes[2] }));
|
|
25
|
+
marks.push(score.make.tabTie({ firstNote: notes[2], lastNote: notes[3] }, 'H'));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const grace = score.make.graceTabNote({ positions: [{ str: 2, fret: 2 }], duration: '16' });
|
|
29
|
+
const group = score.make.graceNoteGroup({ notes: [grace], slur: true });
|
|
30
|
+
score.attach(notes[0], group);
|
|
31
|
+
marks.push(group);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (kind === 'rest') {
|
|
35
|
+
attach(score.make.clef('treble'));
|
|
36
|
+
marks.push(score.make.multiMeasureRest({ numberOfMeasures: 8, useSymbols: true }).setStave(stave));
|
|
37
|
+
}
|
|
38
|
+
else if (kind === 'inline') {
|
|
39
|
+
notes = score.sequence([
|
|
40
|
+
'C5/q',
|
|
41
|
+
score.make.barNote(),
|
|
42
|
+
score.make.clefNote({ type: 'bass', options: { size: 'small' } }),
|
|
43
|
+
score.make.keySigNote({ key: 'G' }),
|
|
44
|
+
score.make.timeSigNote({ time: '3/4' }),
|
|
45
|
+
...score.notes('G3/q, A3, B3', { clef: 'bass' }),
|
|
46
|
+
]);
|
|
47
|
+
attach(score.make.clef('treble'));
|
|
48
|
+
}
|
|
49
|
+
else if (kind === 'repeat') {
|
|
50
|
+
notes = [
|
|
51
|
+
score.make.repeatNote('slash'),
|
|
52
|
+
score.make.repeatNote('slash'),
|
|
53
|
+
score.make.glyphNote('\uE047', { duration: 'h' }, { line: 2 }),
|
|
54
|
+
];
|
|
55
|
+
attach(score.make.clef('percussion'));
|
|
56
|
+
const annotation = score.make.annotation({ text: 'sim.', vJustify: 'top' });
|
|
57
|
+
score.attach(notes[2], annotation);
|
|
58
|
+
marks.push(annotation);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
notes = score.notes('C5/q, D5, E5, F5');
|
|
62
|
+
attach(score.make.clef('treble'));
|
|
63
|
+
attach(score.make.keySignature('G'));
|
|
64
|
+
attach(score.make.timeSignature('4/4'));
|
|
65
|
+
attach(score.make.barline(VF.Barline.type.REPEAT_END), VF.StaveModifier.Position.END);
|
|
66
|
+
if (kind === 'labels') {
|
|
67
|
+
attach(score.make.section('A', 0, -15));
|
|
68
|
+
attach(score.make.tempo({ duration: 'q', bpm: 96 }, 100, -15));
|
|
69
|
+
attach(score.make.staveText('dolce', VF.StaveModifier.Position.BELOW));
|
|
70
|
+
}
|
|
71
|
+
else if (kind !== 'connector') {
|
|
72
|
+
attach(score.make.volta(VF.Volta.type.BEGIN_END, '1.', 0, 0));
|
|
73
|
+
attach(score.make.repetition(VF.Repetition.type.DC, 0, 0));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
system.addStave({ stave, voices: notes.length ? [score.voice(notes)] : [] });
|
|
77
|
+
if (kind === 'connector') {
|
|
78
|
+
const lowerNotes = score.notes('C3/w', { clef: 'bass' });
|
|
79
|
+
const lower = score.make.stave(bounds);
|
|
80
|
+
score.attachToStave(lower, score.make.clef('bass'));
|
|
81
|
+
system.addStave({ stave: lower, voices: [score.voice(lowerNotes)] });
|
|
82
|
+
marks.push(score.make.connector({ topStave: stave, bottomStave: lower, type: 'brace' }));
|
|
83
|
+
notes.push(...lowerNotes);
|
|
84
|
+
score.factory.getContext().resize(renderer.width, 350);
|
|
85
|
+
}
|
|
86
|
+
score.draw({ retain: true });
|
|
87
|
+
return { score, notes, marks, system };
|
|
88
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { expression } from './expression.mjs';
|
|
2
|
+
import { layout } from './layout.mjs';
|
|
3
|
+
import { notes } from './notes.mjs';
|
|
4
|
+
import { staves } from './staves.mjs';
|
|
5
|
+
import { strings } from './strings.mjs';
|
|
6
|
+
export const entries = [...notes, ...staves, ...expression, ...strings, ...layout];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { example as e, number, select, setup, staff, text } from './helpers.mjs';
|
|
2
|
+
const group = 'Marks & expression';
|
|
3
|
+
export const expression = [
|
|
4
|
+
e('annotations', 'Lyrics & annotations', group, 'Align lyrics below notes or annotations above them.', 'Annotation', staff("score.notes('C5/q, E5, G5, C6')", `params.words.split(' ').slice(0, notes.length).forEach((word, i) => {
|
|
5
|
+
notes[i].addModifier(factory.Annotation({ text: word, vJustify: params.position }), 0);
|
|
6
|
+
});`), [text('words', 'Words', 'One two three four'), select('position', 'Position', 'bottom', ['bottom', 'top'])]),
|
|
7
|
+
e('chord-symbols', 'Chord symbols', group, 'Build harmonic labels from text, accidentals, and superscripts.', 'ChordSymbol', staff("score.notes('C5/h, G4')", `notes[0].addModifier(factory.ChordSymbol().addText(params.root).addGlyphOrText('maj7'), 0);
|
|
8
|
+
notes[1].addModifier(factory.ChordSymbol().addText('G').addGlyphOrText('7').addGlyphOrText('b9', { symbolModifier: VF.ChordSymbol.symbolModifiers.SUPERSCRIPT }), 0);`), [text('root', 'Root', 'C')]),
|
|
9
|
+
e('chord-kerning', 'Chord kerning', group, 'Compare default spacing with opt-in font-specific kerning and stacked scripts.', 'ChordSymbol', `${setup}
|
|
10
|
+
// The two rows use identical notes and chord content. Only the kerning mode changes.
|
|
11
|
+
const ctx = factory.getContext();
|
|
12
|
+
ctx.resize(width, 360);
|
|
13
|
+
const chords = [];
|
|
14
|
+
const sup = { symbolModifier: VF.ChordSymbol.symbolModifiers.SUPERSCRIPT };
|
|
15
|
+
const sub = { symbolModifier: VF.ChordSymbol.symbolModifiers.SUBSCRIPT };
|
|
16
|
+
['none', 'auto'].forEach((mode, row) => {
|
|
17
|
+
const notes = score.notes('C5/q, D5, E5, G5');
|
|
18
|
+
const make = () => factory.ChordSymbol({ fontSize: params.size, hJustify: 'left' }).setKerning(mode);
|
|
19
|
+
const symbols = [
|
|
20
|
+
make().addText(params.root).addGlyph('diminished', sup),
|
|
21
|
+
make().addGlyphOrText('C#7'),
|
|
22
|
+
make().addText('F7').addGlyphOrText('b9', sup).addGlyphOrText('#11', sub),
|
|
23
|
+
make().addText(params.root).addGlyph('majorSeventh', sup),
|
|
24
|
+
];
|
|
25
|
+
notes.forEach((note, i) => note.addModifier(symbols[i], 0));
|
|
26
|
+
chords.push(...symbols);
|
|
27
|
+
const voice = factory.Voice().addTickables(notes);
|
|
28
|
+
factory.System({ x: 30, y: 70 + row * 150, width: width - 60 })
|
|
29
|
+
.addStave({ voices: [voice] }).addClef('treble');
|
|
30
|
+
});
|
|
31
|
+
factory.draw();
|
|
32
|
+
ctx.setFont('sans-serif', 10);
|
|
33
|
+
ctx.fillText('Default: none', 30, 22);
|
|
34
|
+
ctx.fillText('Opt-in: auto', 30, 172);
|
|
35
|
+
// Inspect the complete chord's ink bounds, including both script rows.
|
|
36
|
+
if (params.bounds === 'yes') {
|
|
37
|
+
ctx.save().setStrokeStyle('#b74632').setLineWidth(0.5);
|
|
38
|
+
chords.forEach(chord => {
|
|
39
|
+
const box = chord.getBoundingBox();
|
|
40
|
+
ctx.beginPath().rect(box.x, box.y, box.w, box.h).stroke();
|
|
41
|
+
});
|
|
42
|
+
ctx.restore();
|
|
43
|
+
}`, [
|
|
44
|
+
text('root', 'Root', 'A'),
|
|
45
|
+
number('size', 'Font size (pt)', 18, 10, 28),
|
|
46
|
+
select('bounds', 'Chord bounds', 'no', ['no', 'yes']),
|
|
47
|
+
], 'Auto supports regular Academico/Bravura and Petaluma Script/Petaluma. Other font combinations keep the default layout. Set the chord font before formatting.'),
|
|
48
|
+
e('dynamics', 'Dynamics', group, 'From pianissimo to fortissimo, draw music-font dynamic marks.', 'TextDynamics', `${setup}
|
|
49
|
+
const dynamics = ['pp', 'p', 'mp', 'mf', 'f', 'ff'].map(text => factory.TextDynamics({ text, duration: 'q' }));
|
|
50
|
+
const voice = factory.Voice().setMode(VF.Voice.Mode.SOFT).addTickables(dynamics);
|
|
51
|
+
factory.System({ x: 30, y: 55, width: width - 60 }).addStave({ voices: [voice] });
|
|
52
|
+
factory.draw();`),
|
|
53
|
+
e('text-notes', 'Text notes', group, 'Place rhythmically aligned text alongside music.', 'TextNote', `${setup}
|
|
54
|
+
const notes = ['dolce', 'poco', 'a', 'poco'].map(text => factory.TextNote({ text, duration: 'q', line: params.line }));
|
|
55
|
+
const voice = factory.Voice().addTickables(notes);
|
|
56
|
+
factory.System({ x: 30, y: 65, width: width - 60 }).addStave({ voices: [voice] });
|
|
57
|
+
factory.draw();`, [number('line', 'Text line', 2, -2, 6)]),
|
|
58
|
+
e('ties', 'Ties', group, 'Connect the same pitch across successive notes. Chord ties can select individual keys.', 'StaveTie', staff("score.notes('(C5 E5)/h, (C5 E5)')", 'factory.StaveTie({ from: notes[0], to: notes[1], firstIndexes: [0, 1], lastIndexes: [0, 1] });')),
|
|
59
|
+
e('slurs', 'Slurs & curves', group, 'Connect notes with a slur and adjust its thickness.', 'Curve', staff("score.notes('C5/q, D5, E5, G5')", 'factory.Curve({ from: notes[0], to: notes[3], options: { thickness: params.thickness } });'), [number('thickness', 'Thickness', 2, 1, 6, 0.5)]),
|
|
60
|
+
e('hairpins', 'Hairpins', group, 'Draw crescendo and decrescendo hairpins below the staff.', 'StaveHairpin', staff("score.notes('C5/q, D5, E5, G5')", '', `new VF.StaveHairpin({ firstNote: notes[0], lastNote: notes[3] }, params.direction === 'crescendo' ? 1 : 2)
|
|
61
|
+
.setPosition(VF.Modifier.Position.BELOW)
|
|
62
|
+
.setStyle({ fillStyle: ink, strokeStyle: ink })
|
|
63
|
+
.setContext(factory.getContext()).drawWithStyle();`), [select('direction', 'Direction', 'crescendo', ['crescendo', 'decrescendo'])]),
|
|
64
|
+
e('pedal', 'Pedal markings', group, 'Choose between text, brackets, and a mixture of the two.', 'PedalMarking', staff("score.notes('C5/q, E5, G5, C6')", 'factory.PedalMarking({ notes: [notes[0], notes[3]], options: { style: params.style } });'), [select('style', 'Style', 'mixed', ['mixed', 'bracket', 'text'])]),
|
|
65
|
+
e('octaves', 'Octave brackets', group, 'An octave instruction spans a passage without changing its written pitches.', 'TextBracket', staff("score.notes('C5/q, E5, G5, C6')", "factory.TextBracket({ from: notes[0], to: notes[3], text: params.text, options: { superscript: 'va', position: 'top', line: 2 } });"), [select('text', 'Interval', '8', ['8', '15'])]),
|
|
66
|
+
e('glissando', 'Glissando lines', group, 'Draw a line between selected pitches and add a label.', 'StaveLine', staff("score.notes('C4/h, C6')", "factory.StaveLine({ from: notes[0], to: notes[1], firstIndexes: [0], lastIndexes: [0], options: { text: 'gliss.' } });")),
|
|
67
|
+
e('vibrato-bracket', 'Vibrato brackets', group, 'Draw a vibrato bracket spanning several notes.', 'VibratoBracket', staff("score.notes('C5/q, D5, E5, G5')", 'factory.VibratoBracket({ from: notes[0], to: notes[3], options: { line: 2 } });')),
|
|
68
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const select = (key, label, value, choices) => ({ key, label, value, choices });
|
|
2
|
+
export const number = (key, label, value, min, max, step = 1) => ({ key, label, value, min, max, step });
|
|
3
|
+
export const text = (key, label, value) => ({ key, label, value });
|
|
4
|
+
export const setup = `// Render into the score container. Dimensions and ink come from the controls.
|
|
5
|
+
const factory = new VF.Factory({
|
|
6
|
+
renderer: { elementId: 'score', width, height }
|
|
7
|
+
});
|
|
8
|
+
factory.setStyle({ fillStyle: ink, strokeStyle: ink });
|
|
9
|
+
|
|
10
|
+
// EasyScore parses pitch/duration strings such as C5/q or (C4 E4 G4)/h.
|
|
11
|
+
const score = factory.EasyScore({ throwOnError: true });`;
|
|
12
|
+
export function staff(notes, modifications = '', after = '', stave = ".addClef('treble')") {
|
|
13
|
+
return `${setup}
|
|
14
|
+
|
|
15
|
+
const notes = ${notes};
|
|
16
|
+
${modifications}
|
|
17
|
+
|
|
18
|
+
// SOFT mode allows incomplete measures while experimenting with durations.
|
|
19
|
+
const voice = factory.Voice().setMode(VF.Voice.Mode.SOFT).addTickables(notes);
|
|
20
|
+
const system = factory.System({ x: 30, y: 65, width: width - 60 });
|
|
21
|
+
system.addStave({ voices: [voice] })${stave};
|
|
22
|
+
|
|
23
|
+
// Format and draw the objects registered with the factory.
|
|
24
|
+
factory.draw();
|
|
25
|
+
${after ? '\n// Draw this additional mark after note positions have been calculated.\n' + after : ''}`.trim();
|
|
26
|
+
}
|
|
27
|
+
export function example(id, title, group, description, api, code, controls = [], tips = '') {
|
|
28
|
+
return { id, title, group, description, api: api.split(' '), code, controls, tips };
|
|
29
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { renderEasyScoreComposition } from '../../easyscore-composition.mjs';
|
|
2
|
+
import { createEasyScoreExample } from '../../easyscore-example.mjs';
|
|
3
|
+
import { renderEasyScoreFamilies } from '../../easyscore-families.mjs';
|
|
4
|
+
import { createEasyScoreReferencesExample } from '../../easyscore-references-example.mjs';
|
|
5
|
+
import { renderEasyScoreStructure } from '../../easyscore-structure.mjs';
|
|
6
|
+
import { renderEasyScoreRhythm } from '../../easyscore-rhythm.mjs';
|
|
7
|
+
import { example as e, number, select, setup, staff, text } from './helpers.mjs';
|
|
8
|
+
const group = 'Layout & composition';
|
|
9
|
+
export const layout = [
|
|
10
|
+
e('easyscore-first-score', 'EasyScore: first score', group, 'Create notes, an annotation, a tie, a voice, and a system through EasyScore.', 'EasyScore Annotation StaveTie Voice System', `// The function body is shared with the tested user-guide example.
|
|
11
|
+
(${createEasyScoreExample.toString()})(VF, { elementId: 'score', width, height }, ink);`, [], 'EasyScore.create() validates before construction. Helpers return native VexFlow objects. Typed helpers cover all notation families; native setters remain available.'),
|
|
12
|
+
e('easyscore-references', 'EasyScore: references & extensions', group, 'Resolve named notes, adopt native extensions, and click parsed notes to select their source.', 'EasyScore getElement getNote getSource adopt Annotation StaveTie Curve', `// Click either C4 note to select its notation in this editor.
|
|
13
|
+
(${createEasyScoreReferencesExample.toString()})(VF, { elementId: 'score', width, height }, ink);`, [], 'IDs are local to each score. Adopted notes and drawables share the normal retained lifecycle. Native objects have no notation source. Inspector selection requires one unescaped matching literal; computed or ambiguous input is shown without guessing an editor location.'),
|
|
14
|
+
e('easyscore-families', 'EasyScore: notes & modifiers', group, 'Typed notes, percussion heads, native modifiers, and grace groups through one score.', 'EasyScore StaveNote Accidental Articulation Ornament Tremolo Vibrato Parenthesis Dot ChordSymbol GraceNoteGroup NoteSubGroup Stroke TextNote', `(${renderEasyScoreFamilies.toString()})(VF, { elementId: 'score', width, height }, params.family, ink);`, [select('family', 'Family', 'modifiers', ['modifiers', 'accidentals', 'text', 'grace', 'percussion', 'sequence'])], 'Typed notes preserve native fields and head codes. Grace/subnote groups own their children. Set note duration dots explicitly; a Dot modifier alone changes only the appearance.'),
|
|
15
|
+
e('easyscore-rhythm', 'EasyScore: rhythm & relationships', group, 'Odd-meter voices, nested tuplets, owned spans, partial endpoints, and timed dynamics.', 'EasyScore Beam Tuplet StaveTie Curve StaveHairpin StaveLine TextBracket VibratoBracket PedalMarking TextDynamics Crescendo', `(${renderEasyScoreRhythm.toString()})(VF, { elementId: 'score', width, height }, params.family, ink);`, [
|
|
16
|
+
select('family', 'Family', 'odd-meter', [
|
|
17
|
+
'odd-meter',
|
|
18
|
+
'tuplets',
|
|
19
|
+
'ties',
|
|
20
|
+
'curves',
|
|
21
|
+
'hairpins',
|
|
22
|
+
'lines',
|
|
23
|
+
'brackets',
|
|
24
|
+
'pedal',
|
|
25
|
+
'partial-spans',
|
|
26
|
+
'dynamics',
|
|
27
|
+
]),
|
|
28
|
+
], 'Beam groups use exact Fractions and preserve explicit stems by default. Create tuplets before voices. Spans draw through the score; row-break segments remain explicit.'),
|
|
29
|
+
e('easyscore-structure', 'EasyScore: tablature & staff structure', group, 'Tablature, bends, grace groups, inline changes, rests, repeats, and staff markings.', 'EasyScore TabNote GraceTabNote TabSlide TabTie Bend Stave Clef KeySignature TimeSignature MultiMeasureRest RepeatNote GlyphNote', `(${renderEasyScoreStructure.toString()})(VF, { elementId: 'score', width, height }, params.family, ink);`, [
|
|
30
|
+
select('family', 'Family', 'tab', [
|
|
31
|
+
'tab',
|
|
32
|
+
'grace-tab',
|
|
33
|
+
'rest',
|
|
34
|
+
'inline',
|
|
35
|
+
'repeat',
|
|
36
|
+
'labels',
|
|
37
|
+
'endings',
|
|
38
|
+
'connector',
|
|
39
|
+
]),
|
|
40
|
+
], 'Staff modifiers draw through their stave. Inline clefs and signatures change appearance; update note options explicitly. Tab tuning stays a separate native utility.'),
|
|
41
|
+
e('easyscore-composition', 'EasyScore: responsive composition', group, 'A grand staff with pickup, opposing voices, triplets, changing meter, key-aware accidentals, and inline state.', 'EasyScore compose Sheet System Voice Fraction Accidental', `(${renderEasyScoreComposition.toString()})(VF, { elementId: 'score', width: params.sheetWidth, height }, params.spacing, ink);`, [
|
|
42
|
+
number('sheetWidth', 'Width', 640, 320, 1000, 20),
|
|
43
|
+
select('spacing', 'Spacing', 'engraving', ['engraving', 'proportional']),
|
|
44
|
+
], 'Each measure is a native System. Tuplets precede voices; all voices share the actual span. Signatures repeat at every measure here, so any measure can begin a row. Use Sheet.getRows() to inspect overflow.'),
|
|
45
|
+
e('proportional-spacing', 'Proportional spacing', group, 'Compare engraving spacing with an exact musical-time grid. Equal durations occupy equal widths.', 'Formatter Voice TickContext System Tuplet', `${setup}
|
|
46
|
+
const ctx = factory.getContext();
|
|
47
|
+
// Auto width preserves the chosen scale. Resize the surface to fit both rows.
|
|
48
|
+
const systems = [];
|
|
49
|
+
const rows = [];
|
|
50
|
+
['engraving', 'proportional'].forEach((mode, row) => {
|
|
51
|
+
const notes = score.notes('C5/16, D5, E5, F5, G5/8, A5, B5/q, C6', { stem: 'up' });
|
|
52
|
+
score.beam(notes.slice(0, 4));
|
|
53
|
+
score.beam(notes.slice(4, 6));
|
|
54
|
+
const voices = [score.voice(notes)];
|
|
55
|
+
if (params.voices === 'two') {
|
|
56
|
+
voices.push(score.voice(score.notes('C4/q, E4, G4, E4', { stem: 'down' })));
|
|
57
|
+
}
|
|
58
|
+
const spacing = mode === 'proportional'
|
|
59
|
+
? { mode: 'proportional', pixelsPerQuarter: params.scale }
|
|
60
|
+
: undefined;
|
|
61
|
+
const system = factory.System({
|
|
62
|
+
x: 30, y: 45 + row * 155,
|
|
63
|
+
...(mode === 'engraving' ? { width: params.scale * 4 + 100 } : {}),
|
|
64
|
+
details: { spacing },
|
|
65
|
+
});
|
|
66
|
+
system.addStave({ voices }).addClef('treble').addTimeSignature('4/4');
|
|
67
|
+
system.format();
|
|
68
|
+
systems.push(system);
|
|
69
|
+
rows.push(notes);
|
|
70
|
+
});
|
|
71
|
+
ctx.resize(Math.max(width, ...systems.map(system => system.getWidth() + 60)), 360);
|
|
72
|
+
factory.draw();
|
|
73
|
+
ctx.setFont('sans-serif', 10);
|
|
74
|
+
ctx.fillText('Default engraving', 30, 20);
|
|
75
|
+
ctx.fillText('Strict proportional spacing', 30, 175);
|
|
76
|
+
// Guides mark quarter-note onsets, plus the end of the four-beat span.
|
|
77
|
+
const origin = rows[1][0].getAbsoluteX();
|
|
78
|
+
ctx.save().setStrokeStyle('#b6c4c0').setLineWidth(0.5);
|
|
79
|
+
for (let beat = 0; beat <= 4; beat++) {
|
|
80
|
+
const x = origin + beat * params.scale;
|
|
81
|
+
ctx.beginPath().moveTo(x, 210).lineTo(x, 310).stroke();
|
|
82
|
+
}
|
|
83
|
+
ctx.restore();`, [number('scale', 'Pixels per quarter', 140, 120, 180, 10), select('voices', 'Voices', 'two', ['one', 'two'])], 'Set spacing on Formatter, or System.details. Omit pixelsPerQuarter to fit a supplied width. Crowded notation reports the minimum scale and width instead of moving notes off the grid.'),
|
|
84
|
+
e('voices', 'Multiple voices', group, 'Independent voices share a staff and align at common musical times.', 'Voice Formatter ModifierContext TickContext', `${setup}
|
|
85
|
+
const upper = score.voice(score.notes('C5/h, D5', { stem: 'up' }));
|
|
86
|
+
const lower = score.voice(score.notes('G4/q, A4, B4, A4', { stem: 'down' }));
|
|
87
|
+
factory.System({ x: 30, y: 65, width: width - 60 })
|
|
88
|
+
.addStave({ voices: [upper, lower] }).addClef('treble');
|
|
89
|
+
factory.draw();`),
|
|
90
|
+
e('sheet', 'Responsive sheets', group, 'Wrap measures into rows at a configurable width.', 'Sheet System Factory', `${setup}
|
|
91
|
+
const sheet = factory.Sheet({ width: Math.min(params.rowWidth, width - 60), x: 30, y: 25, rowGap: 15 });
|
|
92
|
+
for (const notes of score.measures('C5/h, E5 | G5/q, E5, D5, C5 | E5/h, G5 | C5/w')) {
|
|
93
|
+
sheet.addSystem().addStave({ voices: [score.voice(notes)] }).addClef('treble');
|
|
94
|
+
}
|
|
95
|
+
// Format first so the renderer can use the height of the wrapped rows.
|
|
96
|
+
sheet.format();
|
|
97
|
+
factory.getContext().resize(width, sheet.getHeight() + 30);
|
|
98
|
+
factory.draw();`, [number('rowWidth', 'Row width', 620, 200, 900, 20)]),
|
|
99
|
+
e('styles', 'Color & highlighting', group, 'Set a foreground for the score and keep individual highlights.', 'Element Factory', staff("score.notes('C5/q, E5, G5, C6')", 'notes[params.index].setStyle({ fillStyle: params.color, strokeStyle: params.color });'), [number('index', 'Note index', 1, 0, 3), text('color', 'Highlight color', '#b74632')]),
|
|
100
|
+
e('ghosts', 'Ghost notes', group, 'An invisible tickable reserves rhythmic space without drawing a note.', 'GhostNote', staff("[...score.notes('C5/q'), factory.GhostNote({ duration: 'q' }), ...score.notes('E5/q, G5')]"), [], 'The empty second beat is intentional. GhostNote contributes time and spacing without a visible notehead.'),
|
|
101
|
+
e('repeat-notes', 'Measure-repeat symbols', group, 'A repeat glyph can stand in for a repeated measure.', 'RepeatNote', staff("[factory.RepeatNote(params.type, { duration: 'w' })]"), [select('type', 'Repeat', '1', ['1', '2', '4', 'slash'])]),
|
|
102
|
+
e('glyph-notes', 'Glyph notes', group, 'Use a music glyph as a rhythmically positioned note.', 'GlyphNote', staff("[factory.GlyphNote(VF.Glyphs.segno, { duration: 'h' }), factory.GlyphNote(VF.Glyphs.coda, { duration: 'h' })]")),
|
|
103
|
+
e('subgroups', 'Note subgroups', group, 'Attach a small inline group, such as a clef change, to a note.', 'NoteSubGroup ClefNote', staff("score.notes('C5/q, E5, G5, C6')", "notes[1].addModifier(factory.NoteSubGroup({ notes: [new VF.ClefNote('bass', 'small')] }), 0);")),
|
|
104
|
+
e('crescendo-note', 'Rhythmic crescendo', group, 'A crescendo can occupy musical time inside a voice.', 'Crescendo', `${setup}
|
|
105
|
+
const crescendo = new VF.Crescendo({ duration: 'w' }).setLine(params.line);
|
|
106
|
+
const voice = factory.Voice().addTickables([crescendo]);
|
|
107
|
+
factory.System({ x: 30, y: 60, width: width - 60 }).addStave({ voices: [voice] });
|
|
108
|
+
factory.draw();`, [number('line', 'Line', 2, 0, 6)]),
|
|
109
|
+
];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { example as e, number, select, setup, staff, text } from './helpers.mjs';
|
|
2
|
+
const group = 'Notes & rhythm';
|
|
3
|
+
export const notes = [
|
|
4
|
+
e('notes', 'Notes & stems', group, 'Create notes from pitch and duration strings. Adjust stem direction.', 'StaveNote Stem Flag EasyScore', staff('score.notes(params.phrase, { stem: params.stem })'), [
|
|
5
|
+
text('phrase', 'Phrase', 'C5/q, D5/8, E5, G5/q, E5'),
|
|
6
|
+
select('stem', 'Stem direction', 'auto', ['auto', 'up', 'down']),
|
|
7
|
+
], 'EasyScore uses scientific pitch names. /q, /8, and /h select quarter, eighth, and half notes. Omitted durations carry forward.'),
|
|
8
|
+
e('rests', 'Rests', group, 'Compare whole, half, quarter, eighth, and sixteenth rests.', 'StaveNote EasyScore', staff("score.notes('B4/w/r, B4/h/r, B4/q/r, B4/8/r, B4/16/r')")),
|
|
9
|
+
e('chords', 'Chords & seconds', group, 'Stack pitches and inspect how adjacent noteheads shift to avoid one another.', 'StaveNote NoteHead', staff('score.notes(params.phrase, { stem: params.stem })'), [
|
|
10
|
+
text('phrase', 'Chords', '(C4 E4 G4)/q, (D4 E4 F4), (C5 D5 E5), (G4 B4 D5)'),
|
|
11
|
+
select('stem', 'Stems', 'up', ['up', 'down']),
|
|
12
|
+
]),
|
|
13
|
+
e('noteheads', 'Notehead shapes', group, 'Compare cross, diamond, triangle, and slash noteheads.', 'StaveNote NoteHead', staff("['c/4', 'd/4', 'e/4', 'f/4'].map(key => factory.StaveNote({ keys: [key + '/' + params.shape], duration: 'q' }))"), [select('shape', 'Shape', 'D', ['D', 'X0', 'X1', 'X2', 'T0', 'S1'])]),
|
|
14
|
+
e('dots', 'Dotted notes', group, 'Render single and double augmentation dots beside noteheads.', 'Dot StaveNote', staff("score.notes('C5/q., D5/8, E5/q.., G5/16')")),
|
|
15
|
+
e('beams', 'Beams', group, 'Group eighth notes under a beam. Edit pitches to change its slope.', 'Beam StemmableNote', staff('score.notes(params.phrase)', '// Automatic stems are resolved for the complete group.\nscore.beam(notes);'), [text('phrase', 'Eighth notes', 'C5/8, D5, E5, G5, A5, G5, E5, D5')]),
|
|
16
|
+
e('beamed-tuplets', 'Beamed tuplets', group, 'Keep all seven stems on the same side of a 7:4 beam, including when pitches cross the middle line.', 'Tuplet Beam EasyScore Formatter', `${setup}
|
|
17
|
+
const phrase = params.phrase === 'ascending'
|
|
18
|
+
? 'C4/8, D4, E4, F4, G4, A4, B4'
|
|
19
|
+
: 'A5/8, G5, F5, E5, D5, C5, A4';
|
|
20
|
+
const notes = score.notes(phrase);
|
|
21
|
+
score.tuplet(notes, { numNotes: 7, notesOccupied: 4, ratioed: true });
|
|
22
|
+
// EasyScore resolves the automatic stems for the complete beam.
|
|
23
|
+
score.beam(notes);
|
|
24
|
+
const details = params.spacing === 'proportional'
|
|
25
|
+
? { spacing: { mode: 'proportional', pixelsPerQuarter: 140 } }
|
|
26
|
+
: {};
|
|
27
|
+
factory.System({ x: 30, y: 65, width: width - 60, details })
|
|
28
|
+
.addStave({ voices: [score.voice(notes, { time: '2/4' })] }).addClef('treble');
|
|
29
|
+
factory.draw();`, [
|
|
30
|
+
select('phrase', 'Phrase', 'ascending', ['ascending', 'descending']),
|
|
31
|
+
select('spacing', 'Spacing', 'proportional', ['proportional', 'engraving']),
|
|
32
|
+
], 'Automatic stems use a shared direction. Explicit stem choices are preserved. Use beam options autoStem: false for intentional mixed automatic stems.'),
|
|
33
|
+
e('tuplets', 'Tuplets', group, 'Fit a group of notes into a different rhythmic span.', 'Tuplet', staff("score.notes('C5/8, D5, E5, G5, E5, D5')", 'factory.Tuplet({ notes, options: { numNotes: 6, notesOccupied: params.occupied, ratioed: true, bracketed: true } });'), [select('occupied', 'Notes occupied', 4, [2, 4, 8])]),
|
|
34
|
+
e('grace', 'Grace notes', group, 'Small notes lead into a full-sized note, with an optional slur.', 'GraceNote GraceNoteGroup', staff("score.notes('C5/q, E5, G5, C6')", `const grace = ['d/5', 'e/5'].map(key => factory.GraceNote({ keys: [key], duration: '16', slash: params.slash === 'yes' }));
|
|
35
|
+
notes[0].addModifier(factory.GraceNoteGroup({ notes: grace, slur: true }), 0);`), [select('slash', 'Slash', 'yes', ['yes', 'no'])]),
|
|
36
|
+
e('accidentals', 'Accidentals', 'Marks & expression', 'Alter a pitch with sharps, flats, naturals, or a cautionary accidental.', 'Accidental', staff("score.notes('C5/q, D5, E5, F5')", `notes.forEach((note, index) => {
|
|
37
|
+
const accidental = factory.Accidental({ type: params.type });
|
|
38
|
+
if (index === 3) accidental.setAsCautionary();
|
|
39
|
+
note.addModifier(accidental, 0);
|
|
40
|
+
});`), [select('type', 'Accidental', '#', ['#', 'b', 'n', '##', 'bb'])]),
|
|
41
|
+
e('microtones', 'Microtonal accidentals', 'Marks & expression', 'Explore quarter-tone and other microtonal pitch marks.', 'Accidental', staff("score.notes('C5/q, D5, E5, F5')", "['+', '++', 'db', 'bbs'].forEach((type, i) => notes[i].addModifier(factory.Accidental({ type }), 0));")),
|
|
42
|
+
e('articulations', 'Articulations', 'Marks & expression', 'Small marks describe the attack and length of a note.', 'Articulation', staff("score.notes('C5/q, D5, E5, G5')", 'notes.forEach(note => note.addModifier(factory.Articulation({ type: params.type, position: params.position }), 0));'), [
|
|
43
|
+
select('type', 'Articulation', 'a.', ['a.', 'a-', 'a>', 'a^', 'a@a', 'a@u']),
|
|
44
|
+
select('position', 'Position', 'above', ['above', 'below']),
|
|
45
|
+
]),
|
|
46
|
+
e('ornaments', 'Ornaments', 'Marks & expression', 'Attach turns, mordents, trills, and other ornaments to notes.', 'Ornament', staff("score.notes('C5/q, D5, E5, G5')", 'notes.forEach(note => note.addModifier(factory.Ornament(params.type), 0));'), [
|
|
47
|
+
select('type', 'Ornament', 'tr', [
|
|
48
|
+
'tr',
|
|
49
|
+
'mordent',
|
|
50
|
+
'mordentInverted',
|
|
51
|
+
'turn',
|
|
52
|
+
'turnInverted',
|
|
53
|
+
'upprall',
|
|
54
|
+
'doit',
|
|
55
|
+
'fall',
|
|
56
|
+
]),
|
|
57
|
+
]),
|
|
58
|
+
e('tremolo', 'Tremolo', 'Marks & expression', 'Repeated strokes across a stem indicate rapid repetition.', 'Tremolo', staff("score.notes('C5/h, E5, G5')", 'notes.forEach(note => note.addModifier(new VF.Tremolo(params.strokes), 0));'), [number('strokes', 'Strokes', 3, 1, 4)]),
|
|
59
|
+
e('fingering', 'Fingerings', 'Marks & expression', 'Place a finger number beside each pitch of a chord.', 'FretHandFinger', staff("score.notes('(C5 E5 G5)/h, (D5 F5 A5)')", "notes.forEach(note => ['1', '3', '5'].forEach((number, i) => note.addModifier(factory.Fingering({ number, position: params.position }), i)));"), [select('position', 'Position', 'left', ['left', 'right', 'above', 'below'])]),
|
|
60
|
+
e('parentheses', 'Parentheses', 'Marks & expression', 'Parenthesize a pitch to indicate an optional or editorial note.', 'Parenthesis', staff("score.notes('C5/q, D5, E5, G5')", 'VF.Parenthesis.buildAndAttach([notes[1], notes[3]]);')),
|
|
61
|
+
];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { example as e, number, select, setup, staff, text } from './helpers.mjs';
|
|
2
|
+
const group = 'Staves & structure';
|
|
3
|
+
export const staves = [
|
|
4
|
+
e('clefs', 'Clefs', group, 'Compare clefs and their positions on the staff.', 'Stave Clef', `${setup}
|
|
5
|
+
const stave = factory.Stave({ x: 35, y: 65, width: width - 70 });
|
|
6
|
+
stave.addClef(params.clef);
|
|
7
|
+
factory.draw();`, [
|
|
8
|
+
select('clef', 'Clef', 'treble', [
|
|
9
|
+
'treble',
|
|
10
|
+
'bass',
|
|
11
|
+
'alto',
|
|
12
|
+
'tenor',
|
|
13
|
+
'soprano',
|
|
14
|
+
'mezzo-soprano',
|
|
15
|
+
'baritone-c',
|
|
16
|
+
'baritone-f',
|
|
17
|
+
'percussion',
|
|
18
|
+
'tab',
|
|
19
|
+
]),
|
|
20
|
+
]),
|
|
21
|
+
e('stave', 'Staff lines', group, 'Change the number and spacing of lines, from a percussion staff to a conventional stave.', 'Stave', `${setup}
|
|
22
|
+
factory.Stave({ x: 35, y: 65, width: width - 70,
|
|
23
|
+
options: { numLines: params.lines, spacingBetweenLinesPx: params.spacing }
|
|
24
|
+
});
|
|
25
|
+
factory.draw();`, [number('lines', 'Lines', 5, 1, 8), number('spacing', 'Spacing', 10, 5, 20)]),
|
|
26
|
+
e('keys', 'Key signatures', group, 'Render sharp and flat key signatures.', 'KeySignature Stave', staff("score.notes('C5/q, D5, E5, G5')", '', '', ".addClef('treble').addKeySignature(params.key)"), [select('key', 'Key', 'D', ['C', 'G', 'D', 'A', 'E', 'B', 'F#', 'C#', 'F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'Cb'])]),
|
|
27
|
+
e('meter', 'Time signatures', group, 'Show simple, compound, common, and cut time.', 'TimeSignature', staff("score.notes('C5/q, E5, G5, C6')", '', '', ".addClef('treble').addTimeSignature(params.time)"), [select('time', 'Meter', '4/4', ['2/4', '3/4', '4/4', '6/8', '9/8', '12/8', 'C', 'C|'])]),
|
|
28
|
+
e('barlines', 'Barlines & repeats', group, 'Draw boundaries, endings, and repeat marks on a staff.', 'Barline Stave', `${setup}
|
|
29
|
+
const stave = factory.Stave({ x: 35, y: 65, width: width - 70 }).addClef('treble');
|
|
30
|
+
stave.setBegBarType(VF.Barline.type.REPEAT_BEGIN);
|
|
31
|
+
stave.setEndBarType(VF.Barline.type[params.ending]);
|
|
32
|
+
factory.draw();`, [
|
|
33
|
+
select('ending', 'End barline', 'REPEAT_END', [
|
|
34
|
+
'SINGLE',
|
|
35
|
+
'DOUBLE',
|
|
36
|
+
'END',
|
|
37
|
+
'REPEAT_BEGIN',
|
|
38
|
+
'REPEAT_END',
|
|
39
|
+
'REPEAT_BOTH',
|
|
40
|
+
'NONE',
|
|
41
|
+
]),
|
|
42
|
+
]),
|
|
43
|
+
e('connectors', 'Staff connectors', group, 'Connect multiple staves with braces, brackets, or a shared barline.', 'StaveConnector System', `${setup}
|
|
44
|
+
const system = factory.System({ x: 45, y: 30, width: width - 80, spaceBetweenStaves: 9 });
|
|
45
|
+
system.addStave({ voices: [score.voice(score.notes('C5/w'))] }).addClef('treble');
|
|
46
|
+
system.addStave({ voices: [score.voice(score.notes('C3/w', { clef: 'bass' }))] }).addClef('bass');
|
|
47
|
+
system.addConnector(params.connector);
|
|
48
|
+
factory.draw();`, [
|
|
49
|
+
select('connector', 'Connector', 'brace', [
|
|
50
|
+
'brace',
|
|
51
|
+
'bracket',
|
|
52
|
+
'singleLeft',
|
|
53
|
+
'singleRight',
|
|
54
|
+
'double',
|
|
55
|
+
'thinDouble',
|
|
56
|
+
]),
|
|
57
|
+
]),
|
|
58
|
+
e('tempo', 'Tempo markings', group, 'Combine a tempo name with a metronome mark.', 'StaveTempo', staff("score.notes('C5/q, E5, G5, C6')", '', '', ".addClef('treble').setTempo({ name: params.name, duration: 'q', bpm: params.bpm }, 0)"), [text('name', 'Tempo', 'Andante'), number('bpm', 'BPM', 76, 30, 220)]),
|
|
59
|
+
e('rehearsal', 'Rehearsal marks & text', group, 'Add a section label and a short instruction to the staff.', 'StaveSection StaveText', staff("score.notes('C5/q, E5, G5, C6')", '', '', ".addClef('treble').setSection(params.section, 0).setText(params.instruction, VF.Modifier.Position.BELOW)"), [text('section', 'Section', 'A'), text('instruction', 'Instruction', 'dolce')]),
|
|
60
|
+
e('volta', 'Volta endings', group, 'Bracket an alternate ending above a repeated section.', 'Volta', staff("score.notes('C5/q, E5, G5, C6')", '', '', ".addClef('treble').setVoltaType(VF.Volta.type.BEGIN_END, params.label, 0)"), [text('label', 'Ending label', '1.')]),
|
|
61
|
+
e('repetition', 'Repeat instructions', group, 'Coda, segno, and textual repeat instructions guide the reader through a score.', 'Repetition', staff("score.notes('C5/q, E5, G5, C6')", '', '', ".addClef('treble').setRepetitionType(VF.Repetition.type[params.mark], 0)"), [
|
|
62
|
+
select('mark', 'Instruction', 'CODA_RIGHT', [
|
|
63
|
+
'CODA_RIGHT',
|
|
64
|
+
'SEGNO_LEFT',
|
|
65
|
+
'DC',
|
|
66
|
+
'DC_AL_CODA',
|
|
67
|
+
'DS_AL_FINE',
|
|
68
|
+
'FINE',
|
|
69
|
+
]),
|
|
70
|
+
]),
|
|
71
|
+
e('changes', 'Changes within a measure', group, 'Insert a clef, key, or meter change into a sequence of tickables.', 'ClefNote KeySigNote TimeSigNote BarNote', `${setup}
|
|
72
|
+
const notes = [
|
|
73
|
+
...score.notes('C5/h'), factory.BarNote(),
|
|
74
|
+
factory.ClefNote({ type: 'bass', options: { size: 'small' } }),
|
|
75
|
+
factory.KeySigNote({ key: 'F' }), factory.TimeSigNote({ time: '3/4' }),
|
|
76
|
+
...score.notes('F3/h', { clef: 'bass' })
|
|
77
|
+
];
|
|
78
|
+
const voice = score.voice(notes).setMode(VF.Voice.Mode.SOFT);
|
|
79
|
+
factory.System({ x: 30, y: 65, width: width - 60 }).addStave({ voices: [voice] }).addClef('treble');
|
|
80
|
+
factory.draw();`),
|
|
81
|
+
e('multirests', 'Multi-measure rests', group, 'Render multi-measure rests as a bar or rest symbols.', 'MultiMeasureRest', `${setup}
|
|
82
|
+
const stave = factory.Stave({ x: 35, y: 65, width: width - 70 }).addClef('treble');
|
|
83
|
+
factory.MultiMeasureRest({ numberOfMeasures: params.measures, useSymbols: params.style === 'symbols' }).setStave(stave);
|
|
84
|
+
factory.draw();`, [number('measures', 'Measures', 8, 1, 32), select('style', 'Style', 'bar', ['bar', 'symbols'])]),
|
|
85
|
+
];
|