vexflow-native 1.7.0 → 1.9.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 +33 -348
- package/lib/module/base/FontManager.js +0 -0
- package/lib/module/base/FontManager.js.map +1 -1
- package/lib/module/base/VexflowRecordingContext.js +2 -0
- package/lib/module/base/VexflowRecordingContext.js.map +1 -1
- package/lib/module/base/index.js +1 -0
- package/lib/module/base/index.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +24 -7
- package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js +11 -3
- package/lib/module/musicxml/MusicXmlParser/MusicXmlDirections.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/Spanners.js +21 -5
- package/lib/module/musicxml/MusicXmlParser/Spanners.js.map +1 -1
- package/lib/module/musicxml/MusicXmlParser/mappers.js +1 -1
- package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -1
- package/lib/module/percussion/index.js +8 -0
- package/lib/module/percussion/index.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +4 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/fixedNoteSpacing.js +56 -0
- package/lib/module/renderer/fixedNoteSpacing.js.map +1 -0
- package/lib/module/renderer/index.js +1 -0
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/module/renderer/itemLayout.js +108 -0
- package/lib/module/renderer/itemLayout.js.map +1 -0
- package/lib/module/renderer/measure.js +31 -102
- package/lib/module/renderer/measure.js.map +1 -1
- package/lib/module/renderer/measureBounds.js +73 -0
- package/lib/module/renderer/measureBounds.js.map +1 -0
- package/lib/module/renderer/measureModifiers.js +99 -0
- package/lib/module/renderer/measureModifiers.js.map +1 -0
- package/lib/module/renderer/noteModifiers.js +212 -0
- package/lib/module/renderer/noteModifiers.js.map +1 -0
- package/lib/module/renderer/render.js +34 -115
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/scale.js +16 -2
- package/lib/module/renderer/scale.js.map +1 -1
- package/lib/module/renderer/scoreParsing.js +37 -188
- package/lib/module/renderer/scoreParsing.js.map +1 -1
- package/lib/module/renderer/stave.js +37 -0
- package/lib/module/renderer/stave.js.map +1 -0
- package/lib/module/renderer/useScoreRecording.js +10 -3
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/module/renderer/vfKeys.js +72 -0
- package/lib/module/renderer/vfKeys.js.map +1 -0
- package/lib/module/state/index.js +1 -0
- package/lib/module/state/index.js.map +1 -1
- package/lib/typescript/src/base/FontManager.d.ts +7 -0
- package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
- package/lib/typescript/src/base/VexflowRecordingContext.d.ts +1 -0
- package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
- package/lib/typescript/src/base/index.d.ts +1 -0
- package/lib/typescript/src/base/index.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +4 -2
- package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts +6 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/MusicXmlDirections.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts +6 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/Spanners.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -1
- package/lib/typescript/src/musicxml/index.d.ts +1 -0
- package/lib/typescript/src/musicxml/index.d.ts.map +1 -1
- package/lib/typescript/src/percussion/index.d.ts +4 -0
- package/lib/typescript/src/percussion/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
- package/lib/typescript/src/renderer/fixedNoteSpacing.d.ts +17 -0
- package/lib/typescript/src/renderer/fixedNoteSpacing.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +2 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/itemLayout.d.ts +23 -0
- package/lib/typescript/src/renderer/itemLayout.d.ts.map +1 -0
- package/lib/typescript/src/renderer/layout.d.ts +1 -1
- package/lib/typescript/src/renderer/layout.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measure.d.ts +3 -6
- package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measureBounds.d.ts +13 -0
- package/lib/typescript/src/renderer/measureBounds.d.ts.map +1 -0
- package/lib/typescript/src/renderer/measureModifiers.d.ts +20 -0
- package/lib/typescript/src/renderer/measureModifiers.d.ts.map +1 -0
- package/lib/typescript/src/renderer/noteModifiers.d.ts +29 -0
- package/lib/typescript/src/renderer/noteModifiers.d.ts.map +1 -0
- package/lib/typescript/src/renderer/render.d.ts +2 -27
- package/lib/typescript/src/renderer/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scale.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scoreParsing.d.ts +14 -40
- package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -1
- package/lib/typescript/src/renderer/stave.d.ts +11 -0
- package/lib/typescript/src/renderer/stave.d.ts.map +1 -0
- package/lib/typescript/src/renderer/types.d.ts +53 -4
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +2 -2
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
- package/lib/typescript/src/renderer/vfKeys.d.ts +17 -0
- package/lib/typescript/src/renderer/vfKeys.d.ts.map +1 -0
- package/lib/typescript/src/state/index.d.ts +1 -0
- package/lib/typescript/src/state/index.d.ts.map +1 -1
- package/lib/typescript/src/state/types.d.ts +39 -6
- package/lib/typescript/src/state/types.d.ts.map +1 -1
- package/package.json +15 -5
- package/src/base/FontManager.ts +0 -0
- package/src/base/VexflowRecordingContext.ts +1 -0
- package/src/base/index.ts +1 -0
- package/src/musicxml/MusicXmlParser/InternalTypes.ts +5 -2
- package/src/musicxml/MusicXmlParser/MeasureParser.ts +36 -7
- package/src/musicxml/MusicXmlParser/MusicXmlDirections.ts +25 -8
- package/src/musicxml/MusicXmlParser/Spanners.ts +27 -4
- package/src/musicxml/MusicXmlParser/mappers.ts +7 -0
- package/src/musicxml/index.ts +1 -0
- package/src/percussion/index.ts +7 -0
- package/src/renderer/Layout/VerticalSpacing.ts +1 -1
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +4 -0
- package/src/renderer/fixedNoteSpacing.ts +78 -0
- package/src/renderer/index.ts +8 -0
- package/src/renderer/itemLayout.ts +137 -0
- package/src/renderer/layout.ts +1 -1
- package/src/renderer/measure.tsx +85 -182
- package/src/renderer/measureBounds.ts +109 -0
- package/src/renderer/measureModifiers.ts +133 -0
- package/src/renderer/noteModifiers.ts +298 -0
- package/src/renderer/render.tsx +66 -171
- package/src/renderer/scale.ts +21 -1
- package/src/renderer/scoreParsing.tsx +78 -262
- package/src/renderer/stave.ts +44 -0
- package/src/renderer/types.ts +67 -4
- package/src/renderer/useScoreRecording.ts +11 -3
- package/src/renderer/vfKeys.ts +88 -0
- package/src/state/index.ts +1 -0
- package/src/state/types.ts +48 -5
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Formatter, Stave, StaveConnector } from 'vexflow';
|
|
4
|
-
import {
|
|
4
|
+
import { applyMeasureModifiers, resolveMeasureModifiers } from "./measureModifiers.js";
|
|
5
|
+
import { indexAttachmentsByOwner, makeVFVoice } from "./scoreParsing.js";
|
|
6
|
+
import { applyFixedNoteSpacing } from "./fixedNoteSpacing.js";
|
|
7
|
+
import { itemLayoutOf } from "./itemLayout.js";
|
|
8
|
+
import { hasNoteHeads } from "./noteModifiers.js";
|
|
9
|
+
import { applyStaffLines, visibleLineYs } from "./stave.js";
|
|
5
10
|
/**
|
|
6
11
|
* Renders the score from a precomputed layout plan and returns the formatted
|
|
7
12
|
* geometry of every rendered item and measure.
|
|
8
13
|
*/
|
|
9
|
-
export function renderScore(ctx, score, layoutPlan, options) {
|
|
14
|
+
export function renderScore(ctx, score, layoutPlan, options, hooks = {}) {
|
|
10
15
|
const groupsById = new Map(layoutPlan.groups.map(group => [group.groupId, group]));
|
|
11
16
|
const measuresByGroup = groupMeasuresByIndex(layoutPlan.measures);
|
|
12
17
|
const attachmentsByOwner = indexAttachmentsByOwner(score);
|
|
@@ -25,64 +30,13 @@ export function renderScore(ctx, score, layoutPlan, options) {
|
|
|
25
30
|
renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, {
|
|
26
31
|
isFirstMeasureInSystem: measureIndex === 0,
|
|
27
32
|
isLastMeasureInSystem: measureIndex === measurePlans.length - 1,
|
|
28
|
-
fixedNoteSpacing: options.render.fixedNoteSpacing
|
|
33
|
+
fixedNoteSpacing: options.render.fixedNoteSpacing,
|
|
34
|
+
...hooks
|
|
29
35
|
}, itemsLayout);
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
return itemsLayout;
|
|
33
39
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Re-positions every tick context at its time-proportional x inside the note
|
|
36
|
-
* area, overriding the formatter's duration-weighted spacing. Runs after
|
|
37
|
-
* `formatToStave` (the same post-format `setX` mechanism the formatter's own
|
|
38
|
-
* tuning uses), so beams, tuplets and modifiers pick the final positions up
|
|
39
|
-
* at draw time. The lattice follows VexFlow's own convention for its first
|
|
40
|
-
* tick: it starts at that context's left-modifier width (`totalLeftPx`), so a
|
|
41
|
-
* grace group or accidental on beat 1 hangs inside the note area instead of
|
|
42
|
-
* over the clef. The proportional span is clamped only by that inset and the
|
|
43
|
-
* LAST context's width — with a spacer voice on the lattice the latter is
|
|
44
|
-
* constant, so the mapping stays a pure function of time and of what hangs
|
|
45
|
-
* left of beat 1.
|
|
46
|
-
*/
|
|
47
|
-
export function applyFixedNoteSpacing(formatter, voices, stave) {
|
|
48
|
-
const contexts = formatter.getTickContexts();
|
|
49
|
-
const lastTickKey = contexts?.list[contexts.list.length - 1];
|
|
50
|
-
if (!contexts || voices.length === 0 || lastTickKey === undefined || lastTickKey <= 0) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const totalTicks = voices[0]?.getTotalTicks().value() ?? 0;
|
|
54
|
-
if (!(totalTicks > 0)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Tick context keys are ticks × the formatter's resolution multiplier (the
|
|
59
|
-
// lcm that keeps tuplet ticks integral: 3 with triplets, 5 with
|
|
60
|
-
// quintuplets…), while getTotalTicks() is in plain ticks. Compare in plain
|
|
61
|
-
// ticks, or every position scales by the multiplier and the overflow
|
|
62
|
-
// correction below crushes the last tick flush against the note end.
|
|
63
|
-
const multiplier = contexts.resolutionMultiplier || 1;
|
|
64
|
-
const lastTick = lastTickKey / multiplier;
|
|
65
|
-
|
|
66
|
-
// Tick context x is relative to noteStartX + the stave's left note padding
|
|
67
|
-
// (see Tickable.getAbsoluteX), so the usable span ends at noteEndX. The
|
|
68
|
-
// padding is derived from Stave statics because the `Metrics` module is not
|
|
69
|
-
// re-exported by every vexflow build.
|
|
70
|
-
const stavePadding = Stave.defaultPadding - Stave.rightPadding;
|
|
71
|
-
const noteAreaWidth = stave.getNoteEndX() - stave.getNoteStartX() - stavePadding;
|
|
72
|
-
const firstLeft = contexts.map[contexts.list[0]].getMetrics().totalLeftPx;
|
|
73
|
-
let span = noteAreaWidth - firstLeft;
|
|
74
|
-
const lastContext = contexts.map[lastTickKey];
|
|
75
|
-
const lastOverflow = firstLeft + lastTick / totalTicks * span + lastContext.getWidth() - noteAreaWidth;
|
|
76
|
-
if (lastOverflow > 0) {
|
|
77
|
-
span -= lastOverflow * totalTicks / lastTick;
|
|
78
|
-
}
|
|
79
|
-
if (!(span > 0)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
for (const tickKey of contexts.list) {
|
|
83
|
-
contexts.map[tickKey].setX(firstLeft + tickKey / multiplier / totalTicks * span);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
40
|
function renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, options, itemsLayout) {
|
|
87
41
|
const formatter = new Formatter();
|
|
88
42
|
const resolvedStateByStaffId = new Map(group.staves.map((staff, staffIndex) => [staff.id, group.resolvedStatesByStaff[staffIndex]?.[measurePlan.measureIndex]]));
|
|
@@ -97,9 +51,16 @@ function renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, optio
|
|
|
97
51
|
tuplets: []
|
|
98
52
|
};
|
|
99
53
|
}
|
|
100
|
-
const voiceArtifacts = measure.voices.map(voice => ({
|
|
54
|
+
const voiceArtifacts = measure.voices.map((voice, voiceIndex) => ({
|
|
101
55
|
...makeVFVoice(score, resolvedState.meter, resolvedState.clef, voice, {
|
|
102
56
|
attachmentsByOwner,
|
|
57
|
+
staff,
|
|
58
|
+
directions: voiceIndex === 0 ? measure.directions : undefined,
|
|
59
|
+
itemContext: options.decorateItem ? {
|
|
60
|
+
decorateItem: options.decorateItem,
|
|
61
|
+
staff,
|
|
62
|
+
measureIndex: measurePlan.measureIndex
|
|
63
|
+
} : undefined,
|
|
103
64
|
resolveClef: item => item.targetStaffId ? resolvedStateByStaffId.get(item.targetStaffId)?.clef ?? resolvedState.clef : resolvedState.clef
|
|
104
65
|
}),
|
|
105
66
|
items: voice.items,
|
|
@@ -134,13 +95,8 @@ function renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, optio
|
|
|
134
95
|
const renderedStaves = group.staves.map((staff, staffIndex) => {
|
|
135
96
|
const measure = staff.measures[measurePlan.measureIndex];
|
|
136
97
|
const resolvedState = group.resolvedStatesByStaff[staffIndex][measurePlan.measureIndex];
|
|
137
|
-
const stave = new Stave(measurePlan.x, measurePlan.y + (measurePlan.staffYOffsets[staffIndex] ?? 0), measurePlan.width);
|
|
138
|
-
|
|
139
|
-
stave.addClef(resolvedState.clef);
|
|
140
|
-
}
|
|
141
|
-
if (measure.leftModifiers?.showMeter === true) {
|
|
142
|
-
stave.addTimeSignature(`${resolvedState.meter.beats}/${resolvedState.meter.beatUnit}`);
|
|
143
|
-
}
|
|
98
|
+
const stave = applyStaffLines(new Stave(measurePlan.x, measurePlan.y + (measurePlan.staffYOffsets[staffIndex] ?? 0), measurePlan.width), staff.lines);
|
|
99
|
+
applyMeasureModifiers(stave, resolveMeasureModifiers(measure, measurePlan.measureIndex), resolvedState);
|
|
144
100
|
stave.setContext(ctx).draw();
|
|
145
101
|
return stave;
|
|
146
102
|
});
|
|
@@ -172,7 +128,6 @@ function renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, optio
|
|
|
172
128
|
applyFixedNoteSpacing(formatter, allVoices, referenceStave);
|
|
173
129
|
}
|
|
174
130
|
}
|
|
175
|
-
collectMeasureItemsLayout(itemsLayout, measurePlan, group.staves, renderedStaves, staffRenderArtifacts);
|
|
176
131
|
staffRenderArtifacts.forEach(({
|
|
177
132
|
vfVoices,
|
|
178
133
|
voiceArtifacts,
|
|
@@ -184,11 +139,12 @@ function renderMeasure(ctx, score, group, measurePlan, attachmentsByOwner, optio
|
|
|
184
139
|
items,
|
|
185
140
|
notes
|
|
186
141
|
}) => {
|
|
187
|
-
drawVoiceItems(ctx, items, notes);
|
|
142
|
+
drawVoiceItems(ctx, items, notes, measurePlan.measureIndex, itemsLayout, options.onDrawItem);
|
|
188
143
|
});
|
|
189
144
|
beams.forEach(beam => beam.setContext(ctx).draw());
|
|
190
145
|
tuplets.forEach(tuplet => tuplet.setContext(ctx).draw());
|
|
191
146
|
});
|
|
147
|
+
collectMeasureLayout(itemsLayout, measurePlan, group.staves, renderedStaves);
|
|
192
148
|
}
|
|
193
149
|
|
|
194
150
|
/**
|
|
@@ -200,34 +156,10 @@ function getFormatReferenceStave(renderedStaves) {
|
|
|
200
156
|
}
|
|
201
157
|
|
|
202
158
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* measure entry per rendered stave, since note bounds differ per stave.
|
|
159
|
+
* Emits one measure entry per rendered stave, since note bounds differ per
|
|
160
|
+
* stave.
|
|
206
161
|
*/
|
|
207
|
-
function
|
|
208
|
-
staffRenderArtifacts.forEach(({
|
|
209
|
-
voiceArtifacts
|
|
210
|
-
}) => {
|
|
211
|
-
voiceArtifacts.forEach(({
|
|
212
|
-
items,
|
|
213
|
-
notes
|
|
214
|
-
}) => {
|
|
215
|
-
items.forEach((item, index) => {
|
|
216
|
-
const note = notes[index];
|
|
217
|
-
if (!note) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const x = note.getAbsoluteX();
|
|
221
|
-
const width = note.getWidth();
|
|
222
|
-
itemsLayout.items[item.id] = {
|
|
223
|
-
x,
|
|
224
|
-
width,
|
|
225
|
-
headCenterX: resolveItemHeadCenterX(note, x, width),
|
|
226
|
-
measureIndex: measurePlan.measureIndex
|
|
227
|
-
};
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
162
|
+
function collectMeasureLayout(itemsLayout, measurePlan, staves, renderedStaves) {
|
|
231
163
|
staves.forEach((staff, staffIndex) => {
|
|
232
164
|
const stave = renderedStaves[staffIndex];
|
|
233
165
|
if (!stave) {
|
|
@@ -245,35 +177,17 @@ function collectMeasureItemsLayout(itemsLayout, measurePlan, staves, renderedSta
|
|
|
245
177
|
y: measurePlan.y,
|
|
246
178
|
height: measurePlan.height,
|
|
247
179
|
staveLineTopY: stave.getTopLineTopY(),
|
|
248
|
-
staveLineBottomY: stave.getBottomLineBottomY()
|
|
180
|
+
staveLineBottomY: stave.getBottomLineBottomY(),
|
|
181
|
+
visibleLineYs: visibleLineYs(stave, staff.lines)
|
|
249
182
|
});
|
|
250
183
|
});
|
|
251
184
|
}
|
|
252
185
|
|
|
253
|
-
/** Detected structurally because `GhostNote`s lack these getters. */
|
|
254
|
-
|
|
255
186
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* the block's left edge, capped by the block width — so a `spacer` rest
|
|
259
|
-
* anchors where a real note's head would sit on the same tick, and external
|
|
260
|
-
* UI aligned to it does not hop when the note appears. Zero-width `hidden`
|
|
261
|
-
* rests keep anchoring at their tick x.
|
|
187
|
+
* Draws each item and records its formatted geometry; the layout entry is
|
|
188
|
+
* taken after `draw()` because modifiers only take their position there.
|
|
262
189
|
*/
|
|
263
|
-
|
|
264
|
-
const {
|
|
265
|
-
getNoteHeadBeginX,
|
|
266
|
-
getNoteHeadEndX
|
|
267
|
-
} = note;
|
|
268
|
-
if (typeof getNoteHeadBeginX === 'function' && typeof getNoteHeadEndX === 'function') {
|
|
269
|
-
const center = (getNoteHeadBeginX.call(note) + getNoteHeadEndX.call(note)) / 2;
|
|
270
|
-
if (Number.isFinite(center) && center > x && center <= x + width) {
|
|
271
|
-
return center;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return x + Math.min(width, noteheadWidth()) / 2;
|
|
275
|
-
}
|
|
276
|
-
function drawVoiceItems(ctx, items, notes) {
|
|
190
|
+
function drawVoiceItems(ctx, items, notes, measureIndex, itemsLayout, onDrawItem) {
|
|
277
191
|
items.forEach((item, index) => {
|
|
278
192
|
const note = notes[index];
|
|
279
193
|
if (!note) {
|
|
@@ -282,6 +196,11 @@ function drawVoiceItems(ctx, items, notes) {
|
|
|
282
196
|
ctx.beginColorGroup(item.id);
|
|
283
197
|
try {
|
|
284
198
|
note.setContext(ctx).drawWithStyle();
|
|
199
|
+
const layout = itemLayoutOf(note, measureIndex);
|
|
200
|
+
itemsLayout.items[item.id] = layout;
|
|
201
|
+
if (onDrawItem && hasNoteHeads(note)) {
|
|
202
|
+
onDrawItem(ctx, item, note, layout);
|
|
203
|
+
}
|
|
285
204
|
} finally {
|
|
286
205
|
ctx.endColorGroup();
|
|
287
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Formatter","Stave","StaveConnector","indexAttachmentsByOwner","makeVFVoice","noteheadWidth","renderScore","ctx","score","layoutPlan","options","groupsById","Map","groups","map","group","groupId","measuresByGroup","groupMeasuresByIndex","measures","attachmentsByOwner","itemsLayout","items","contentSize","system","systems","get","staves","length","measurePlans","measureIndices","measureIndex","filter","measure","Boolean","measurePlan","entries","renderMeasure","isFirstMeasureInSystem","isLastMeasureInSystem","fixedNoteSpacing","render","applyFixedNoteSpacing","formatter","voices","stave","contexts","getTickContexts","lastTickKey","list","undefined","totalTicks","getTotalTicks","value","multiplier","resolutionMultiplier","lastTick","stavePadding","defaultPadding","rightPadding","noteAreaWidth","getNoteEndX","getNoteStartX","firstLeft","getMetrics","totalLeftPx","span","lastContext","lastOverflow","getWidth","tickKey","setX","resolvedStateByStaffId","staff","staffIndex","id","resolvedStatesByStaff","staffRenderArtifacts","resolvedState","vfVoices","voiceArtifacts","beams","tuplets","voice","meter","clef","resolveClef","item","targetStaffId","ownerStaffId","vfVoice","joinVoices","notes","flatMap","allVoices","renderedStaves","x","y","staffYOffsets","width","leftModifiers","showClef","addClef","showMeter","addTimeSignature","beats","beatUnit","setContext","draw","renderedStaveByStaffId","renderStaffConnectors","forEach","index","targetStave","setStave","referenceStave","getFormatReferenceStave","formatToStave","collectMeasureItemsLayout","setRendered","drawVoiceItems","beam","tuplet","reduce","reference","note","getAbsoluteX","headCenterX","resolveItemHeadCenterX","push","staffId","systemIndex","staveNoteStartX","staveNoteEndX","height","staveLineTopY","getTopLineTopY","staveLineBottomY","getBottomLineBottomY","getNoteHeadBeginX","getNoteHeadEndX","center","call","Number","isFinite","Math","min","beginColorGroup","drawWithStyle","endColorGroup","staffGroup","topStave","bottomStave","connectorSymbol","resolveStaffGroupConnectorSymbol","drawStaveConnector","connectorSymbolToVFType","requireStaveConnectorType","type","SINGLE_LEFT","SINGLE_RIGHT","symbol","role","BRACE","BRACKET","setType","Error","groupMeasures","set"],"sourceRoot":"../../../src","sources":["renderer/render.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,KAAK,EAAEC,cAAc,QAA0B,SAAS;AAe5E,SACEC,uBAAuB,EACvBC,WAAW,EACXC,aAAa,QACR,mBAAgB;AAIvB;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,GAA4B,EAC5BC,KAAY,EACZC,UAA2B,EAC3BC,OAAqB,EACH;EAClB,MAAMC,UAAU,GAAG,IAAIC,GAAG,CACxBH,UAAU,CAACI,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAK,CAACA,KAAK,CAACC,OAAO,EAAED,KAAK,CAAC,CACzD,CAAC;EACD,MAAME,eAAe,GAAGC,oBAAoB,CAACT,UAAU,CAACU,QAAQ,CAAC;EACjE,MAAMC,kBAAkB,GAAGjB,uBAAuB,CAACK,KAAK,CAAC;EACzD,MAAMa,WAA6B,GAAG;IACpCC,KAAK,EAAE,CAAC,CAAC;IACTH,QAAQ,EAAE,EAAE;IACZI,WAAW,EAAEd,UAAU,CAACc;EAC1B,CAAC;EAED,KAAK,MAAMC,MAAM,IAAIf,UAAU,CAACgB,OAAO,EAAE;IACvC,MAAMV,KAAK,GAAGJ,UAAU,CAACe,GAAG,CAACF,MAAM,CAACR,OAAO,CAAC;IAE5C,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACY,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC;IACF;IAEA,MAAMC,YAAY,GAAGL,MAAM,CAACM,cAAc,CACvChB,GAAG,CAAEiB,YAAY,IAChBd,eAAe,CAACS,GAAG,CAACF,MAAM,CAACR,OAAO,CAAC,EAAEU,GAAG,CAACK,YAAY,CACvD,CAAC,CACAC,MAAM,CAAEC,OAAO,IAAmCC,OAAO,CAACD,OAAO,CAAC,CAAC;IAEtE,KAAK,MAAM,CAACF,YAAY,EAAEI,WAAW,CAAC,IAAIN,YAAY,CAACO,OAAO,CAAC,CAAC,EAAE;MAChEC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CAACK,MAAyC,EAAE;EAC1E,OAAOA,MAAM,KAAK,OAAO,GACrBJ,yBAAyB,CAAC3J,cAAc,CAAC4J,IAAI,CAACK,KAAK,CAAC,GACpDN,yBAAyB,CAAC3J,cAAc,CAAC4J,IAAI,CAACM,OAAO,CAAC;AAC5D;AAEA,SAAST,kBAAkBA,CACzBpJ,GAA4B,EAC5BgJ,QAAe,EACfC,WAAkB,EAClBM,IAAwB,EACxB;EACA,IAAI5J,cAAc,CAACqJ,QAAQ,EAAEC,WAAW,CAAC,CACtCa,OAAO,CAACP,IAAI,CAAC,CACbnD,UAAU,CAACpG,GAAG,CAAC,CACfqG,IAAI,CAAC,CAAC;AACX;AAEA,SAASiD,yBAAyBA,CAChCC,IAAqD,EACjC;EACpB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,MAAM,IAAIQ,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEA,OAAOR,IAAI;AACb;AAEA,SAAS5I,oBAAoBA,CAACC,QAA6B,EAAE;EAC3D,MAAMF,eAAe,GAAG,IAAIL,GAAG,CAAyC,CAAC;EAEzE,KAAK,MAAMqB,OAAO,IAAId,QAAQ,EAAE;IAC9B,MAAMoJ,aAAa,GACjBtJ,eAAe,CAACS,GAAG,CAACO,OAAO,CAACjB,OAAO,CAAC,IACpC,IAAIJ,GAAG,CAA4B,CAAC;IAEtC2J,aAAa,CAACC,GAAG,CAACvI,OAAO,CAACF,YAAY,EAAEE,OAAO,CAAC;IAChDhB,eAAe,CAACuJ,GAAG,CAACvI,OAAO,CAACjB,OAAO,EAAEuJ,aAAa,CAAC;EACrD;EAEA,OAAOtJ,eAAe;AACxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Formatter","Stave","StaveConnector","applyMeasureModifiers","resolveMeasureModifiers","indexAttachmentsByOwner","makeVFVoice","applyFixedNoteSpacing","itemLayoutOf","hasNoteHeads","applyStaffLines","visibleLineYs","renderScore","ctx","score","layoutPlan","options","hooks","groupsById","Map","groups","map","group","groupId","measuresByGroup","groupMeasuresByIndex","measures","attachmentsByOwner","itemsLayout","items","contentSize","system","systems","get","staves","length","measurePlans","measureIndices","measureIndex","filter","measure","Boolean","measurePlan","entries","renderMeasure","isFirstMeasureInSystem","isLastMeasureInSystem","fixedNoteSpacing","render","formatter","resolvedStateByStaffId","staff","staffIndex","id","resolvedStatesByStaff","staffRenderArtifacts","resolvedState","vfVoices","voiceArtifacts","beams","tuplets","voices","voice","voiceIndex","meter","clef","directions","undefined","itemContext","decorateItem","resolveClef","item","targetStaffId","ownerStaffId","vfVoice","joinVoices","notes","flatMap","allVoices","renderedStaves","stave","x","y","staffYOffsets","width","lines","setContext","draw","renderedStaveByStaffId","renderStaffConnectors","forEach","index","targetStave","setStave","referenceStave","getFormatReferenceStave","formatToStave","setRendered","drawVoiceItems","onDrawItem","beam","tuplet","collectMeasureLayout","reduce","reference","getNoteStartX","push","staffId","systemIndex","staveNoteStartX","staveNoteEndX","getNoteEndX","height","staveLineTopY","getTopLineTopY","staveLineBottomY","getBottomLineBottomY","note","beginColorGroup","drawWithStyle","layout","endColorGroup","staffGroup","topStave","bottomStave","connectorSymbol","resolveStaffGroupConnectorSymbol","drawStaveConnector","connectorSymbolToVFType","requireStaveConnectorType","type","SINGLE_LEFT","SINGLE_RIGHT","symbol","role","BRACE","BRACKET","setType","Error","groupMeasures","set"],"sourceRoot":"../../../src","sources":["renderer/render.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,KAAK,EAAEC,cAAc,QAAQ,SAAS;AAgB1D,SACEC,qBAAqB,EACrBC,uBAAuB,QAClB,uBAAoB;AAC3B,SAASC,uBAAuB,EAAEC,WAAW,QAAQ,mBAAgB;AACrE,SAASC,qBAAqB,QAAQ,uBAAoB;AAC1D,SAASC,YAAY,QAAQ,iBAAc;AAC3C,SAASC,YAAY,QAAQ,oBAAiB;AAC9C,SAASC,eAAe,EAAEC,aAAa,QAAQ,YAAS;AAIxD;AACA;AACA;AACA;AACA,OAAO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AAkB,EAClBM,IAAwB,EACxB;EACA,IAAIhI,cAAc,CAACyH,QAAQ,EAAEC,WAAW,CAAC,CACtCa,OAAO,CAACP,IAAI,CAAC,CACb5C,UAAU,CAACzE,GAAG,CAAC,CACf0E,IAAI,CAAC,CAAC;AACX;AAEA,SAAS0C,yBAAyBA,CAChCC,IAAqD,EACjC;EACpB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,MAAM,IAAIQ,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEA,OAAOR,IAAI;AACb;AAEA,SAASzG,oBAAoBA,CAACC,QAA6B,EAAE;EAC3D,MAAMF,eAAe,GAAG,IAAIL,GAAG,CAAyC,CAAC;EAEzE,KAAK,MAAMqB,OAAO,IAAId,QAAQ,EAAE;IAC9B,MAAMiH,aAAa,GACjBnH,eAAe,CAACS,GAAG,CAACO,OAAO,CAACjB,OAAO,CAAC,IACpC,IAAIJ,GAAG,CAA4B,CAAC;IAEtCwH,aAAa,CAACC,GAAG,CAACpG,OAAO,CAACF,YAAY,EAAEE,OAAO,CAAC;IAChDhB,eAAe,CAACoH,GAAG,CAACpG,OAAO,CAACjB,OAAO,EAAEoH,aAAa,CAAC;EACrD;EAEA,OAAOnH,eAAe;AACxB","ignoreList":[]}
|
|
@@ -60,7 +60,10 @@ export function scaleItemsLayoutToViewSpace(itemsLayout, scale) {
|
|
|
60
60
|
...item,
|
|
61
61
|
x: item.x * scale,
|
|
62
62
|
width: item.width * scale,
|
|
63
|
-
headCenterX: item.headCenterX * scale
|
|
63
|
+
headCenterX: item.headCenterX * scale,
|
|
64
|
+
...(item.modifierBounds ? {
|
|
65
|
+
modifierBounds: scaleBounds(item.modifierBounds, scale)
|
|
66
|
+
} : {})
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
return {
|
|
@@ -74,9 +77,20 @@ export function scaleItemsLayoutToViewSpace(itemsLayout, scale) {
|
|
|
74
77
|
y: measure.y * scale,
|
|
75
78
|
height: measure.height * scale,
|
|
76
79
|
staveLineTopY: measure.staveLineTopY * scale,
|
|
77
|
-
staveLineBottomY: measure.staveLineBottomY * scale
|
|
80
|
+
staveLineBottomY: measure.staveLineBottomY * scale,
|
|
81
|
+
...(measure.visibleLineYs ? {
|
|
82
|
+
visibleLineYs: measure.visibleLineYs.map(y => y * scale)
|
|
83
|
+
} : {})
|
|
78
84
|
})),
|
|
79
85
|
contentSize: toViewSize(itemsLayout.contentSize, scale)
|
|
80
86
|
};
|
|
81
87
|
}
|
|
88
|
+
function scaleBounds(bounds, scale) {
|
|
89
|
+
return {
|
|
90
|
+
left: bounds.left * scale,
|
|
91
|
+
right: bounds.right * scale,
|
|
92
|
+
top: bounds.top * scale,
|
|
93
|
+
bottom: bounds.bottom * scale
|
|
94
|
+
};
|
|
95
|
+
}
|
|
82
96
|
//# sourceMappingURL=scale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getRenderScale","options","scale","render","Number","isFinite","createContentViewport","viewport","x","y","width","height","toViewSize","size","scaleItemsLayoutToViewSpace","itemsLayout","items","itemId","item","Object","entries","headCenterX","measures","map","measure","staveNoteStartX","staveNoteEndX","staveLineTopY","staveLineBottomY","contentSize"],"sourceRoot":"../../../src","sources":["renderer/scale.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["getRenderScale","options","scale","render","Number","isFinite","createContentViewport","viewport","x","y","width","height","toViewSize","size","scaleItemsLayoutToViewSpace","itemsLayout","items","itemId","item","Object","entries","headCenterX","modifierBounds","scaleBounds","measures","map","measure","staveNoteStartX","staveNoteEndX","staveLineTopY","staveLineBottomY","visibleLineYs","contentSize","bounds","left","right","top","bottom"],"sourceRoot":"../../../src","sources":["renderer/scale.ts"],"mappings":";;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,SAASA,cAAcA,CAACC,OAE9B,EAAU;EACT,MAAMC,KAAK,GAAGD,OAAO,EAAEE,MAAM,EAAED,KAAK;EAEpC,OA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AACG,GAAG,GAAGlC,KAAK;IACvBmC,MAAM,EAAEJ,MAAM,CAACI,MAAM,GAAGnC;EAC1B,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export const NOTEHEAD_TO_VF_CODE = {
|
|
8
|
-
'x': 'x',
|
|
9
|
-
'circle-x': 'cx',
|
|
10
|
-
'diamond': 'h',
|
|
11
|
-
'circle': 'ci',
|
|
12
|
-
'square': 'sq',
|
|
13
|
-
'triangle': 'tu',
|
|
14
|
-
'triangle-down': 'td',
|
|
15
|
-
'slash': 'sf'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Maps library articulation names to VexFlow articulation codes.
|
|
20
|
-
*/
|
|
21
|
-
export const ARTICULATION_TO_VF_CODE = {
|
|
22
|
-
staccato: 'a.',
|
|
23
|
-
staccatissimo: 'av',
|
|
24
|
-
tenuto: 'a-',
|
|
25
|
-
accent: 'a>',
|
|
26
|
-
marcato: 'a^',
|
|
27
|
-
fermata: 'a@',
|
|
28
|
-
open: 'ah',
|
|
29
|
-
stopped: 'a+'
|
|
30
|
-
};
|
|
31
|
-
|
|
3
|
+
import { Beam, Element, Fraction as VFFraction, GhostNote, StaveNote, Stem, Tuplet, Voice as VFVoice } from 'vexflow';
|
|
4
|
+
import { applyDots, applyMeasureDirections, applyNoteModifiers, decorateStaveNote, restAttachments } from "./noteModifiers.js";
|
|
5
|
+
import { durationToVF, pitchToVFKey, restKeyForStaffLine } from "./vfKeys.js";
|
|
32
6
|
/**
|
|
33
7
|
* Maps the library stem direction to the numeric VexFlow value.
|
|
34
8
|
*/
|
|
@@ -41,138 +15,6 @@ export function toVFStemDirection(dir) {
|
|
|
41
15
|
}
|
|
42
16
|
return undefined;
|
|
43
17
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Converts an internal pitch into the VexFlow key string format.
|
|
47
|
-
*/
|
|
48
|
-
export function pitchToVFKey(pitch) {
|
|
49
|
-
const accidental = pitch.accidental === 'quarter-flat' ? 'db' : pitch.accidental === 'quarter-sharp' ? 'd#' : pitch.accidental ?? '';
|
|
50
|
-
const key = `${pitch.step.toLowerCase()}${accidental}/${pitch.octave}`;
|
|
51
|
-
if (pitch.notehead) {
|
|
52
|
-
return `${key}/${NOTEHEAD_TO_VF_CODE[pitch.notehead]}`;
|
|
53
|
-
}
|
|
54
|
-
return key;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Converts a duration into the VexFlow duration token, including rests.
|
|
59
|
-
*/
|
|
60
|
-
export function durationToVF(duration, isRest = false) {
|
|
61
|
-
const length = duration.length === 'long' || duration.length === 'breve' ? '1/2' : duration.length;
|
|
62
|
-
|
|
63
|
-
// Dots drive VexFlow's tick math, so rests need them in the token too or
|
|
64
|
-
// strict voices come up short.
|
|
65
|
-
const dots = 'd'.repeat(duration.dots ?? 0);
|
|
66
|
-
return `${length}${dots}${isRest ? 'r' : ''}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Applies the requested number of augmentation dots to a note.
|
|
71
|
-
*/
|
|
72
|
-
export function applyDots(note, dots) {
|
|
73
|
-
for (let i = 0; i < (dots ?? 0); i++) {
|
|
74
|
-
Dot.buildAndAttach([note], {
|
|
75
|
-
all: true
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Adds pitch accidentals to the matching keys in a VexFlow note.
|
|
82
|
-
*/
|
|
83
|
-
export function addPitchAccidentals(note, pitches) {
|
|
84
|
-
pitches.forEach((pitch, index) => {
|
|
85
|
-
if (!pitch.accidental) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const type = pitch.accidental === 'quarter-flat' ? 'db' : pitch.accidental === 'quarter-sharp' ? 'd#' : pitch.accidental;
|
|
89
|
-
note.addModifier(new VFAccidental(type), index);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Wraps each ghost pitch of a note in parentheses.
|
|
95
|
-
*/
|
|
96
|
-
export function applyGhostParentheses(note, pitches) {
|
|
97
|
-
pitches.forEach((pitch, index) => {
|
|
98
|
-
if (!pitch.ghost) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
note.addModifier(new Parenthesis(ModifierPosition.LEFT), index);
|
|
102
|
-
note.addModifier(new Parenthesis(ModifierPosition.RIGHT), index);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function hasAccentAttachment(attachments) {
|
|
106
|
-
return attachments?.some(attachment => attachment.type === 'articulation' && attachment.articulation === 'accent') ?? false;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Draws one accent above a note whose pitches carry the `accent` flag, unless
|
|
111
|
-
* the owner already has an accent attachment.
|
|
112
|
-
*/
|
|
113
|
-
export function applyPitchAccent(note, pitches, attachments) {
|
|
114
|
-
if (!pitches.some(pitch => pitch.accent)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (hasAccentAttachment(attachments)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
note.addModifier(new VFArticulation(ARTICULATION_TO_VF_CODE.accent), 0);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Attaches the owner's articulation and grace-note modifiers to a VexFlow
|
|
125
|
-
* note; dynamics and lyrics are drawn elsewhere.
|
|
126
|
-
*/
|
|
127
|
-
export function applyNoteModifiers(note, clef, attachments) {
|
|
128
|
-
if (!attachments) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
for (const attachment of attachments) {
|
|
132
|
-
if (attachment.type === 'articulation') {
|
|
133
|
-
const articulation = new VFArticulation(ARTICULATION_TO_VF_CODE[attachment.articulation]);
|
|
134
|
-
if (attachment.placement === 'below') {
|
|
135
|
-
articulation.setPosition(ModifierPosition.BELOW);
|
|
136
|
-
}
|
|
137
|
-
note.addModifier(articulation, 0);
|
|
138
|
-
} else if (attachment.type === 'grace') {
|
|
139
|
-
applyGraceNoteGroup(note, clef, attachment);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Grace notes stem up unless the owner was built stem-down (auto stems that
|
|
146
|
-
* flip later in `Beam.generateBeams` are not followed); two or more are
|
|
147
|
-
* beamed together, with the acciaccatura slash on the first stem only.
|
|
148
|
-
*/
|
|
149
|
-
function applyGraceNoteGroup(note, clef, attachment) {
|
|
150
|
-
if (attachment.notes.length === 0) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const stemDirection = note.getStemDirection() === Stem.DOWN ? Stem.DOWN : Stem.UP;
|
|
154
|
-
const graceNotes = attachment.notes.map((graceNote, index) => {
|
|
155
|
-
const vfGraceNote = new VFGraceNote({
|
|
156
|
-
clef,
|
|
157
|
-
keys: [pitchToVFKey(graceNote.pitch)],
|
|
158
|
-
duration: durationToVF(graceNote.duration),
|
|
159
|
-
slash: index === 0 && attachment.slash === true,
|
|
160
|
-
stemDirection
|
|
161
|
-
});
|
|
162
|
-
decorateStaveNote(vfGraceNote, [graceNote.pitch], graceNote.duration);
|
|
163
|
-
return vfGraceNote;
|
|
164
|
-
});
|
|
165
|
-
const group = new GraceNoteGroup(graceNotes);
|
|
166
|
-
if (graceNotes.length > 1) {
|
|
167
|
-
group.beamNotes();
|
|
168
|
-
}
|
|
169
|
-
note.addModifier(group, 0);
|
|
170
|
-
}
|
|
171
|
-
function decorateStaveNote(note, pitches, duration) {
|
|
172
|
-
addPitchAccidentals(note, pitches);
|
|
173
|
-
applyGhostParentheses(note, pitches);
|
|
174
|
-
applyDots(note, duration.dots);
|
|
175
|
-
}
|
|
176
18
|
export function indexAttachmentsByOwner(score) {
|
|
177
19
|
const attachmentsByOwner = new Map();
|
|
178
20
|
for (const attachment of score.attachments ?? []) {
|
|
@@ -209,44 +51,38 @@ function spacerTickWidth() {
|
|
|
209
51
|
/**
|
|
210
52
|
* Builds a VexFlow stave note from a score voice item and clef.
|
|
211
53
|
*/
|
|
212
|
-
export function voiceItemToStaveNote(item, clef, attachments) {
|
|
213
|
-
if (item.type === 'rest') {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
note.setWidth(spacerTickWidth());
|
|
218
|
-
}
|
|
219
|
-
return note;
|
|
54
|
+
export function voiceItemToStaveNote(item, clef, attachments, decorate) {
|
|
55
|
+
if (item.type === 'rest' && (item.kind === 'hidden' || item.kind === 'spacer')) {
|
|
56
|
+
const note = new GhostNote(durationToVF(item.duration));
|
|
57
|
+
if (item.kind === 'spacer') {
|
|
58
|
+
note.setWidth(spacerTickWidth());
|
|
220
59
|
}
|
|
221
|
-
const note = new StaveNote({
|
|
222
|
-
clef,
|
|
223
|
-
keys: ['b/4'],
|
|
224
|
-
duration: durationToVF(item.duration, true)
|
|
225
|
-
});
|
|
226
|
-
applyDots(note, item.duration.dots);
|
|
227
60
|
return note;
|
|
228
61
|
}
|
|
229
|
-
|
|
62
|
+
const note = buildStaveNote(item, clef);
|
|
63
|
+
const applied = (item.type === 'rest' ? restAttachments(attachments) : attachments) ?? [];
|
|
64
|
+
applyNoteModifiers(note, clef, applied);
|
|
65
|
+
decorate?.(item, note, applied);
|
|
66
|
+
return note;
|
|
67
|
+
}
|
|
68
|
+
function buildStaveNote(item, clef) {
|
|
69
|
+
if (item.type === 'rest') {
|
|
230
70
|
const note = new StaveNote({
|
|
231
71
|
clef,
|
|
232
|
-
keys: [
|
|
233
|
-
duration: durationToVF(item.duration)
|
|
234
|
-
stemDirection: toVFStemDirection(item.stemDirection)
|
|
72
|
+
keys: [restKeyForStaffLine(clef, item.staffLine)],
|
|
73
|
+
duration: durationToVF(item.duration, true)
|
|
235
74
|
});
|
|
236
|
-
|
|
237
|
-
applyPitchAccent(note, [item.pitch], attachments);
|
|
238
|
-
applyNoteModifiers(note, clef, attachments);
|
|
75
|
+
applyDots(note, item.duration.dots);
|
|
239
76
|
return note;
|
|
240
77
|
}
|
|
78
|
+
const pitches = item.type === 'note' ? [item.pitch] : item.pitches;
|
|
241
79
|
const note = new StaveNote({
|
|
242
80
|
clef,
|
|
243
|
-
keys:
|
|
81
|
+
keys: pitches.map(pitchToVFKey),
|
|
244
82
|
duration: durationToVF(item.duration),
|
|
245
83
|
stemDirection: toVFStemDirection(item.stemDirection)
|
|
246
84
|
});
|
|
247
|
-
decorateStaveNote(note,
|
|
248
|
-
applyPitchAccent(note, item.pitches, attachments);
|
|
249
|
-
applyNoteModifiers(note, clef, attachments);
|
|
85
|
+
decorateStaveNote(note, pitches, item.duration);
|
|
250
86
|
return note;
|
|
251
87
|
}
|
|
252
88
|
|
|
@@ -312,7 +148,20 @@ export function buildResolvedMeasureStates(score, staff) {
|
|
|
312
148
|
*/
|
|
313
149
|
export function makeVFVoice(score, meter, clef, voice, options = {}) {
|
|
314
150
|
const attachmentsByOwner = options.attachmentsByOwner ?? indexAttachmentsByOwner(score);
|
|
315
|
-
const
|
|
151
|
+
const {
|
|
152
|
+
itemContext
|
|
153
|
+
} = options;
|
|
154
|
+
const notes = voice.items.map(item => {
|
|
155
|
+
const itemClef = options.resolveClef?.(item) ?? clef;
|
|
156
|
+
const decorate = itemContext ? (decoratedItem, note, attachments) => itemContext.decorateItem(decoratedItem, note, {
|
|
157
|
+
clef: itemClef,
|
|
158
|
+
staff: itemContext.staff,
|
|
159
|
+
measureIndex: itemContext.measureIndex,
|
|
160
|
+
attachments
|
|
161
|
+
}) : undefined;
|
|
162
|
+
return voiceItemToStaveNote(item, itemClef, attachmentsByOwner.get(item.id), decorate);
|
|
163
|
+
});
|
|
164
|
+
applyMeasureDirections(notes, options.directions);
|
|
316
165
|
const noteByItemId = new Map();
|
|
317
166
|
voice.items.forEach((item, index) => noteByItemId.set(item.id, notes[index]));
|
|
318
167
|
const tuplets = findTupletsForVoice(score, voice).map(group => {
|
|
@@ -340,7 +189,7 @@ export function makeVFVoice(score, meter, clef, voice, options = {}) {
|
|
|
340
189
|
throw new Error(`Error adding tickables to voice ${voice.id}: ${error.message}`);
|
|
341
190
|
}
|
|
342
191
|
const groups = beamGroupsToVF(meter);
|
|
343
|
-
const maintainStemDirections = voice.items.some(hasExplicitStemDirection);
|
|
192
|
+
const maintainStemDirections = options.staff?.lines === 1 || voice.items.some(hasExplicitStemDirection);
|
|
344
193
|
const beamOptions = groups || maintainStemDirections ? {
|
|
345
194
|
...(groups ? {
|
|
346
195
|
groups
|