vexflow-native 1.4.1 → 1.7.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.
Files changed (45) hide show
  1. package/README.md +31 -1
  2. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js +61 -12
  3. package/lib/module/musicxml/MusicXmlParser/MeasureParser.js.map +1 -1
  4. package/lib/module/musicxml/MusicXmlParser/PartParser.js +1 -0
  5. package/lib/module/musicxml/MusicXmlParser/PartParser.js.map +1 -1
  6. package/lib/module/musicxml/MusicXmlParser/index.js +1 -0
  7. package/lib/module/musicxml/MusicXmlParser/index.js.map +1 -1
  8. package/lib/module/musicxml/MusicXmlParser/mappers.js +11 -1
  9. package/lib/module/musicxml/MusicXmlParser/mappers.js.map +1 -1
  10. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +14 -1
  11. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
  12. package/lib/module/renderer/measure.js +19 -14
  13. package/lib/module/renderer/measure.js.map +1 -1
  14. package/lib/module/renderer/render.js +24 -13
  15. package/lib/module/renderer/render.js.map +1 -1
  16. package/lib/module/renderer/scoreParsing.js +82 -21
  17. package/lib/module/renderer/scoreParsing.js.map +1 -1
  18. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts +7 -1
  19. package/lib/typescript/src/musicxml/MusicXmlParser/InternalTypes.d.ts.map +1 -1
  20. package/lib/typescript/src/musicxml/MusicXmlParser/MeasureParser.d.ts.map +1 -1
  21. package/lib/typescript/src/musicxml/MusicXmlParser/PartParser.d.ts.map +1 -1
  22. package/lib/typescript/src/musicxml/MusicXmlParser/index.d.ts.map +1 -1
  23. package/lib/typescript/src/musicxml/MusicXmlParser/mappers.d.ts.map +1 -1
  24. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
  25. package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
  26. package/lib/typescript/src/renderer/render.d.ts +7 -3
  27. package/lib/typescript/src/renderer/render.d.ts.map +1 -1
  28. package/lib/typescript/src/renderer/scoreParsing.d.ts +14 -3
  29. package/lib/typescript/src/renderer/scoreParsing.d.ts.map +1 -1
  30. package/lib/typescript/src/renderer/types.d.ts +1 -0
  31. package/lib/typescript/src/renderer/types.d.ts.map +1 -1
  32. package/lib/typescript/src/state/types.d.ts +15 -2
  33. package/lib/typescript/src/state/types.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/musicxml/MusicXmlParser/InternalTypes.ts +8 -0
  36. package/src/musicxml/MusicXmlParser/MeasureParser.ts +83 -20
  37. package/src/musicxml/MusicXmlParser/PartParser.ts +2 -0
  38. package/src/musicxml/MusicXmlParser/index.ts +1 -0
  39. package/src/musicxml/MusicXmlParser/mappers.ts +15 -1
  40. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +18 -0
  41. package/src/renderer/measure.tsx +21 -14
  42. package/src/renderer/render.tsx +30 -14
  43. package/src/renderer/scoreParsing.tsx +117 -22
  44. package/src/renderer/types.ts +1 -0
  45. package/src/state/types.ts +20 -2
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/state/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC;AAExB,MAAM,MAAM,IAAI,GACZ,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,eAAe,GACf,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,KAAK,CAAC;AAEV,MAAM,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE3D,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,GAAG,GACH,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,MAAM,UAAU,GAClB,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AmD;IACnD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GACtB,sBAAsB,GACtB,iBAAiB,GACjB,eAAe,GACf,mBAAmB,CAAC;AAExB,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,EAAE,CAAC;IACP,UAAU,EAAE,EAAE,CAAC;IACf,QAAQ,EAAE,EAAE,CAAC;CACd;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,EAAE,CAAC;IACP,UAAU,EAAE,EAAE,CAAC;IACf,QAAQ,EAAE,EAAE,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,EAAE,CAAC;IACP,OAAO,EAAE,EAAE,CAAC;IACZ,OAAO,EAAE,EAAE,EAAE,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexflow-native",
3
- "version": "1.4.1",
3
+ "version": "1.7.0",
4
4
  "description": "React native backend for rendering music notation using @shopify/react-native-skia",
5
5
  "main": "./lib/module/base/index.js",
6
6
  "types": "./lib/typescript/src/base/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  Dynamic,
