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
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() {
|
|
@@ -20,6 +25,7 @@ export class Tuplet extends Element {
|
|
|
20
25
|
return 15;
|
|
21
26
|
}
|
|
22
27
|
constructor(notes, options = {}) {
|
|
28
|
+
var _a, _b;
|
|
23
29
|
super();
|
|
24
30
|
if (!notes || !notes.length) {
|
|
25
31
|
throw new RuntimeError('BadArguments', 'No notes provided for tuplet.');
|
|
@@ -30,10 +36,14 @@ export class Tuplet extends Element {
|
|
|
30
36
|
const bracketed = options.bracketed !== undefined ? options.bracketed : notes.some((note) => !note.hasBeam());
|
|
31
37
|
const ratioed = options.ratioed !== undefined ? options.ratioed : Math.abs(notesOccupied - numNotes) > 1;
|
|
32
38
|
const location = options.location || Tuplet.LOCATION_TOP;
|
|
33
|
-
const yOffset = options.yOffset
|
|
34
|
-
const textYOffset = options.textYOffset
|
|
39
|
+
const yOffset = (_a = options.yOffset) !== null && _a !== void 0 ? _a : Metrics.get('Tuplet.yOffset');
|
|
40
|
+
const textYOffset = (_b = options.textYOffset) !== null && _b !== void 0 ? _b : Metrics.get('Tuplet.textYOffset');
|
|
35
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.');
|
|
36
45
|
this.options = {
|
|
46
|
+
displayRatio: options.displayRatio && [...options.displayRatio],
|
|
37
47
|
bracketed,
|
|
38
48
|
location,
|
|
39
49
|
notesOccupied,
|
|
@@ -70,6 +80,7 @@ export class Tuplet extends Element {
|
|
|
70
80
|
}
|
|
71
81
|
setRatioed(ratioed) {
|
|
72
82
|
this.options.ratioed = ratioed;
|
|
83
|
+
this.resolveGlyphs();
|
|
73
84
|
return this;
|
|
74
85
|
}
|
|
75
86
|
setTupletLocation(location) {
|
|
@@ -96,15 +107,16 @@ export class Tuplet extends Element {
|
|
|
96
107
|
this.attach();
|
|
97
108
|
}
|
|
98
109
|
resolveGlyphs() {
|
|
110
|
+
var _a, _b, _c, _d;
|
|
99
111
|
let numerator = '';
|
|
100
112
|
let denominator = '';
|
|
101
|
-
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;
|
|
102
114
|
while (n >= 1) {
|
|
103
115
|
numerator = String.fromCharCode(0xe880 + (n % 10)) + numerator;
|
|
104
116
|
n = Math.floor(n / 10);
|
|
105
117
|
}
|
|
106
118
|
if (this.options.ratioed) {
|
|
107
|
-
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;
|
|
108
120
|
while (n >= 1) {
|
|
109
121
|
denominator = String.fromCharCode(0xe880 + (n % 10)) + denominator;
|
|
110
122
|
n = Math.floor(n / 10);
|
|
@@ -131,7 +143,7 @@ export class Tuplet extends Element {
|
|
|
131
143
|
return maxOffset;
|
|
132
144
|
}
|
|
133
145
|
getYPosition() {
|
|
134
|
-
var _a;
|
|
146
|
+
var _a, _b, _c;
|
|
135
147
|
const nestedTupletYOffset = this.getNestedTupletCount() * Tuplet.NESTING_OFFSET * -this.options.location;
|
|
136
148
|
const yOffset = (_a = this.options.yOffset) !== null && _a !== void 0 ? _a : 0;
|
|
137
149
|
const firstNote = this.notes[0];
|
|
@@ -143,7 +155,7 @@ export class Tuplet extends Element {
|
|
|
143
155
|
let modLines = 0;
|
|
144
156
|
const mc = note.getModifierContext();
|
|
145
157
|
if (mc) {
|
|
146
|
-
modLines =
|
|
158
|
+
modLines = mc.getUnmeasuredTextLines(true);
|
|
147
159
|
}
|
|
148
160
|
const modY = note.getYForTopText(modLines) - 2 * Tables.STAVE_LINE_DISTANCE;
|
|
149
161
|
if (note.hasStem() || note.isRest()) {
|
|
@@ -162,7 +174,7 @@ export class Tuplet extends Element {
|
|
|
162
174
|
this.notes.forEach((nn) => {
|
|
163
175
|
const mc = nn.getModifierContext();
|
|
164
176
|
if (mc) {
|
|
165
|
-
lineCheck = Math.max(lineCheck, mc.
|
|
177
|
+
lineCheck = Math.max(lineCheck, mc.getUnmeasuredTextLines(false) + 1);
|
|
166
178
|
}
|
|
167
179
|
});
|
|
168
180
|
yPosition = firstNote.checkStave().getYForLine(lineCheck) + 2 * Tables.STAVE_LINE_DISTANCE;
|
|
@@ -177,16 +189,44 @@ export class Tuplet extends Element {
|
|
|
177
189
|
}
|
|
178
190
|
}
|
|
179
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.getVerticalJustification() !== side ||
|
|
212
|
+
mark.checkAttachedNote().getStave() !== note.getStave())
|
|
213
|
+
continue;
|
|
214
|
+
const baseline = mark.computeY().y + mark.getYShift();
|
|
215
|
+
const ink = mark.getTextMetrics();
|
|
216
|
+
yPosition = above
|
|
217
|
+
? Math.min(yPosition, baseline - ink.actualBoundingBoxAscent - padding)
|
|
218
|
+
: Math.max(yPosition, baseline + ink.actualBoundingBoxDescent + padding);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
180
221
|
return yPosition + nestedTupletYOffset + yOffset;
|
|
181
222
|
}
|
|
182
|
-
|
|
223
|
+
positionElements() {
|
|
183
224
|
const { location, bracketed, textYOffset, suffix } = this.options;
|
|
184
225
|
const bracketPadding = Metrics.get('Tuplet.bracket.padding');
|
|
185
226
|
const bracketThickness = Metrics.get('Tuplet.bracket.lineWidth');
|
|
186
227
|
const bracketLegLength = Metrics.get('Tuplet.bracket.legLength');
|
|
187
228
|
const extraSpacing = Metrics.get('Tuplet.suffix.extraSpacing');
|
|
188
229
|
const suffixOffsetY = Metrics.get('Tuplet.suffix.suffixOffsetY');
|
|
189
|
-
const ctx = this.checkContext();
|
|
190
230
|
let xPos = 0;
|
|
191
231
|
let yPos = 0;
|
|
192
232
|
const firstNote = this.notes[0];
|
|
@@ -216,6 +256,15 @@ export class Tuplet extends Element {
|
|
|
216
256
|
const notationCenterX = xPos + bodyWidth / 2;
|
|
217
257
|
const notationStartX = notationCenterX - totalTextWidth / 2;
|
|
218
258
|
const commonTextY = yPos + this.textElement.getHeight() / 2 + (location === Tuplet.LOCATION_TOP ? -1 : 1) * textYOffset;
|
|
259
|
+
this.textElement.setX(notationStartX).setY(commonTextY);
|
|
260
|
+
if (suffix)
|
|
261
|
+
this.suffixElement.setX(notationStartX + ratioWidth + extraSpacing).setY(commonTextY + suffixOffsetY);
|
|
262
|
+
return { xPos, yPos, bodyWidth, totalTextWidth, bracketPadding, bracketThickness, bracketLegLength };
|
|
263
|
+
}
|
|
264
|
+
draw() {
|
|
265
|
+
const { location, bracketed, suffix } = this.options;
|
|
266
|
+
const { xPos, yPos, bodyWidth, totalTextWidth, bracketPadding, bracketThickness, bracketLegLength } = this.positionElements();
|
|
267
|
+
const ctx = this.checkContext();
|
|
219
268
|
const clsAttribute = this.getAttribute('class');
|
|
220
269
|
ctx.openGroup('tuplet' + (clsAttribute ? ' ' + clsAttribute : ''), this.getAttribute('id'));
|
|
221
270
|
if (bracketed) {
|
|
@@ -228,23 +277,15 @@ export class Tuplet extends Element {
|
|
|
228
277
|
ctx.fillRect(xPos + bodyWidth, yPos + (isTupletBottom ? 1 : 0), bracketThickness, location * bracketLegLength);
|
|
229
278
|
}
|
|
230
279
|
}
|
|
231
|
-
let currentX = notationStartX;
|
|
232
|
-
this.textElement.setX(currentX);
|
|
233
|
-
this.textElement.setY(commonTextY);
|
|
234
280
|
this.textElement.renderText(ctx, 0, 0);
|
|
235
|
-
|
|
236
|
-
if (suffix) {
|
|
237
|
-
const suffixY = commonTextY + suffixOffsetY;
|
|
238
|
-
this.suffixElement.setX(currentX);
|
|
239
|
-
this.suffixElement.setY(suffixY);
|
|
281
|
+
if (suffix)
|
|
240
282
|
this.suffixElement.renderText(ctx, 0, 0);
|
|
241
|
-
currentX += noteWidth;
|
|
242
|
-
}
|
|
243
283
|
this.drawPointerRect();
|
|
244
284
|
ctx.closeGroup();
|
|
245
285
|
this.setRendered();
|
|
246
286
|
}
|
|
247
287
|
getBoundingBox() {
|
|
288
|
+
this.positionElements();
|
|
248
289
|
const { bracketed, suffix } = this.options;
|
|
249
290
|
const ratioBounding = this.textElement.getBoundingBox();
|
|
250
291
|
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.3.0';
|
|
2
|
+
export const ID = '18f11424bdf291599683d063b18ded0dc840f0e0';
|
|
3
|
+
export const DATE = '2026-11-18T16:43:59.349Z';
|
package/build/esm/src/vexflow.js
CHANGED
|
@@ -21,8 +21,10 @@ import { ClefNote } from './clefnote.js';
|
|
|
21
21
|
import { Crescendo } from './crescendo.js';
|
|
22
22
|
import { Curve, CurvePosition } from './curve.js';
|
|
23
23
|
import { Dot } from './dot.js';
|
|
24
|
-
import { EasyScore } from './easyscore.js';
|
|
24
|
+
import { EasyScore, EasyScoreError } from './easyscore.js';
|
|
25
25
|
import { Element } from './element.js';
|
|
26
|
+
import { measureEngraving } from './engravinggeometry.js';
|
|
27
|
+
import { EngravingProfile } from './engravingprofile.js';
|
|
26
28
|
import { Factory } from './factory.js';
|
|
27
29
|
import { Font, FontStyle, FontWeight } from './font.js';
|
|
28
30
|
import { Formatter } from './formatter.js';
|
|
@@ -219,6 +221,8 @@ VexFlow.BUILD = {
|
|
|
219
221
|
DATE: DATE,
|
|
220
222
|
INFO: '',
|
|
221
223
|
};
|
|
224
|
+
VexFlow.measureEngraving = measureEngraving;
|
|
225
|
+
VexFlow.EngravingProfile = EngravingProfile;
|
|
222
226
|
VexFlow.Accidental = Accidental;
|
|
223
227
|
VexFlow.Annotation = Annotation;
|
|
224
228
|
VexFlow.Articulation = Articulation;
|
|
@@ -235,6 +239,7 @@ VexFlow.Crescendo = Crescendo;
|
|
|
235
239
|
VexFlow.Curve = Curve;
|
|
236
240
|
VexFlow.Dot = Dot;
|
|
237
241
|
VexFlow.EasyScore = EasyScore;
|
|
242
|
+
VexFlow.EasyScoreError = EasyScoreError;
|
|
238
243
|
VexFlow.Element = Element;
|
|
239
244
|
VexFlow.Factory = Factory;
|
|
240
245
|
VexFlow.Font = Font;
|
|
@@ -10,6 +10,7 @@ const BeamTests = {
|
|
|
10
10
|
run('Sixteenth Beam', sixteenth);
|
|
11
11
|
run('Slopey Beam', slopey);
|
|
12
12
|
run('Auto-stemmed Beam', autoStem);
|
|
13
|
+
run('Auto-stemmed tuplets across middle line', autoStemTuplets);
|
|
13
14
|
run('Mixed Beam 1', mixed);
|
|
14
15
|
run('Mixed Beam 2', mixed2);
|
|
15
16
|
run('Mixed Beam 3', mixed3);
|
|
@@ -667,3 +668,37 @@ function complexWithArticulation2(options) {
|
|
|
667
668
|
}
|
|
668
669
|
VexFlowTests.register(BeamTests);
|
|
669
670
|
export { BeamTests };
|
|
671
|
+
function autoStemTuplets(options) {
|
|
672
|
+
const f = VexFlowTests.makeFactory(options, 720, 650);
|
|
673
|
+
const score = f.EasyScore();
|
|
674
|
+
const groups = [];
|
|
675
|
+
const phrases = ['C4/8, D4, E4, F4, G4, A4, B4', 'A5/8, G5, F5, E5, D5, C5, A4'];
|
|
676
|
+
for (const proportional of [false, true]) {
|
|
677
|
+
for (const phrase of phrases) {
|
|
678
|
+
const notes = score.notes(phrase);
|
|
679
|
+
options.assert.equal(new Set(notes.map((note) => note.getStemDirection())).size, 2, 'Fixture crosses stem boundary');
|
|
680
|
+
score.tuplet(notes, { numNotes: 7, notesOccupied: 4, ratioed: true });
|
|
681
|
+
score.beam(notes);
|
|
682
|
+
const system = f.System({
|
|
683
|
+
x: 25,
|
|
684
|
+
y: 30 + groups.length * 155,
|
|
685
|
+
width: 660,
|
|
686
|
+
details: proportional ? { spacing: { mode: 'proportional', pixelsPerQuarter: 200 } } : {},
|
|
687
|
+
});
|
|
688
|
+
system.addStave({ voices: [score.voice(notes, { time: '2/4' })] }).addClef('treble');
|
|
689
|
+
groups.push(notes);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
f.draw({ retain: true });
|
|
693
|
+
const positions = groups.map((notes) => notes.map((note) => note.getAbsoluteX()));
|
|
694
|
+
f.draw({ retain: true });
|
|
695
|
+
groups.forEach((notes, row) => notes.forEach((note, index) => {
|
|
696
|
+
const direction = note.getBeam().getStemDirection();
|
|
697
|
+
options.assert.equal(note.getStemDirection(), direction, 'All stems agree with the beam');
|
|
698
|
+
const head = note.noteHeads[0];
|
|
699
|
+
options.assert.notOk(head.isDisplaced(), 'A single head has no chord displacement');
|
|
700
|
+
const attachment = direction === Stem.UP ? head.getAbsoluteX() + head.getWidth() : head.getAbsoluteX();
|
|
701
|
+
options.assert.ok(Math.abs(note.getStemX() - (attachment - (direction * Stem.WIDTH) / 2)) < 1e-7, 'Stem attaches to correct edge of head');
|
|
702
|
+
options.assert.equal(note.getAbsoluteX(), positions[row][index], 'Redraw preserves rhythmic anchor');
|
|
703
|
+
}));
|
|
704
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { VexFlowTests } from '../vexflow_test_helpers.js';
|
|
2
|
+
import { BarlineType, Bend, Stem } from '../../src/index.js';
|
|
3
|
+
export function electric(options) {
|
|
4
|
+
const f = VexFlowTests.makeFactory(options, 900, 380);
|
|
5
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
6
|
+
const makeNote = (duration, ...frets) => score.make.tabNote({ duration, stemDirection: Stem.DOWN, positions: frets.map(([str, fret]) => ({ str, fret })) }, true);
|
|
7
|
+
const bars = [
|
|
8
|
+
[
|
|
9
|
+
makeNote('q', [6, 5], [5, 7], [4, 7]),
|
|
10
|
+
makeNote('8', [3, 5]),
|
|
11
|
+
makeNote('8', [3, 7]),
|
|
12
|
+
makeNote('q', [2, 5]),
|
|
13
|
+
makeNote('q', [2, 8]),
|
|
14
|
+
],
|
|
15
|
+
[makeNote('h', [3, 7]), makeNote('8', [3, 5]), makeNote('8', [3, 7]), makeNote('q', [4, 7])],
|
|
16
|
+
[5, 8, 12, 8, 5, 8, 12, 8].map((fret) => makeNote('8', [1, fret])),
|
|
17
|
+
[makeNote('q', [1, 5]), makeNote('8', [2, 8]), makeNote('8', [2, 5]), makeNote('h', [4, 7], [3, 9], [2, 10])],
|
|
18
|
+
];
|
|
19
|
+
bars.forEach((notes, i) => {
|
|
20
|
+
const x = 16 + (i % 2) * 432;
|
|
21
|
+
const y = 35 + Math.floor(i / 2) * 176;
|
|
22
|
+
const stave = score.make.tabStave({ x, y, width: 432 });
|
|
23
|
+
if (i % 2 === 0)
|
|
24
|
+
stave.addClef('tab');
|
|
25
|
+
if (i === 0)
|
|
26
|
+
stave.addTimeSignature('4/4').setTempo({ duration: 'q', bpm: 96 }, -8);
|
|
27
|
+
if (i === 3)
|
|
28
|
+
stave.setEndBarType(BarlineType.END);
|
|
29
|
+
const legato = (start, label) => score.make
|
|
30
|
+
.tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label)
|
|
31
|
+
.setFont('Arial, Helvetica, sans-serif', 9, 'bold');
|
|
32
|
+
if (i === 0) {
|
|
33
|
+
score.beam(notes.slice(1, 3));
|
|
34
|
+
legato(1, 'H');
|
|
35
|
+
notes[4].addModifier(score.make.vibrato().setVibratoWidth(30));
|
|
36
|
+
}
|
|
37
|
+
else if (i === 1) {
|
|
38
|
+
notes[0].addModifier(score.make.bend([
|
|
39
|
+
{ type: Bend.UP, text: 'Full' },
|
|
40
|
+
{ type: Bend.DOWN, text: '' },
|
|
41
|
+
]));
|
|
42
|
+
score.beam(notes.slice(1, 3));
|
|
43
|
+
score.make.tabSlide({ firstNote: notes[1], lastNote: notes[2] });
|
|
44
|
+
}
|
|
45
|
+
else if (i === 2) {
|
|
46
|
+
score.beam(notes.slice(0, 4));
|
|
47
|
+
score.beam(notes.slice(4));
|
|
48
|
+
for (const start of [0, 4]) {
|
|
49
|
+
legato(start, 'H');
|
|
50
|
+
legato(start + 1, 'T');
|
|
51
|
+
legato(start + 2, 'P');
|
|
52
|
+
}
|
|
53
|
+
legato(3, 'P');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
score.beam(notes.slice(1, 3));
|
|
57
|
+
legato(1, 'P');
|
|
58
|
+
}
|
|
59
|
+
f.System({ x, y, width: 432 }).addStave({ stave, voices: [score.voice(notes)] });
|
|
60
|
+
});
|
|
61
|
+
f.draw();
|
|
62
|
+
options.assert.ok(true, 'Four bars of rhythmic tab with native guitar techniques');
|
|
63
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { VexFlowTests } from '../vexflow_test_helpers.js';
|
|
2
|
+
import { BarlineType, Stroke } from '../../src/index.js';
|
|
3
|
+
const positions = {
|
|
4
|
+
E3: [6, 0],
|
|
5
|
+
F3: [6, 1],
|
|
6
|
+
G3: [6, 3],
|
|
7
|
+
A3: [5, 0],
|
|
8
|
+
B3: [5, 2],
|
|
9
|
+
C4: [5, 3],
|
|
10
|
+
D4: [4, 0],
|
|
11
|
+
E4: [4, 2],
|
|
12
|
+
F4: [4, 3],
|
|
13
|
+
G4: [3, 0],
|
|
14
|
+
'G#4': [3, 1],
|
|
15
|
+
A4: [3, 2],
|
|
16
|
+
B4: [2, 0],
|
|
17
|
+
C5: [2, 1],
|
|
18
|
+
D5: [2, 3],
|
|
19
|
+
E5: [1, 0],
|
|
20
|
+
F5: [1, 1],
|
|
21
|
+
};
|
|
22
|
+
export function greensleeves(options) {
|
|
23
|
+
const f = VexFlowTests.makeFactory(options, 900, 486);
|
|
24
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
25
|
+
const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
|
|
26
|
+
const bars = [
|
|
27
|
+
['', 'A4/q'],
|
|
28
|
+
['Am', 'A3+E4+A4+C5/h D5/q'],
|
|
29
|
+
['C', 'C4+G4+C5+E5/q. F5/8 E5/q'],
|
|
30
|
+
['G', 'G3+D4+G4+D5/h B4/q'],
|
|
31
|
+
['Em', 'E3+B3+G4/q. A4/8 B4/q'],
|
|
32
|
+
['Am', 'A3+E4+A4+C5/h A4/q'],
|
|
33
|
+
['Dm/F', 'F3+D4+A4/q. G#4/8 A4/q'],
|
|
34
|
+
['E', 'E3+E4+B4/h G#4/q'],
|
|
35
|
+
['E5', 'E3+B3+E4/h'],
|
|
36
|
+
];
|
|
37
|
+
bars.forEach(([chordName, bar], i) => {
|
|
38
|
+
const row = i >= 5 ? 1 : 0;
|
|
39
|
+
const width = row ? 218 : i === 0 ? 112 : 190;
|
|
40
|
+
const x = row ? 12 + (i - 5) * width : i === 0 ? 12 : 124 + (i - 1) * width;
|
|
41
|
+
const y = 28 + row * 230;
|
|
42
|
+
const events = bar.split(' ').map((token) => {
|
|
43
|
+
const [chord, duration] = token.split('/');
|
|
44
|
+
return { pitches: chord.split('+'), duration };
|
|
45
|
+
});
|
|
46
|
+
const music = events.map(({ pitches, duration }) => {
|
|
47
|
+
const chord = pitches.length === 1 ? pitches[0] : `(${pitches.join(' ')})`;
|
|
48
|
+
return `${chord}/${duration}`;
|
|
49
|
+
});
|
|
50
|
+
const notes = score.notes(music.join(', '));
|
|
51
|
+
if (chordName)
|
|
52
|
+
notes[0].addModifier(score.make.chordSymbol(chordFont).addText(chordName));
|
|
53
|
+
const tab = events.map(({ pitches, duration }) => score.make.tabNote({
|
|
54
|
+
positions: pitches.map((pitch) => {
|
|
55
|
+
const [str, fret] = positions[pitch];
|
|
56
|
+
return { str, fret };
|
|
57
|
+
}),
|
|
58
|
+
duration: duration.replace('.', ''),
|
|
59
|
+
dots: duration.includes('.') ? 1 : 0,
|
|
60
|
+
}));
|
|
61
|
+
if (i === 1 || i === 5) {
|
|
62
|
+
notes[0].addModifier(score.make.fingering({ number: '1', position: 'left' }), 3);
|
|
63
|
+
notes[0].addModifier(score.make.fingering({ number: '2', position: 'left' }), 1);
|
|
64
|
+
}
|
|
65
|
+
if (i === 2 || i === 8)
|
|
66
|
+
notes[0].addModifier(score.make.stroke(Stroke.Type.ARPEGGIO_DIRECTIONLESS));
|
|
67
|
+
if (i === 2 || i === 6)
|
|
68
|
+
score.make.curve({ from: notes[1], to: notes[2] });
|
|
69
|
+
const time = i === 0 ? '1/4' : i === bars.length - 1 ? '2/4' : '3/4';
|
|
70
|
+
const system = f.System({ x, y, width, spaceBetweenStaves: 8 });
|
|
71
|
+
const stave = system.addStave({ voices: [score.voice(notes, { time })], options: { topTextPosition: 3.5 } });
|
|
72
|
+
const tablature = system.addStave({
|
|
73
|
+
stave: score.make.tabStave({ x, y, width }),
|
|
74
|
+
voices: [score.voice(tab, { time })],
|
|
75
|
+
});
|
|
76
|
+
if (i === 0 || i === 5) {
|
|
77
|
+
stave.addClef('treble', 'default', '8vb');
|
|
78
|
+
if (i === 0)
|
|
79
|
+
stave.addTimeSignature('3/4');
|
|
80
|
+
tablature.addClef('tab');
|
|
81
|
+
system.addConnector('bracket');
|
|
82
|
+
}
|
|
83
|
+
if (i === bars.length - 1) {
|
|
84
|
+
stave.setEndBarType(BarlineType.END);
|
|
85
|
+
tablature.setEndBarType(BarlineType.END);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
f.draw();
|
|
89
|
+
options.assert.ok(true, 'Chord melody and tab share the same rhythmic grid');
|
|
90
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { VexFlowTests } from '../vexflow_test_helpers.js';
|
|
2
|
+
import { BarlineType, StaveHairpin } from '../../src/index.js';
|
|
3
|
+
export function joy(options) {
|
|
4
|
+
const f = VexFlowTests.makeFactory(options, 900, 435);
|
|
5
|
+
const score = f.EasyScore({ throwOnError: true });
|
|
6
|
+
score.set({ clef: 'bass', time: '4/4' });
|
|
7
|
+
const duet = [
|
|
8
|
+
['F3/q, F3, G3, A3', 'D3/h, A2'],
|
|
9
|
+
['A3/q, G3, F3, E3', 'F2/h, A2'],
|
|
10
|
+
['D3/q, D3, E3, F3', 'B2/h, G2'],
|
|
11
|
+
['F3/q., E3/8, E3/h', 'A2/w'],
|
|
12
|
+
['F3/q, F3, G3, A3', 'D3/h, A2'],
|
|
13
|
+
['A3/q, G3, F3, E3', 'F2/h, A2'],
|
|
14
|
+
['D3/q, D3, E3, F3', 'G2/h, A2'],
|
|
15
|
+
['E3/q., D3/8, D3/h', 'A2/h, D2'],
|
|
16
|
+
];
|
|
17
|
+
duet.forEach(([tune, bass], i) => {
|
|
18
|
+
const notes = score.notes(tune);
|
|
19
|
+
const system = f.System({
|
|
20
|
+
x: 24 + (i % 4) * 213,
|
|
21
|
+
y: 10 + Math.floor(i / 4) * 210,
|
|
22
|
+
width: 213,
|
|
23
|
+
spaceBetweenStaves: 10,
|
|
24
|
+
});
|
|
25
|
+
const voices = [score.voice(notes)];
|
|
26
|
+
if (i % 2 === 0) {
|
|
27
|
+
const dynamic = ['p', 'mf', 'mp', 'f'][i / 2];
|
|
28
|
+
voices.push(score.voice([score.make.textDynamics({ text: dynamic, duration: 'w', line: 10 })]));
|
|
29
|
+
}
|
|
30
|
+
const first = system.addStave({ voices });
|
|
31
|
+
const second = system.addStave({ voices: [score.voice(score.notes(bass))] });
|
|
32
|
+
if (i % 4 === 0) {
|
|
33
|
+
first.addClef('bass').addKeySignature('D');
|
|
34
|
+
second.addClef('bass').addKeySignature('D');
|
|
35
|
+
if (i === 0) {
|
|
36
|
+
first.addTimeSignature('4/4');
|
|
37
|
+
second.addTimeSignature('4/4');
|
|
38
|
+
}
|
|
39
|
+
system.addConnector('bracket');
|
|
40
|
+
}
|
|
41
|
+
if (i === 1 || i === 5) {
|
|
42
|
+
score.make.hairpin({
|
|
43
|
+
from: notes[0],
|
|
44
|
+
to: notes[3],
|
|
45
|
+
type: StaveHairpin.type.CRESC,
|
|
46
|
+
options: { height: 8, yShift: -21 },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (i === 0 || i === 4)
|
|
50
|
+
notes[0].addModifier(score.make.articulation({ type: 'tenuto', position: 'above' }));
|
|
51
|
+
if (i === 3 || i === 7)
|
|
52
|
+
score.make.curve({ from: notes[0], to: notes[1] });
|
|
53
|
+
if (i === 7) {
|
|
54
|
+
first.setEndBarType(BarlineType.END);
|
|
55
|
+
second.setEndBarType(BarlineType.END);
|
|
56
|
+
}
|
|
57
|
+
system.addConnector('singleRight');
|
|
58
|
+
});
|
|
59
|
+
f.draw();
|
|
60
|
+
options.assert.ok(true, 'Two cello parts aligned through the cadence');
|
|
61
|
+
}
|