vexflow 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- 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 +6502 -1708
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +5622 -1618
- 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/alternatingtremolo.js +68 -0
- package/build/esm/src/annotation.js +19 -3
- package/build/esm/src/articulation.js +28 -6
- package/build/esm/src/beam.js +171 -28
- package/build/esm/src/bend.js +79 -23
- package/build/esm/src/clef.js +3 -0
- package/build/esm/src/continuouslayout.js +681 -0
- package/build/esm/src/continuousspan.js +159 -0
- package/build/esm/src/curve.js +48 -55
- package/build/esm/src/dot.js +13 -4
- package/build/esm/src/easyscore/composition.js +52 -2
- package/build/esm/src/easyscore/policies.js +39 -8
- package/build/esm/src/element.js +4 -0
- package/build/esm/src/engravinggeometry.js +157 -0
- package/build/esm/src/engravingprofile.js +44 -0
- package/build/esm/src/factory.js +31 -11
- package/build/esm/src/font.js +9 -1
- package/build/esm/src/formatter.js +9 -1
- package/build/esm/src/fretdiagram.js +77 -0
- package/build/esm/src/gracenote.js +43 -38
- package/build/esm/src/gracenotegroup.js +53 -56
- package/build/esm/src/guitargesture.js +33 -0
- package/build/esm/src/guitarmodifiers.js +26 -0
- package/build/esm/src/index.js +10 -0
- package/build/esm/src/instrumentprofile.js +123 -0
- package/build/esm/src/keysignature.js +24 -2
- package/build/esm/src/modifiercontext.js +11 -0
- package/build/esm/src/notationspelling.js +73 -0
- package/build/esm/src/note.js +3 -0
- package/build/esm/src/notehead.js +11 -6
- package/build/esm/src/ornament.js +43 -18
- package/build/esm/src/pagebreaks.js +58 -0
- package/build/esm/src/pedalmarking.js +39 -17
- package/build/esm/src/phraselayout.js +503 -0
- package/build/esm/src/phraseribbon.js +28 -0
- package/build/esm/src/proportionalformatter.js +54 -6
- package/build/esm/src/publication.js +402 -0
- package/build/esm/src/publicationview.js +114 -0
- package/build/esm/src/scorenavigation.js +172 -0
- package/build/esm/src/sheet.js +14 -2
- package/build/esm/src/stave.js +33 -16
- package/build/esm/src/stavebarline.js +5 -7
- package/build/esm/src/staveconnector.js +1 -0
- package/build/esm/src/stavehairpin.js +53 -27
- package/build/esm/src/stavenote.js +134 -116
- package/build/esm/src/stavetie.js +66 -9
- package/build/esm/src/stem.js +26 -11
- package/build/esm/src/strokes.js +4 -0
- package/build/esm/src/system.js +19 -4
- package/build/esm/src/systembreaks.js +42 -0
- package/build/esm/src/tabnote.js +6 -1
- package/build/esm/src/textbracket.js +24 -5
- package/build/esm/src/tickcontext.js +19 -0
- package/build/esm/src/timesignature.js +20 -6
- package/build/esm/src/tuplet.js +58 -17
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vexflow.js +20 -0
- package/build/esm/src/voice.js +7 -3
- 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/continuous-studies.mjs +140 -0
- package/build/esm/tests/engraving/instrument-studies.mjs +273 -0
- package/build/esm/tests/engraving/phrase-studies.mjs +63 -0
- package/build/esm/tests/engraving/publication-studies.mjs +87 -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/specialist-studies.mjs +347 -0
- package/build/esm/tests/engraving/studies.mjs +367 -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/continuous-score-tests.mjs +282 -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/instrument-profile-tests.mjs +224 -0
- package/build/esm/tests/node/local-engraving-tests.mjs +128 -0
- package/build/esm/tests/node/phrase-layout-tests.mjs +281 -0
- package/build/esm/tests/node/proportional-spacing-tests.mjs +64 -0
- package/build/esm/tests/node/publication-tests.mjs +219 -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-structure.mjs +1 -1
- package/build/esm/tools/explorer/catalog/entries.mjs +2 -1
- package/build/esm/tools/explorer/catalog/expression.mjs +14 -9
- package/build/esm/tools/explorer/catalog/guitar.mjs +238 -0
- package/build/esm/tools/explorer/catalog/layout.mjs +8 -6
- package/build/esm/tools/explorer/catalog/notes.mjs +16 -14
- package/build/esm/tools/explorer/catalog/staves.mjs +12 -6
- package/build/esm/tools/explorer/catalog/strings.mjs +10 -7
- package/build/esm/tools/score-fixtures.mjs +23 -6
- package/build/types/src/accidental.d.ts +4 -0
- package/build/types/src/alternatingtremolo.d.ts +13 -0
- package/build/types/src/annotation.d.ts +9 -0
- package/build/types/src/articulation.d.ts +9 -1
- package/build/types/src/beam.d.ts +16 -0
- package/build/types/src/bend.d.ts +8 -0
- package/build/types/src/clef.d.ts +3 -0
- package/build/types/src/continuouslayout.d.ts +103 -0
- package/build/types/src/continuousspan.d.ts +60 -0
- package/build/types/src/curve.d.ts +20 -0
- package/build/types/src/dot.d.ts +5 -0
- package/build/types/src/easyscore/composition.d.ts +27 -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/fretdiagram.d.ts +23 -0
- package/build/types/src/gracenote.d.ts +7 -0
- package/build/types/src/gracenotegroup.d.ts +7 -2
- package/build/types/src/guitargesture.d.ts +26 -0
- package/build/types/src/guitarmodifiers.d.ts +3 -0
- package/build/types/src/index.d.ts +12 -0
- package/build/types/src/instrumentprofile.d.ts +124 -0
- package/build/types/src/keysignature.d.ts +9 -0
- package/build/types/src/modifiercontext.d.ts +4 -0
- package/build/types/src/notationspelling.d.ts +25 -0
- package/build/types/src/note.d.ts +15 -0
- package/build/types/src/notehead.d.ts +5 -0
- package/build/types/src/ornament.d.ts +10 -1
- package/build/types/src/pagebreaks.d.ts +26 -0
- package/build/types/src/pedalmarking.d.ts +9 -0
- package/build/types/src/phraselayout.d.ts +87 -0
- package/build/types/src/phraseribbon.d.ts +7 -0
- package/build/types/src/proportionalformatter.d.ts +11 -2
- package/build/types/src/publication.d.ts +61 -0
- package/build/types/src/publicationview.d.ts +27 -0
- package/build/types/src/scorenavigation.d.ts +33 -0
- package/build/types/src/sheet.d.ts +5 -0
- package/build/types/src/stave.d.ts +13 -0
- package/build/types/src/stavehairpin.d.ts +18 -0
- package/build/types/src/stavenote.d.ts +20 -2
- package/build/types/src/stavetie.d.ts +9 -0
- package/build/types/src/stem.d.ts +10 -1
- package/build/types/src/system.d.ts +8 -1
- package/build/types/src/systembreaks.d.ts +9 -0
- package/build/types/src/textbracket.d.ts +7 -0
- package/build/types/src/tickcontext.d.ts +5 -0
- package/build/types/src/timesignature.d.ts +6 -0
- package/build/types/src/tuplet.d.ts +5 -48
- package/build/types/src/vexflow.d.ts +20 -0
- package/build/types/src/voice.d.ts +2 -0
- package/changelog/CHANGELOG.md +25 -0
- package/package.json +15 -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,42 @@
|
|
|
1
|
+
export function chooseSystemBreaks(units, width, gap, indent, mode) {
|
|
2
|
+
var _a;
|
|
3
|
+
const n = units.length;
|
|
4
|
+
const next = Array(n);
|
|
5
|
+
const costs = Array(n + 1).fill(Infinity);
|
|
6
|
+
const clipped = Array(n + 1).fill(Infinity);
|
|
7
|
+
costs[n] = 0;
|
|
8
|
+
clipped[n] = 0;
|
|
9
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
10
|
+
let body = indent(i) + units[i].start;
|
|
11
|
+
let found = false;
|
|
12
|
+
for (let j = i; j < n; j++) {
|
|
13
|
+
if (j > i && units[j].breakBefore === 'force')
|
|
14
|
+
break;
|
|
15
|
+
body += units[j].width + (j > i ? gap : 0);
|
|
16
|
+
if (((_a = units[j + 1]) === null || _a === void 0 ? void 0 : _a.breakBefore) === 'keep')
|
|
17
|
+
continue;
|
|
18
|
+
const spare = width - body - units[j].end;
|
|
19
|
+
if (spare < 0 && found) {
|
|
20
|
+
if (body >= width)
|
|
21
|
+
break;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const overflow = Math.max(0, -spare);
|
|
25
|
+
const cost = costs[j + 1] + width * width * 0.12 + (spare >= 0 ? spare * spare : width * width + 16 * overflow * overflow);
|
|
26
|
+
const clippedWidth = overflow + clipped[j + 1];
|
|
27
|
+
const improves = clippedWidth < clipped[i] || (clippedWidth === clipped[i] && cost <= costs[i]);
|
|
28
|
+
if (!found || (mode === 'greedy' ? spare >= 0 : improves)) {
|
|
29
|
+
clipped[i] = clippedWidth;
|
|
30
|
+
next[i] = j + 1;
|
|
31
|
+
costs[i] = cost;
|
|
32
|
+
}
|
|
33
|
+
found = true;
|
|
34
|
+
if (body >= width)
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const rows = [];
|
|
39
|
+
for (let i = 0; i < n; i = next[i])
|
|
40
|
+
rows.push(Array.from({ length: next[i] - i }, (_, k) => i + k));
|
|
41
|
+
return rows;
|
|
42
|
+
}
|
package/build/esm/src/tabnote.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Element } from './element.js';
|
|
2
2
|
import { Font } from './font.js';
|
|
3
3
|
import { Glyphs } from './glyphs.js';
|
|
4
|
+
import { attachGuitarGestures } from './guitarmodifiers.js';
|
|
4
5
|
import { Metrics } from './metrics.js';
|
|
5
6
|
import { Modifier } from './modifier.js';
|
|
6
7
|
import { Note } from './note.js';
|
|
@@ -90,6 +91,8 @@ export class TabNote extends StemmableNote {
|
|
|
90
91
|
}
|
|
91
92
|
this.ghost = false;
|
|
92
93
|
this.updateWidth();
|
|
94
|
+
if (this.notation.length)
|
|
95
|
+
attachGuitarGestures(this);
|
|
93
96
|
}
|
|
94
97
|
reset() {
|
|
95
98
|
super.reset();
|
|
@@ -279,7 +282,9 @@ export class TabNote extends StemmableNote {
|
|
|
279
282
|
this.setRendered();
|
|
280
283
|
const renderStem = this.beam === undefined && this.renderOptions.drawStem;
|
|
281
284
|
const clsAttribute = this.getAttribute('class');
|
|
282
|
-
ctx.openGroup('tabnote' + (clsAttribute ? ' ' + clsAttribute : ''), this.getAttribute('id'));
|
|
285
|
+
const group = ctx.openGroup('tabnote' + (clsAttribute ? ' ' + clsAttribute : ''), this.getAttribute('id'));
|
|
286
|
+
if (this.notation.length)
|
|
287
|
+
group === null || group === void 0 ? void 0 : group.setAttribute('aria-label', this.notation.map((entry) => entry.label).join(', '));
|
|
283
288
|
this.drawPositions();
|
|
284
289
|
this.drawStemThrough();
|
|
285
290
|
if (this.stem && renderStem) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BoundingBox } from './boundingbox.js';
|
|
1
2
|
import { Element } from './element.js';
|
|
2
3
|
import { Font } from './font.js';
|
|
3
4
|
import { Renderer } from './renderer.js';
|
|
@@ -69,9 +70,11 @@ export class TextBracket extends Element {
|
|
|
69
70
|
this.line = line;
|
|
70
71
|
return this;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
setLayoutBaseline(y) {
|
|
74
|
+
this.layoutBaseline = y;
|
|
75
|
+
}
|
|
76
|
+
geometry() {
|
|
77
|
+
var _a;
|
|
75
78
|
let y = 0;
|
|
76
79
|
switch (this.position) {
|
|
77
80
|
case TextBracketPosition.TOP:
|
|
@@ -83,15 +86,14 @@ export class TextBracket extends Element {
|
|
|
83
86
|
default:
|
|
84
87
|
throw new RuntimeError('InvalidPosition', `The position ${this.position} is invalid.`);
|
|
85
88
|
}
|
|
89
|
+
y = (_a = this.layoutBaseline) !== null && _a !== void 0 ? _a : y;
|
|
86
90
|
const start = { x: this.start.getAbsoluteX(), y };
|
|
87
91
|
const stop = { x: this.stop.getAbsoluteX(), y };
|
|
88
92
|
L('Rendering TextBracket: start:', start, 'stop:', stop, 'y:', y);
|
|
89
93
|
const bracketHeight = this.renderOptions.bracketHeight * this.position;
|
|
90
|
-
this.textElement.renderText(ctx, start.x, start.y);
|
|
91
94
|
const mainWidth = this.textElement.getWidth();
|
|
92
95
|
const mainHeight = this.textElement.getHeight();
|
|
93
96
|
const superY = start.y - mainHeight / 2.5;
|
|
94
|
-
this.superscriptElement.renderText(ctx, start.x + mainWidth + 1, superY);
|
|
95
97
|
const superWidth = this.superscriptElement.getWidth();
|
|
96
98
|
const superHeight = this.superscriptElement.getHeight();
|
|
97
99
|
let startX = start.x;
|
|
@@ -108,6 +110,23 @@ export class TextBracket extends Element {
|
|
|
108
110
|
startX += superWidth;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
113
|
+
return { start, superX: start.x + mainWidth + 1, superY, startX, endX, lineY, bracketHeight };
|
|
114
|
+
}
|
|
115
|
+
getBoundingBox() {
|
|
116
|
+
const { start, superX, superY, startX, endX, lineY, bracketHeight } = this.geometry();
|
|
117
|
+
const pad = this.renderOptions.lineWidth / 2;
|
|
118
|
+
const height = this.renderOptions.showBracket ? bracketHeight : 0;
|
|
119
|
+
return this.textElement
|
|
120
|
+
.getTextInk(start.x, start.y)
|
|
121
|
+
.mergeWith(this.superscriptElement.getTextInk(superX, superY))
|
|
122
|
+
.mergeWith(new BoundingBox(Math.min(startX, endX) - pad, Math.min(lineY, lineY + height) - pad, Math.abs(endX - startX) + 2 * pad, Math.abs(height) + 2 * pad));
|
|
123
|
+
}
|
|
124
|
+
draw() {
|
|
125
|
+
const ctx = this.checkContext();
|
|
126
|
+
this.setRendered();
|
|
127
|
+
const { start, superX, superY, startX, endX, lineY, bracketHeight } = this.geometry();
|
|
128
|
+
this.textElement.renderText(ctx, start.x, start.y);
|
|
129
|
+
this.superscriptElement.renderText(ctx, superX, superY);
|
|
111
130
|
if (this.renderOptions.dashed) {
|
|
112
131
|
Renderer.drawDashedLine(ctx, startX, lineY, endX, lineY, this.renderOptions.dash);
|
|
113
132
|
if (this.renderOptions.showBracket) {
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { Fraction } from './fraction.js';
|
|
2
2
|
import { RuntimeError, sumArray } from './util.js';
|
|
3
3
|
export class TickContext {
|
|
4
|
+
static linkTimeline(contexts) {
|
|
5
|
+
contexts.forEach((context, i) => {
|
|
6
|
+
context.nextAttack = contexts[i + 1];
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
*through(last) {
|
|
10
|
+
if (this.tickID > last.tickID)
|
|
11
|
+
return;
|
|
12
|
+
yield this;
|
|
13
|
+
if (this === last)
|
|
14
|
+
return;
|
|
15
|
+
let context = this.nextAttack;
|
|
16
|
+
while (context && context.tickID <= last.tickID) {
|
|
17
|
+
yield context;
|
|
18
|
+
if (context === last)
|
|
19
|
+
return;
|
|
20
|
+
context = context.nextAttack;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
4
23
|
static getNextContext(tContext) {
|
|
5
24
|
const contexts = tContext.tContexts;
|
|
6
25
|
const index = contexts.indexOf(tContext);
|
|
@@ -34,6 +34,11 @@ export class TimeSignature extends StaveModifier {
|
|
|
34
34
|
this.setTimeSig(timeSpec);
|
|
35
35
|
this.setPadding(padding);
|
|
36
36
|
}
|
|
37
|
+
setMusicFont(family) {
|
|
38
|
+
for (const element of [this, this.topText, this.botText])
|
|
39
|
+
element.setFont(Object.assign(Object.assign({}, element.fontInfo), { family }));
|
|
40
|
+
return this.setTimeSig(this.timeSpec);
|
|
41
|
+
}
|
|
37
42
|
static getTimeSigCode(key, smallSig = false) {
|
|
38
43
|
let code = Glyphs.null;
|
|
39
44
|
switch (key) {
|
|
@@ -135,12 +140,7 @@ export class TimeSignature extends StaveModifier {
|
|
|
135
140
|
this.setRendered();
|
|
136
141
|
if (this.isNumeric) {
|
|
137
142
|
let startX = x + this.topStartX;
|
|
138
|
-
|
|
139
|
-
this.topRenderY = stave.getYForLine(this.topLine - this.lineShift);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.topRenderY = (stave.getYForLine(this.topLine) + stave.getYForLine(this.bottomLine)) / 2;
|
|
143
|
-
}
|
|
143
|
+
this.topRenderY = this.topBaseline(stave);
|
|
144
144
|
this.topText.renderText(ctx, startX, this.topRenderY);
|
|
145
145
|
startX = x + this.botStartX;
|
|
146
146
|
this.botRenderY = stave.getYForLine(this.bottomLine + this.lineShift);
|
|
@@ -150,6 +150,20 @@ export class TimeSignature extends StaveModifier {
|
|
|
150
150
|
this.renderText(ctx, x - this.x, stave.getYForLine(this.line));
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
topBaseline(stave) {
|
|
154
|
+
return this.botText.getText().length
|
|
155
|
+
? stave.getYForLine(this.topLine - this.lineShift)
|
|
156
|
+
: (stave.getYForLine(this.topLine) + stave.getYForLine(this.bottomLine)) / 2;
|
|
157
|
+
}
|
|
158
|
+
getInkBounds() {
|
|
159
|
+
const stave = this.checkStave();
|
|
160
|
+
if (!this.isNumeric)
|
|
161
|
+
return this.getTextInk(this.x, stave.getYForLine(this.line));
|
|
162
|
+
const top = this.topText.getTextInk(this.x + this.topStartX, this.topBaseline(stave));
|
|
163
|
+
return this.botText.getText().length
|
|
164
|
+
? top.mergeWith(this.botText.getTextInk(this.x + this.botStartX, stave.getYForLine(this.bottomLine + this.lineShift)))
|
|
165
|
+
: top;
|
|
166
|
+
}
|
|
153
167
|
getBoundingBox() {
|
|
154
168
|
if (this.isNumeric) {
|
|
155
169
|
const topBoundingBox = this.topText.getBoundingBox();
|
package/build/esm/src/tuplet.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { Annotation } from './annotation.js';
|
|
2
|
+
import { Articulation } from './articulation.js';
|
|
1
3
|
import { BoundingBox } from './boundingbox.js';
|
|
2
4
|
import { Element } from './element.js';
|
|
3
5
|
import { Formatter } from './formatter.js';
|
|
4
6
|
import { Glyphs } from './glyphs.js';
|
|
5
7
|
import { Metrics } from './metrics.js';
|
|
8
|
+
import { Modifier } from './modifier.js';
|
|
9
|
+
import { Ornament } from './ornament.js';
|
|
6
10
|
import { Stem } from './stem.js';
|
|
7
11
|
import { Tables } from './tables.js';
|
|
12
|
+
import { isAnnotation } from './typeguard.js';
|
|
8
13
|
import { RuntimeError } from './util.js';
|
|
9
14
|
export class Tuplet extends Element {
|
|
10
15
|
static get CATEGORY() {
|
|
@@ -34,7 +39,11 @@ export class Tuplet extends Element {
|
|
|
34
39
|
const yOffset = (_a = options.yOffset) !== null && _a !== void 0 ? _a : Metrics.get('Tuplet.yOffset');
|
|
35
40
|
const textYOffset = (_b = options.textYOffset) !== null && _b !== void 0 ? _b : Metrics.get('Tuplet.textYOffset');
|
|
36
41
|
const suffix = options.suffix || '';
|
|
42
|
+
if (options.displayRatio &&
|
|
43
|
+
(options.displayRatio.length !== 2 || !options.displayRatio.every((n) => Number.isSafeInteger(n) && n > 0)))
|
|
44
|
+
throw new RuntimeError('BadArguments', 'Tuplet display ratio requires two positive integers.');
|
|
37
45
|
this.options = {
|
|
46
|
+
displayRatio: options.displayRatio && [...options.displayRatio],
|
|
38
47
|
bracketed,
|
|
39
48
|
location,
|
|
40
49
|
notesOccupied,
|
|
@@ -71,6 +80,7 @@ export class Tuplet extends Element {
|
|
|
71
80
|
}
|
|
72
81
|
setRatioed(ratioed) {
|
|
73
82
|
this.options.ratioed = ratioed;
|
|
83
|
+
this.resolveGlyphs();
|
|
74
84
|
return this;
|
|
75
85
|
}
|
|
76
86
|
setTupletLocation(location) {
|
|
@@ -97,15 +107,16 @@ export class Tuplet extends Element {
|
|
|
97
107
|
this.attach();
|
|
98
108
|
}
|
|
99
109
|
resolveGlyphs() {
|
|
110
|
+
var _a, _b, _c, _d;
|
|
100
111
|
let numerator = '';
|
|
101
112
|
let denominator = '';
|
|
102
|
-
let n = this.options.numNotes;
|
|
113
|
+
let n = (_b = (_a = this.options.displayRatio) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.options.numNotes;
|
|
103
114
|
while (n >= 1) {
|
|
104
115
|
numerator = String.fromCharCode(0xe880 + (n % 10)) + numerator;
|
|
105
116
|
n = Math.floor(n / 10);
|
|
106
117
|
}
|
|
107
118
|
if (this.options.ratioed) {
|
|
108
|
-
n = this.options.notesOccupied;
|
|
119
|
+
n = (_d = (_c = this.options.displayRatio) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : this.options.notesOccupied;
|
|
109
120
|
while (n >= 1) {
|
|
110
121
|
denominator = String.fromCharCode(0xe880 + (n % 10)) + denominator;
|
|
111
122
|
n = Math.floor(n / 10);
|
|
@@ -132,7 +143,7 @@ export class Tuplet extends Element {
|
|
|
132
143
|
return maxOffset;
|
|
133
144
|
}
|
|
134
145
|
getYPosition() {
|
|
135
|
-
var _a;
|
|
146
|
+
var _a, _b, _c;
|
|
136
147
|
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.options.location;
|
|
137
148
|
const yOffset = (_a = this.options.yOffset) !== null && _a !== void 0 ? _a : 0;
|
|
138
149
|
const firstNote = this.notes[0];
|
|
@@ -144,7 +155,7 @@ export class Tuplet extends Element {
|
|
|
144
155
|
let modLines = 0;
|
|
145
156
|
const mc = note.getModifierContext();
|
|
146
157
|
if (mc) {
|
|
147
|
-
modLines =
|
|
158
|
+
modLines = mc.getUnmeasuredTextLines(true);
|
|
148
159
|
}
|
|
149
160
|
const modY = note.getYForTopText(modLines) - 2 * Tables.STAVE_LINE_DISTANCE;
|
|
150
161
|
if (note.hasStem() || note.isRest()) {
|
|
@@ -163,7 +174,7 @@ export class Tuplet extends Element {
|
|
|
163
174
|
this.notes.forEach((nn) => {
|
|
164
175
|
const mc = nn.getModifierContext();
|
|
165
176
|
if (mc) {
|
|
166
|
-
lineCheck = Math.max(lineCheck, mc.
|
|
177
|
+
lineCheck = Math.max(lineCheck, mc.getUnmeasuredTextLines(false) + 1);
|
|
167
178
|
}
|
|
168
179
|
});
|
|
169
180
|
yPosition = firstNote.checkStave().getYForLine(lineCheck) + 2 * Tables.STAVE_LINE_DISTANCE;
|
|
@@ -178,16 +189,45 @@ export class Tuplet extends Element {
|
|
|
178
189
|
}
|
|
179
190
|
}
|
|
180
191
|
}
|
|
192
|
+
const above = this.options.location === Tuplet.LOCATION_TOP;
|
|
193
|
+
const side = above ? Annotation.VerticalJustify.TOP : Annotation.VerticalJustify.BOTTOM;
|
|
194
|
+
const hook = this.options.bracketed ? Metrics.get('Tuplet.bracket.legLength') : this.textElement.getHeight() / 2;
|
|
195
|
+
const padding = hook + firstNote.checkStave().getSpacingBetweenLines() / 4;
|
|
196
|
+
for (const note of this.notes) {
|
|
197
|
+
for (const mark of note.getModifiers()) {
|
|
198
|
+
if (mark.getPosition() !== (above ? Modifier.Position.ABOVE : Modifier.Position.BELOW))
|
|
199
|
+
continue;
|
|
200
|
+
const box = mark instanceof Articulation
|
|
201
|
+
? mark.getInkBounds()
|
|
202
|
+
: mark instanceof Ornament
|
|
203
|
+
? mark.getBoundingBox()
|
|
204
|
+
: undefined;
|
|
205
|
+
if (box)
|
|
206
|
+
yPosition = above ? Math.min(yPosition, box.y - padding) : Math.max(yPosition, box.y + box.h + padding);
|
|
207
|
+
}
|
|
208
|
+
const annotations = (_c = (_b = note.getModifierContext()) === null || _b === void 0 ? void 0 : _b.getMembers("Annotation")) !== null && _c !== void 0 ? _c : [];
|
|
209
|
+
for (const mark of annotations) {
|
|
210
|
+
if (!isAnnotation(mark) ||
|
|
211
|
+
mark.phraseManaged ||
|
|
212
|
+
mark.getVerticalJustification() !== side ||
|
|
213
|
+
mark.checkAttachedNote().getStave() !== note.getStave())
|
|
214
|
+
continue;
|
|
215
|
+
const baseline = mark.computeY().y + mark.getYShift();
|
|
216
|
+
const ink = mark.getTextMetrics();
|
|
217
|
+
yPosition = above
|
|
218
|
+
? Math.min(yPosition, baseline - ink.actualBoundingBoxAscent - padding)
|
|
219
|
+
: Math.max(yPosition, baseline + ink.actualBoundingBoxDescent + padding);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
181
222
|
return yPosition + nestedTupletYOffset + yOffset;
|
|
182
223
|
}
|
|
183
|
-
|
|
224
|
+
positionElements() {
|
|
184
225
|
const { location, bracketed, textYOffset, suffix } = this.options;
|
|
185
226
|
const bracketPadding = Metrics.get('Tuplet.bracket.padding');
|
|
186
227
|
const bracketThickness = Metrics.get('Tuplet.bracket.lineWidth');
|
|
187
228
|
const bracketLegLength = Metrics.get('Tuplet.bracket.legLength');
|
|
188
229
|
const extraSpacing = Metrics.get('Tuplet.suffix.extraSpacing');
|
|
189
230
|
const suffixOffsetY = Metrics.get('Tuplet.suffix.suffixOffsetY');
|
|
190
|
-
const ctx = this.checkContext();
|
|
191
231
|
let xPos = 0;
|
|
192
232
|
let yPos = 0;
|
|
193
233
|
const firstNote = this.notes[0];
|
|
@@ -217,6 +257,15 @@ export class Tuplet extends Element {
|
|
|
217
257
|
const notationCenterX = xPos + bodyWidth / 2;
|
|
218
258
|
const notationStartX = notationCenterX - totalTextWidth / 2;
|
|
219
259
|
const commonTextY = yPos + this.textElement.getHeight() / 2 + (location === Tuplet.LOCATION_TOP ? -1 : 1) * textYOffset;
|
|
260
|
+
this.textElement.setX(notationStartX).setY(commonTextY);
|
|
261
|
+
if (suffix)
|
|
262
|
+
this.suffixElement.setX(notationStartX + ratioWidth + extraSpacing).setY(commonTextY + suffixOffsetY);
|
|
263
|
+
return { xPos, yPos, bodyWidth, totalTextWidth, bracketPadding, bracketThickness, bracketLegLength };
|
|
264
|
+
}
|
|
265
|
+
draw() {
|
|
266
|
+
const { location, bracketed, suffix } = this.options;
|
|
267
|
+
const { xPos, yPos, bodyWidth, totalTextWidth, bracketPadding, bracketThickness, bracketLegLength } = this.positionElements();
|
|
268
|
+
const ctx = this.checkContext();
|
|
220
269
|
const clsAttribute = this.getAttribute('class');
|
|
221
270
|
ctx.openGroup('tuplet' + (clsAttribute ? ' ' + clsAttribute : ''), this.getAttribute('id'));
|
|
222
271
|
if (bracketed) {
|
|
@@ -229,23 +278,15 @@ export class Tuplet extends Element {
|
|
|
229
278
|
ctx.fillRect(xPos + bodyWidth, yPos + (isTupletBottom ? 1 : 0), bracketThickness, location * bracketLegLength);
|
|
230
279
|
}
|
|
231
280
|
}
|
|
232
|
-
let currentX = notationStartX;
|
|
233
|
-
this.textElement.setX(currentX);
|
|
234
|
-
this.textElement.setY(commonTextY);
|
|
235
281
|
this.textElement.renderText(ctx, 0, 0);
|
|
236
|
-
|
|
237
|
-
if (suffix) {
|
|
238
|
-
const suffixY = commonTextY + suffixOffsetY;
|
|
239
|
-
this.suffixElement.setX(currentX);
|
|
240
|
-
this.suffixElement.setY(suffixY);
|
|
282
|
+
if (suffix)
|
|
241
283
|
this.suffixElement.renderText(ctx, 0, 0);
|
|
242
|
-
currentX += noteWidth;
|
|
243
|
-
}
|
|
244
284
|
this.drawPointerRect();
|
|
245
285
|
ctx.closeGroup();
|
|
246
286
|
this.setRendered();
|
|
247
287
|
}
|
|
248
288
|
getBoundingBox() {
|
|
289
|
+
this.positionElements();
|
|
249
290
|
const { bracketed, suffix } = this.options;
|
|
250
291
|
const ratioBounding = this.textElement.getBoundingBox();
|
|
251
292
|
const suffixBounding = this.suffixElement.getBoundingBox();
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '5.
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2026-11-
|
|
1
|
+
export const VERSION = '5.4.0';
|
|
2
|
+
export const ID = '30054199edf019f97dcea2f2939430198f387f49';
|
|
3
|
+
export const DATE = '2026-11-19T00:43:30.372Z';
|
package/build/esm/src/vexflow.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Accidental } from './accidental.js';
|
|
11
|
+
import { AlternatingTremolo } from './alternatingtremolo.js';
|
|
11
12
|
import { Annotation, AnnotationHorizontalJustify, AnnotationVerticalJustify } from './annotation.js';
|
|
12
13
|
import { Articulation } from './articulation.js';
|
|
13
14
|
import { BarNote } from './barnote.js';
|
|
@@ -23,10 +24,13 @@ import { Curve, CurvePosition } from './curve.js';
|
|
|
23
24
|
import { Dot } from './dot.js';
|
|
24
25
|
import { EasyScore, EasyScoreError } from './easyscore.js';
|
|
25
26
|
import { Element } from './element.js';
|
|
27
|
+
import { measureEngraving } from './engravinggeometry.js';
|
|
28
|
+
import { EngravingProfile } from './engravingprofile.js';
|
|
26
29
|
import { Factory } from './factory.js';
|
|
27
30
|
import { Font, FontStyle, FontWeight } from './font.js';
|
|
28
31
|
import { Formatter } from './formatter.js';
|
|
29
32
|
import { Fraction } from './fraction.js';
|
|
33
|
+
import { FretDiagram } from './fretdiagram.js';
|
|
30
34
|
import { FretHandFinger } from './frethandfinger.js';
|
|
31
35
|
import { GhostNote } from './ghostnote.js';
|
|
32
36
|
import { GlyphNote } from './glyphnote.js';
|
|
@@ -34,6 +38,7 @@ import { Glyphs } from './glyphs.js';
|
|
|
34
38
|
import { GraceNote } from './gracenote.js';
|
|
35
39
|
import { GraceNoteGroup } from './gracenotegroup.js';
|
|
36
40
|
import { GraceTabNote } from './gracetabnote.js';
|
|
41
|
+
import { FrettedInstrument, PercussionMap } from './instrumentprofile.js';
|
|
37
42
|
import { KeyManager } from './keymanager.js';
|
|
38
43
|
import { KeySignature } from './keysignature.js';
|
|
39
44
|
import { KeySigNote } from './keysignote.js';
|
|
@@ -42,6 +47,7 @@ import { Modifier, ModifierPosition } from './modifier.js';
|
|
|
42
47
|
import { ModifierContext } from './modifiercontext.js';
|
|
43
48
|
import { MultiMeasureRest } from './multimeasurerest.js';
|
|
44
49
|
import { Music } from './music.js';
|
|
50
|
+
import { NotationSpelling, WrittenAccidentalState } from './notationspelling.js';
|
|
45
51
|
import { Note } from './note.js';
|
|
46
52
|
import { NoteHead } from './notehead.js';
|
|
47
53
|
import { NoteSubGroup } from './notesubgroup.js';
|
|
@@ -49,10 +55,13 @@ import { Ornament } from './ornament.js';
|
|
|
49
55
|
import { Parenthesis } from './parenthesis.js';
|
|
50
56
|
import { Parser } from './parser.js';
|
|
51
57
|
import { PedalMarking } from './pedalmarking.js';
|
|
58
|
+
import { PhraseLayout } from './phraselayout.js';
|
|
59
|
+
import { Publication } from './publication.js';
|
|
52
60
|
import { Registry } from './registry.js';
|
|
53
61
|
import { RenderContext } from './rendercontext.js';
|
|
54
62
|
import { Renderer, RendererBackends, RendererLineEndType } from './renderer.js';
|
|
55
63
|
import { RepeatNote } from './repeatnote.js';
|
|
64
|
+
import { ScoreNavigation } from './scorenavigation.js';
|
|
56
65
|
import { Sheet } from './sheet.js';
|
|
57
66
|
import { Stave } from './stave.js';
|
|
58
67
|
import { Barline, BarlineType, RepeatBracketType } from './stavebarline.js';
|
|
@@ -219,6 +228,9 @@ VexFlow.BUILD = {
|
|
|
219
228
|
DATE: DATE,
|
|
220
229
|
INFO: '',
|
|
221
230
|
};
|
|
231
|
+
VexFlow.measureEngraving = measureEngraving;
|
|
232
|
+
VexFlow.PhraseLayout = PhraseLayout;
|
|
233
|
+
VexFlow.EngravingProfile = EngravingProfile;
|
|
222
234
|
VexFlow.Accidental = Accidental;
|
|
223
235
|
VexFlow.Annotation = Annotation;
|
|
224
236
|
VexFlow.Articulation = Articulation;
|
|
@@ -280,7 +292,15 @@ VexFlow.StringNumber = StringNumber;
|
|
|
280
292
|
VexFlow.Stroke = Stroke;
|
|
281
293
|
VexFlow.SVGContext = SVGContext;
|
|
282
294
|
VexFlow.System = System;
|
|
295
|
+
VexFlow.ScoreNavigation = ScoreNavigation;
|
|
283
296
|
VexFlow.Sheet = Sheet;
|
|
297
|
+
VexFlow.FrettedInstrument = FrettedInstrument;
|
|
298
|
+
VexFlow.PercussionMap = PercussionMap;
|
|
299
|
+
VexFlow.FretDiagram = FretDiagram;
|
|
300
|
+
VexFlow.AlternatingTremolo = AlternatingTremolo;
|
|
301
|
+
VexFlow.WrittenAccidentalState = WrittenAccidentalState;
|
|
302
|
+
VexFlow.NotationSpelling = NotationSpelling;
|
|
303
|
+
VexFlow.Publication = Publication;
|
|
284
304
|
VexFlow.TabNote = TabNote;
|
|
285
305
|
VexFlow.TabSlide = TabSlide;
|
|
286
306
|
VexFlow.TabStave = TabStave;
|
package/build/esm/src/voice.js
CHANGED
|
@@ -24,6 +24,7 @@ export class Voice extends Element {
|
|
|
24
24
|
this.ticksUsed = new Fraction(0, 1);
|
|
25
25
|
this.largestTickWidth = 0;
|
|
26
26
|
this.tickables = [];
|
|
27
|
+
this.preserveStaveAssignments = false;
|
|
27
28
|
this.options = {
|
|
28
29
|
softmaxFactor: Tables.SOFTMAX_FACTOR,
|
|
29
30
|
};
|
|
@@ -199,12 +200,15 @@ export class Voice extends Element {
|
|
|
199
200
|
return defined(this.stave, 'NoStave', 'No stave attached to instance.');
|
|
200
201
|
}
|
|
201
202
|
draw(context = this.checkContext(), stave) {
|
|
202
|
-
|
|
203
|
+
const override = stave !== null && stave !== void 0 ? stave : (this.preserveStaveAssignments ? undefined : this.stave);
|
|
203
204
|
this.setRendered();
|
|
204
205
|
for (let i = 0; i < this.tickables.length; ++i) {
|
|
205
206
|
const tickable = this.tickables[i];
|
|
206
|
-
if (
|
|
207
|
-
tickable.setStave(
|
|
207
|
+
if (override) {
|
|
208
|
+
tickable.setStave(override);
|
|
209
|
+
}
|
|
210
|
+
else if (this.preserveStaveAssignments && !tickable.getStave() && this.stave) {
|
|
211
|
+
tickable.setStave(this.stave);
|
|
208
212
|
}
|
|
209
213
|
defined(tickable.getStave(), 'MissingStave', 'The voice cannot draw tickables without staves.');
|
|
210
214
|
tickable.setContext(context);
|
|
@@ -146,7 +146,20 @@ function reverseBends(options, contextBuilder) {
|
|
|
146
146
|
.addTickable(note)
|
|
147
147
|
.preFormat()
|
|
148
148
|
.setX(75 * i);
|
|
149
|
-
|
|
149
|
+
const arrowXs = [];
|
|
150
|
+
const quadratic = ctx.quadraticCurveTo.bind(ctx);
|
|
151
|
+
ctx.quadraticCurveTo = (cx, cy, x, y) => {
|
|
152
|
+
arrowXs.push(x);
|
|
153
|
+
return quadratic(cx, cy, x, y);
|
|
154
|
+
};
|
|
155
|
+
try {
|
|
156
|
+
note.setStave(stave).setContext(ctx).drawWithStyle();
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
ctx.quadraticCurveTo = quadratic;
|
|
160
|
+
}
|
|
161
|
+
if (i < 2)
|
|
162
|
+
options.assert.ok(arrowXs[0] > arrowXs[1], 'Lower string uses the outer curve');
|
|
150
163
|
Note.plotMetrics(ctx, note, 140);
|
|
151
164
|
options.assert.ok(true, 'Bend ' + i);
|
|
152
165
|
}
|
|
@@ -22,11 +22,12 @@ function createTest(noteGroup1, noteGroup2, setupCurves) {
|
|
|
22
22
|
score.beam(score.notes(...noteGroup1)),
|
|
23
23
|
score.beam(score.notes(...noteGroup2)),
|
|
24
24
|
].reduce(concat);
|
|
25
|
-
setupCurves(factory, staveNotes);
|
|
25
|
+
const check = setupCurves(factory, staveNotes);
|
|
26
26
|
const voices = [score.voice(staveNotes, { time: '4/4' })];
|
|
27
27
|
factory.Formatter().joinVoices(voices).formatToStave(voices, stave);
|
|
28
28
|
factory.draw();
|
|
29
|
-
options.assert
|
|
29
|
+
check === null || check === void 0 ? void 0 : check(options.assert);
|
|
30
|
+
options.assert.ok(true, 'Curve renders');
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
const simple = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5, d5, g5', { stem: 'down' }], (f, notes) => {
|
|
@@ -59,16 +60,20 @@ const openingDirUp = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5
|
|
|
59
60
|
openingDirection: 'up',
|
|
60
61
|
},
|
|
61
62
|
});
|
|
62
|
-
f.Curve({
|
|
63
|
+
const lower = f.Curve({
|
|
63
64
|
from: notes[4],
|
|
64
65
|
to: notes[7],
|
|
65
66
|
options: {
|
|
66
67
|
openingDirection: 'up',
|
|
67
68
|
},
|
|
68
69
|
});
|
|
70
|
+
return (assert) => {
|
|
71
|
+
const tips = [notes[4], notes[7]].map((note) => note.getStemExtents().topY);
|
|
72
|
+
assert.ok(lower.getBoundingBox().getY() > Math.min(...tips), 'Opening-up slur clears the down-stem beam');
|
|
73
|
+
};
|
|
69
74
|
});
|
|
70
75
|
const openingDirDown = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8, f5, d5, g5', { stem: 'down' }], (f, notes) => {
|
|
71
|
-
f.Curve({
|
|
76
|
+
const upper = f.Curve({
|
|
72
77
|
from: notes[0],
|
|
73
78
|
to: notes[3],
|
|
74
79
|
options: {
|
|
@@ -82,6 +87,11 @@ const openingDirDown = createTest(['c4/8, f5, d5, g5', { stem: 'up' }], ['d6/8,
|
|
|
82
87
|
openingDirection: 'down',
|
|
83
88
|
},
|
|
84
89
|
});
|
|
90
|
+
return (assert) => {
|
|
91
|
+
const tips = [notes[0], notes[3]].map((note) => note.getStemExtents().topY);
|
|
92
|
+
const bounds = upper.getBoundingBox();
|
|
93
|
+
assert.ok(bounds.getY() + bounds.getH() < Math.max(...tips), 'Opening-down slur clears the up-stem beam');
|
|
94
|
+
};
|
|
85
95
|
});
|
|
86
96
|
const rounded = createTest(['c5/8, f4, d4, g5', { stem: 'up' }], ['d5/8, d6, d6, g5', { stem: 'down' }], (f, notes) => {
|
|
87
97
|
f.Curve({
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { drums } from './demos/drums.js';
|
|
3
|
+
import { electric } from './demos/electric.js';
|
|
4
|
+
import { greensleeves } from './demos/greensleeves.js';
|
|
5
|
+
import { joy } from './demos/joy.js';
|
|
6
|
+
import { kesh } from './demos/kesh.js';
|
|
7
|
+
import { prelude } from './demos/prelude.js';
|
|
8
|
+
import { quartertones } from './demos/quartertones.js';
|
|
9
|
+
import { saints } from './demos/saints.js';
|
|
10
|
+
const repertoire = [
|
|
11
|
+
{ title: 'When the Saints Go Marching In', render: saints, fonts: ['Petaluma'] },
|
|
12
|
+
{ title: 'Greensleeves', render: greensleeves },
|
|
13
|
+
{ title: 'Prelude in C major', render: prelude },
|
|
14
|
+
{ title: 'The Kesh Jig', render: kesh },
|
|
15
|
+
{ title: 'Ode to Joy', render: joy },
|
|
16
|
+
{ title: 'High Wire', render: electric },
|
|
17
|
+
{ title: 'Pocket Change', render: drums },
|
|
18
|
+
{ title: 'Narrow Steps', render: quartertones },
|
|
19
|
+
];
|
|
20
|
+
for (const piece of repertoire) {
|
|
21
|
+
VexFlowTests.register({
|
|
22
|
+
Start() {
|
|
23
|
+
QUnit.module('Demo - ' + piece.title);
|
|
24
|
+
VexFlowTests.runTests(piece.title, piece.render, undefined, piece.fonts);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { VexFlowTests } from '../vexflow_test_helpers.js';
|
|
2
|
+
import { BarlineType, Modifier, Stem } from '../../src/index.js';
|
|
3
|
+
export function drums(options) {
|
|
4
|
+
const f = VexFlowTests.makeFactory(options, 900, 350);
|
|
5
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
6
|
+
const hat = 'g/5/x2';
|
|
7
|
+
const snare = 'c/5';
|
|
8
|
+
const hand = (...keys) => score.make.note({ keys, duration: '8', stemDirection: Stem.UP });
|
|
9
|
+
const kicks = [
|
|
10
|
+
'F4/q, D4/q/r, F4/8, F4, D4/q/r',
|
|
11
|
+
'F4/q., F4/8, F4/q, D4/q/r',
|
|
12
|
+
'F4/q, D4/q/r, F4/8, F4, D4/q/r',
|
|
13
|
+
'F4/q, D4/q/r, F4/q, F4',
|
|
14
|
+
];
|
|
15
|
+
kicks.forEach((kick, i) => {
|
|
16
|
+
const fill = i === 3;
|
|
17
|
+
const hands = [hand(hat), hand(hat), hand(snare, hat), hand(hat)];
|
|
18
|
+
hands[2].addModifier(score.make.articulation({ type: 'accent', position: 'above' }));
|
|
19
|
+
score.beam(hands.slice());
|
|
20
|
+
if (fill) {
|
|
21
|
+
for (const run of [
|
|
22
|
+
[snare, snare, 'e/5'],
|
|
23
|
+
['d/5', 'a/4', 'a/4'],
|
|
24
|
+
]) {
|
|
25
|
+
const triplet = run.map((drum) => hand(drum));
|
|
26
|
+
score.beam(triplet);
|
|
27
|
+
score.make.tuplet({ notes: triplet, options: { numNotes: 3, notesOccupied: 2 } });
|
|
28
|
+
hands.push(...triplet);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const answer = [hand(hat), hand(snare, hat), hand(snare, hat), hand(hat)];
|
|
33
|
+
answer[1].addModifier(score.make.parenthesis(Modifier.Position.LEFT), 0);
|
|
34
|
+
answer[1].addModifier(score.make.parenthesis(Modifier.Position.RIGHT), 0);
|
|
35
|
+
answer[2].addModifier(score.make.articulation({ type: 'accent', position: 'above' }));
|
|
36
|
+
score.beam(answer);
|
|
37
|
+
hands.push(...answer);
|
|
38
|
+
}
|
|
39
|
+
const feet = score.notes(kick, { stem: 'down' });
|
|
40
|
+
if (i === 0 || i === 2)
|
|
41
|
+
score.beam(feet.slice(2, 4));
|
|
42
|
+
const stave = f
|
|
43
|
+
.System({ x: 16 + (i % 2) * 432, y: 56 + Math.floor(i / 2) * 148, width: 432 })
|
|
44
|
+
.addStave({ voices: [score.voice(hands), score.voice(feet)] });
|
|
45
|
+
if (i % 2 === 0)
|
|
46
|
+
stave.addClef('percussion');
|
|
47
|
+
if (i === 0)
|
|
48
|
+
stave.addTimeSignature('4/4').setTempo({ name: 'In the pocket', duration: 'q', bpm: 92 }, -43);
|
|
49
|
+
if (fill)
|
|
50
|
+
stave.setEndBarType(BarlineType.REPEAT_END);
|
|
51
|
+
});
|
|
52
|
+
f.draw();
|
|
53
|
+
options.assert.ok(true, 'Independent kick and hands finish together after the triplet fill');
|
|
54
|
+
}
|