3
+ GraceNote,
3
4
  Measure,
4
5
  NoteAttachment,
5
6
  ScoreDefaults,
@@ -26,6 +27,11 @@ type ActiveSpanner = {
26
27
  itemId: string;
27
28
  };
28
29
 
30
+ export type PendingGraceNotes = {
31
+ notes: GraceNote[];
32
+ slash: boolean;
33
+ };
34
+
29
35
  export type ParserState = {
30
36
  scoreId: string;
31
37
  divisions: number;
@@ -35,6 +41,8 @@ export type ParserState = {
35
41
  slurs: Slur[];
36
42
  tuplets: TupletGroup[];
37
43
  pendingDynamics: Map<string, Dynamic[]>;
44
+ /** Keyed by MusicXML voice name; consumed by that voice's next note. */
45
+ pendingGraceNotes: Map<string, PendingGraceNotes>;
38
46
  activeTies: Map<string, ActiveSpanner>;
39
47
  activeSlurs: Map<string, ActiveSpanner>;
40
48
  activeTuplets: Map<string, TupletGroup>;
@@ -1,8 +1,10 @@
1
1
  import type {
2
2
  Chord,
3
3
  Direction,
4
+ DurationValue,
4
5
  Measure,
5
6
  MeasureState,
7
+ Pitch,
6
8
  Voice,
7
9
  VoiceItem,
8
10
  } from '../../state';
@@ -205,6 +207,12 @@ function parseNote(
205
207
  }
206
208
 
207
209
  if (hasChild(note, 'grace')) {
210
+ const graceVoiceName = childText(note, 'voice');
211
+
212
+ if (graceVoiceName) {
213
+ collectGraceNote(note, graceVoiceName, state);
214
+ }
215
+
208
216
  return currentPosition;
209
217
  }
210
218
 
@@ -239,6 +247,7 @@ function parseNote(
239
247
  ? mergeChordTone(voice, item, note)
240
248
  : pushItem(voice, item);
241
249
 
250
+ attachPendingGraceNotes(itemId, voiceName, state);
242
251
  applyNoteAttachments(note, itemId, staffNumber, voice.id, state);
243
252
 
244
253
  if (isChordTone) {
@@ -330,20 +339,7 @@ function createVoiceItem(
330
339
  isChordTone: boolean,
331
340
  state: ParserState
332
341
  ): VoiceItem {
333
- const typeText = childText(note, 'type');
334
- const type = typeText
335
- ? mapDurationType(typeText)
336
- : inferDurationType(requiredNumberText(note, 'duration'), state.divisions);
337
- const dotCount = childrenNamed(note, 'dot').length;
338
-
339
- if (dotCount > 3) {
340
- throw new MusicXmlParseError('More than three dots are unsupported');
341
- }
342
-
343
- const duration = {
344
- length: type,
345
- dots: dotCount ? (dotCount as 1 | 2 | 3) : undefined,
346
- };
342
+ const duration = parseDuration(note, state);
347
343
 
348
344
  if (hasChild(note, 'rest')) {
349
345
  if (isChordTone) {
@@ -359,21 +355,88 @@ function createVoiceItem(
359
355
  };
360
356
  }
361
357
 
362
- const pitch = mapPitch(
363
- firstChild(note, 'pitch'),
364
- childText(note, 'accidental')
365
- );
366
-
367
358
  return {
368
359
  id: '',
369
360
  type: 'note',
370
- pitch,
361
+ pitch: parsePitch(note),
371
362
  duration,
372
363
  voiceId: voice.id,
373
364
  stemDirection: mapStemDirection(childText(note, 'stem')),
374
365
  };
375
366
  }
376
367
 
368
+ function parseDuration(note: XmlElement, state: ParserState): DurationValue {
369
+ const typeText = childText(note, 'type');
370
+ const type = typeText
371
+ ? mapDurationType(typeText)
372
+ : inferDurationType(requiredNumberText(note, 'duration'), state.divisions);
373
+ const dotCount = childrenNamed(note, 'dot').length;
374
+
375
+ if (dotCount > 3) {
376
+ throw new MusicXmlParseError('More than three dots are unsupported');
377
+ }
378
+
379
+ return {
380
+ length: type,
381
+ dots: dotCount ? (dotCount as 1 | 2 | 3) : undefined,
382
+ };
383
+ }
384
+
385
+ function parsePitch(note: XmlElement): Pitch {
386
+ return mapPitch(firstChild(note, 'pitch'), childText(note, 'accidental'));
387
+ }
388
+
389
+ /**
390
+ * Grace chord tones keep only their first pitch; the group's slash comes
391
+ * from its first grace note.
392
+ */
393
+ function collectGraceNote(
394
+ note: XmlElement,
395
+ voiceName: string,
396
+ state: ParserState
397
+ ) {
398
+ if (hasChild(note, 'chord')) {
399
+ return;
400
+ }
401
+
402
+ const graceNote = {
403
+ pitch: parsePitch(note),
404
+ duration: parseDuration(note, state),
405
+ };
406
+ const pending = state.pendingGraceNotes.get(voiceName);
407
+
408
+ if (pending) {
409
+ pending.notes.push(graceNote);
410
+ return;
411
+ }
412
+
413
+ state.pendingGraceNotes.set(voiceName, {
414
+ notes: [graceNote],
415
+ slash: attr(firstChild(note, 'grace'), 'slash') === 'yes',
416
+ });
417
+ }
418
+
419
+ function attachPendingGraceNotes(
420
+ itemId: string,
421
+ voiceName: string,
422
+ state: ParserState
423
+ ) {
424
+ const pending = state.pendingGraceNotes.get(voiceName);
425
+
426
+ if (!pending) {
427
+ return;
428
+ }
429
+
430
+ state.pendingGraceNotes.delete(voiceName);
431
+ state.attachments.push({
432
+ id: `${itemId}-grace`,
433
+ ownerId: itemId,
434
+ type: 'grace',
435
+ notes: pending.notes,
436
+ ...(pending.slash ? { slash: true } : {}),
437
+ });
438
+ }
439
+
377
440
  function pushItem(voice: Voice, item: VoiceItem): string {
378
441
  item.id = `${voice.id}-item-${(voice.items.length + 1).toString()}`;
379
442
  voice.items.push(item);
@@ -35,6 +35,8 @@ export function parsePart(
35
35
  parseMeasure(measure, measureIndex, builds, state);
36
36
  });
37
37
 
38
+ state.pendingGraceNotes.clear();
39
+
38
40
  const staves = builds.map(
39
41
  (staff): Staff => ({
40
42
  id: staff.id,
@@ -43,6 +43,7 @@ export function parseMusicXmlToScore(
43
43
  slurs: [],
44
44
  tuplets: [],
45
45
  pendingDynamics: new Map(),
46
+ pendingGraceNotes: new Map(),
46
47
  activeTies: new Map(),
47
48
  activeSlurs: new Map(),
48
49
  activeTuplets: new Map(),
@@ -226,11 +226,25 @@ export function articulationsFromNotations(
226
226
  articulations.push('fermata');
227
227
  }
228
228
 
229
- return articulations.filter(
229
+ const technical = childrenNamed(notations, 'technical').flatMap((group) =>
230
+ group.children.map((child) => mapTechnical(child.name))
231
+ );
232
+
233
+ return [...articulations, ...technical].filter(
230
234
  (item): item is Articulation => item !== undefined
231
235
  );
232
236
  }
233
237
 
238
+ function mapTechnical(name: string): Articulation | undefined {
239
+ switch (name) {
240
+ case 'open':
241
+ case 'stopped':
242
+ return name;
243
+ default:
244
+ return undefined;
245
+ }
246
+ }
247
+
234
248
  function mapArticulation(name: string): Articulation | undefined {
235
249
  switch (name) {
236
250
  case 'staccato':
@@ -48,6 +48,7 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
48
48
  playheadStyle,
49
49
  onScrollGeometry,
50
50
  onItemsLayout,
51
+ onReady,
51
52
  }) => {
52
53
  const options = useMemo(() => withDefaultOptions(userOptions), [userOptions]);
53
54
 
@@ -210,6 +211,23 @@ const ScoreRenderer: React.FC<ScoreRendererProps> = ({
210
211
  return () => picture.dispose();
211
212
  }, [picture]);
212
213
 
214
+ const onReadyRef = useRef(onReady);
215
+
216
+ useEffect(() => {
217
+ onReadyRef.current = onReady;
218
+ });
219
+
220
+ const hasFiredReadyRef = useRef(false);
221
+
222
+ useEffect(() => {
223
+ if (hasFiredReadyRef.current || !hasViewportSize || !picture) {
224
+ return;
225
+ }
226
+
227
+ hasFiredReadyRef.current = true;
228
+ onReadyRef.current?.();
229
+ }, [hasViewportSize, picture]);
230
+
213
231
  const { scrollOffset } = scrollState;
214
232
 
215
233
  const pictureTransform = useDerivedValue(() => {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Articulation as VFArticulation,
3
3
  Formatter,
4
+ GraceNoteGroup,
4
5
  Stave,
5
6
  Voice as VFVoice,
6
7
  } from 'vexflow';
@@ -105,10 +106,7 @@ export function measureScore(
105
106
  );
106
107
  const vfVoices = voiceArtifacts.map(({ vfVoice }) => vfVoice);
107
108
 
108
- if (vfVoices.length > 1) {
109
- formatter.joinVoices(vfVoices);
110
- }
111
-
109
+ formatter.joinVoices(vfVoices);
112
110
  allVoices.push(...vfVoices);
113
111
 
114
112
  return {
@@ -261,9 +259,7 @@ function measureStaffVerticalBounds({
261
259
  ({ measure, ownerStaffId, staffIndex, voiceArtifacts }) => {
262
260
  const vfVoices = voiceArtifacts.map(({ vfVoice }) => vfVoice);
263
261
 
264
- if (vfVoices.length > 1) {
265
- formatter.joinVoices(vfVoices);
266
- }
262
+ formatter.joinVoices(vfVoices);
267
263
 
268
264
  voiceArtifacts.forEach(({ notes }, voiceIndex) => {
269
265
  const items = measure.voices[voiceIndex]?.items ?? [];
@@ -306,7 +302,7 @@ function measureStaffVerticalBounds({
306
302
  staffIndexById.get(
307
303
  items[noteIndex]?.targetStaffId ?? ownerStaffId
308
304
  ) ?? staffIndex;
309
- mergeArticulationBounds(bounds[ownerStaffIndex], note);
305
+ mergeModifierBounds(bounds[ownerStaffIndex], note);
310
306
  mergeNoteBounds(bounds[ownerStaffIndex], note);
311
307
  });
312
308
 
@@ -358,11 +354,12 @@ function createNoopRenderContext(): RenderContext {
358
354
  const NOOP_RENDER_CONTEXT = createNoopRenderContext();
359
355
 
360
356
  /**
361
- * Merges the drawn extents of a note's articulations into the staff bounds.
362
- * VexFlow only positions an articulation inside `draw()`, so each one is
363
- * drawn against a no-op context first to make its bounding box real.
357
+ * Merges the drawn extents of a note's articulations and grace-note groups
358
+ * into the staff bounds. VexFlow only positions these modifiers inside
359
+ * `draw()`, so each one is drawn against a no-op context first to make its
360
+ * bounding boxes real.
364
361
  */
365
- function mergeArticulationBounds(
362
+ function mergeModifierBounds(
366
363
  bounds: StaffVerticalBounds | undefined,
367
364
  note: VFVoiceNote
368
365
  ) {
@@ -371,14 +368,24 @@ function mergeArticulationBounds(
371
368
  }
372
369
 
373
370
  for (const modifier of note.getModifiers()) {
374
- if (!(modifier instanceof VFArticulation)) {
371
+ const isArticulation = modifier instanceof VFArticulation;
372
+ const isGraceNoteGroup = modifier instanceof GraceNoteGroup;
373
+
374
+ if (!isArticulation && !isGraceNoteGroup) {
375
375
  continue;
376
376
  }
377
377
 
378
378
  try {
379
379
  modifier.setContext(NOOP_RENDER_CONTEXT);
380
380
  modifier.draw();
381
- mergeBoundingBox(bounds, modifier.getBoundingBox());
381
+
382
+ if (isGraceNoteGroup) {
383
+ modifier.getGraceNotes().forEach((graceNote) => {
384
+ mergeBoundingBox(bounds, graceNote.getBoundingBox());
385
+ });
386
+ } else {
387
+ mergeBoundingBox(bounds, modifier.getBoundingBox());
388
+ }
382
389
  } catch {
383
390
  // Ghost and spacer notes cannot place modifiers; note bounds remain
384
391
  // the fallback.
@@ -101,9 +101,13 @@ interface RenderMeasureOptions {
101
101
  * area, overriding the formatter's duration-weighted spacing. Runs after
102
102
  * `formatToStave` (the same post-format `setX` mechanism the formatter's own
103
103
  * tuning uses), so beams, tuplets and modifiers pick the final positions up
104
- * at draw time. The proportional span is clamped only by the LAST context's
105
- * width — with a spacer voice on the lattice that width is constant, so the
106
- * mapping stays a pure function of time.
104
+ * at draw time. The lattice follows VexFlow's own convention for its first
105
+ * tick: it starts at that context's left-modifier width (`totalLeftPx`), so a
106
+ * grace group or accidental on beat 1 hangs inside the note area instead of
107
+ * over the clef. The proportional span is clamped only by that inset and the
108
+ * LAST context's width — with a spacer voice on the lattice the latter is
109
+ * constant, so the mapping stays a pure function of time and of what hangs
110
+ * left of beat 1.
107
111
  */
108
112
  export function applyFixedNoteSpacing(
109
113
  formatter: Formatter,
@@ -111,13 +115,13 @@ export function applyFixedNoteSpacing(
111
115
  stave: Stave
112
116
  ) {
113
117
  const contexts = formatter.getTickContexts();
114
- const lastTick = contexts?.list[contexts.list.length - 1];
118
+ const lastTickKey = contexts?.list[contexts.list.length - 1];
115
119
 
116
120
  if (
117
121
  !contexts ||
118
122
  voices.length === 0 ||
119
- lastTick === undefined ||
120
- lastTick <= 0
123
+ lastTickKey === undefined ||
124
+ lastTickKey <= 0
121
125
  ) {
122
126
  return;
123
127
  }
@@ -128,6 +132,14 @@ export function applyFixedNoteSpacing(
128
132
  return;
129
133
  }
130
134
 
135
+ // Tick context keys are ticks × the formatter's resolution multiplier (the
136
+ // lcm that keeps tuplet ticks integral: 3 with triplets, 5 with
137
+ // quintuplets…), while getTotalTicks() is in plain ticks. Compare in plain
138
+ // ticks, or every position scales by the multiplier and the overflow
139
+ // correction below crushes the last tick flush against the note end.
140
+ const multiplier = contexts.resolutionMultiplier || 1;
141
+ const lastTick = lastTickKey / multiplier;
142
+
131
143
  // Tick context x is relative to noteStartX + the stave's left note padding
132
144
  // (see Tickable.getAbsoluteX), so the usable span ends at noteEndX. The
133
145
  // padding is derived from Stave statics because the `Metrics` module is not
@@ -135,11 +147,15 @@ export function applyFixedNoteSpacing(
135
147
  const stavePadding = Stave.defaultPadding - Stave.rightPadding;
136
148
  const noteAreaWidth =
137
149
  stave.getNoteEndX() - stave.getNoteStartX() - stavePadding;
138
- let span = noteAreaWidth;
150
+ const firstLeft = contexts.map[contexts.list[0]!]!.getMetrics().totalLeftPx;
151
+ let span = noteAreaWidth - firstLeft;
139
152
 
140
- const lastContext = contexts.map[lastTick]!;
153
+ const lastContext = contexts.map[lastTickKey]!;
141
154
  const lastOverflow =
142
- (lastTick / totalTicks) * span + lastContext.getWidth() - noteAreaWidth;
155
+ firstLeft +
156
+ (lastTick / totalTicks) * span +
157
+ lastContext.getWidth() -
158
+ noteAreaWidth;
143
159
 
144
160
  if (lastOverflow > 0) {
145
161
  span -= (lastOverflow * totalTicks) / lastTick;
@@ -149,8 +165,10 @@ export function applyFixedNoteSpacing(
149
165
  return;
150
166
  }
151
167
 
152
- for (const tick of contexts.list) {
153
- contexts.map[tick]!.setX((tick / totalTicks) * span);
168
+ for (const tickKey of contexts.list) {
169
+ contexts.map[tickKey]!.setX(
170
+ firstLeft + (tickKey / multiplier / totalTicks) * span
171
+ );
154
172
  }
155
173
  }
156
174
 
@@ -195,9 +213,7 @@ function renderMeasure(
195
213
  }));
196
214
  const vfVoices = voiceArtifacts.map(({ vfVoice }) => vfVoice);
197
215
 
198
- if (vfVoices.length > 1) {
199
- formatter.joinVoices(vfVoices);
200
- }
216
+ formatter.joinVoices(vfVoices);
201
217
 
202
218
  return {
203
219
  vfVoices,
@@ -6,6 +6,8 @@ import {
6
6
  Element,
7
7
  Fraction as VFFraction,
8
8
  GhostNote,
9
+ GraceNote as VFGraceNote,
10
+ GraceNoteGroup,
9
11
  ModifierPosition,
10
12
  Parenthesis,
11
13
  StaveNote,
@@ -20,6 +22,7 @@ import type {
20
22
  Clef,
21
23
  KeySignature,
22
24
  DurationValue,
25
+ GraceNoteAttachment,
23
26
  Meter,
24
27
  NoteAttachment,
25
28
  Notehead,
@@ -83,6 +86,8 @@ export const ARTICULATION_TO_VF_CODE: Record<Articulation, string> = {
83
86
  accent: 'a>',
84
87
  marcato: 'a^',
85
88
  fermata: 'a@',
89
+ open: 'ah',
90
+ stopped: 'a+',
86
91
  };
87
92
 
88
93
  /**
@@ -148,7 +153,10 @@ export function applyDots(note: StaveNote, dots?: 0 | 1 | 2 | 3) {
148
153
  /**
149
154
  * Adds pitch accidentals to the matching keys in a VexFlow note.
150
155
  */
151
- export function addPitchAccidentals(note: StaveNote, pitches: Pitch[]) {
156
+ export function addPitchAccidentals(
157
+ note: StaveNote,
158
+ pitches: readonly Pitch[]
159
+ ) {
152
160
  pitches.forEach((pitch, index) => {
153
161
  if (!pitch.accidental) {
154
162
  return;
@@ -182,8 +190,43 @@ export function applyGhostParentheses(
182
190
  });
183
191
  }
184
192
 
185
- export function applyArticulations(
193
+ function hasAccentAttachment(attachments: NoteAttachment[] | undefined) {
194
+ return (
195
+ attachments?.some(
196
+ (attachment) =>
197
+ attachment.type === 'articulation' &&
198
+ attachment.articulation === 'accent'
199
+ ) ?? false
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Draws one accent above a note whose pitches carry the `accent` flag, unless
205
+ * the owner already has an accent attachment.
206
+ */
207
+ export function applyPitchAccent(
186
208
  note: StaveNote,
209
+ pitches: readonly Pitch[],
210
+ attachments?: NoteAttachment[]
211
+ ) {
212
+ if (!pitches.some((pitch) => pitch.accent)) {
213
+ return;
214
+ }
215
+
216
+ if (hasAccentAttachment(attachments)) {
217
+ return;
218
+ }
219
+
220
+ note.addModifier(new VFArticulation(ARTICULATION_TO_VF_CODE.accent), 0);
221
+ }
222
+
223
+ /**
224
+ * Attaches the owner's articulation and grace-note modifiers to a VexFlow
225
+ * note; dynamics and lyrics are drawn elsewhere.
226
+ */
227
+ export function applyNoteModifiers(
228
+ note: StaveNote,
229
+ clef: Clef,
187
230
  attachments: NoteAttachment[] | undefined
188
231
  ) {
189
232
  if (!attachments) {
@@ -191,20 +234,66 @@ export function applyArticulations(
191
234
  }
192
235
 
193
236
  for (const attachment of attachments) {
194
- if (attachment.type !== 'articulation') {
195
- continue;
196
- }
237
+ if (attachment.type === 'articulation') {
238
+ const articulation = new VFArticulation(
239
+ ARTICULATION_TO_VF_CODE[attachment.articulation]
240
+ );
197
241
 
198
- const articulation = new VFArticulation(
199
- ARTICULATION_TO_VF_CODE[attachment.articulation]
200
- );
242
+ if (attachment.placement === 'below') {
243
+ articulation.setPosition(ModifierPosition.BELOW);
244
+ }
201
245
 
202
- if (attachment.placement === 'below') {
203
- articulation.setPosition(ModifierPosition.BELOW);
246
+ note.addModifier(articulation, 0);
247
+ } else if (attachment.type === 'grace') {
248
+ applyGraceNoteGroup(note, clef, attachment);
204
249
  }
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Grace notes stem up unless the owner was built stem-down (auto stems that
255
+ * flip later in `Beam.generateBeams` are not followed); two or more are
256
+ * beamed together, with the acciaccatura slash on the first stem only.
257
+ */
258
+ function applyGraceNoteGroup(
259
+ note: StaveNote,
260
+ clef: Clef,
261
+ attachment: GraceNoteAttachment
262
+ ) {
263
+ if (attachment.notes.length === 0) {
264
+ return;
265
+ }
266
+
267
+ const stemDirection =
268
+ note.getStemDirection() === Stem.DOWN ? Stem.DOWN : Stem.UP;
269
+ const graceNotes = attachment.notes.map((graceNote, index) => {
270
+ const vfGraceNote = new VFGraceNote({
271
+ clef,
272
+ keys: [pitchToVFKey(graceNote.pitch)],
273
+ duration: durationToVF(graceNote.duration),
274
+ slash: index === 0 && attachment.slash === true,
275
+ stemDirection,
276
+ });
277
+ decorateStaveNote(vfGraceNote, [graceNote.pitch], graceNote.duration);
278
+ return vfGraceNote;
279
+ });
280
+ const group = new GraceNoteGroup(graceNotes);
205
281
 
206
- note.addModifier(articulation, 0);
282
+ if (graceNotes.length > 1) {
283
+ group.beamNotes();
207
284
  }
285
+
286
+ note.addModifier(group, 0);
287
+ }
288
+
289
+ function decorateStaveNote(
290
+ note: StaveNote,
291
+ pitches: readonly Pitch[],
292
+ duration: DurationValue
293
+ ) {
294
+ addPitchAccidentals(note, pitches);
295
+ applyGhostParentheses(note, pitches);
296
+ applyDots(note, duration.dots);
208
297
  }
209
298
 
210
299
  export function indexAttachmentsByOwner(
@@ -279,10 +368,9 @@ export function voiceItemToStaveNote(
279
368
  duration: durationToVF(item.duration),
280
369
  stemDirection: toVFStemDirection(item.stemDirection),
281
370
  });
282
- addPitchAccidentals(note, [item.pitch]);
283
- applyGhostParentheses(note, [item.pitch]);
284
- applyArticulations(note, attachments);
285
- applyDots(note, item.duration.dots);
371
+ decorateStaveNote(note, [item.pitch], item.duration);
372
+ applyPitchAccent(note, [item.pitch], attachments);
373
+ applyNoteModifiers(note, clef, attachments);
286
374
  return note;
287
375
  }
288
376
 
@@ -292,22 +380,29 @@ export function voiceItemToStaveNote(
292
380
  duration: durationToVF(item.duration),
293
381
  stemDirection: toVFStemDirection(item.stemDirection),
294
382
  });
295
- addPitchAccidentals(note, item.pitches);
296
- applyGhostParentheses(note, item.pitches);
297
- applyArticulations(note, attachments);
298
- applyDots(note, item.duration.dots);
383
+ decorateStaveNote(note, item.pitches, item.duration);
384
+ applyPitchAccent(note, item.pitches, attachments);
385
+ applyNoteModifiers(note, clef, attachments);
299
386
  return note;
300
387
  }
301
388
 
302
389
  /**
303
- * Translates beam group fractions into the VexFlow representation.
390
+ * Beam groups for a meter: its explicit `beamGroups`, otherwise VexFlow's
391
+ * conventional grouping for the time signature (quarters in x/4, dotted
392
+ * quarters in 6/8, 9/8, 12/8, halves in x/2).
304
393
  */
305
394
  export function beamGroupsToVF(meter?: Meter): VFFraction[] | undefined {
306
- if (!meter?.beamGroups?.length) {
395
+ if (!meter) {
307
396
  return undefined;
308
397
  }
309
398
 
310
- return meter.beamGroups.map((group) => new VFFraction(group.num, group.den));
399
+ if (meter.beamGroups?.length) {
400
+ return meter.beamGroups.map(
401
+ (group) => new VFFraction(group.num, group.den)
402
+ );
403
+ }
404
+
405
+ return Beam.getDefaultBeamGroups(`${meter.beats}/${meter.beatUnit}`);
311
406
  }
312
407
 
313
408
  function hasExplicitStemDirection(item: VoiceItem): boolean {
@@ -85,6 +85,7 @@ export interface ScoreRendererProps {
85
85
  * @param layout Geometry of all rendered items and measures.
86
86
  */
87
87
  onItemsLayout?: (layout: ScoreItemsLayout) => void;
88
+ onReady?: () => void;
88
89
  }
89
90
 
90
91
  export interface Viewport {