From a907a5f6260c4ca7ebd335d7807e2f3b5eb8a5a9 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 10 Dec 2025 23:12:26 +0100 Subject: [PATCH] added support to display fingerings as annotations --- src/parsing/musicxml/annotation.ts | 9 +++++++++ src/parsing/musicxml/note.ts | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/parsing/musicxml/annotation.ts b/src/parsing/musicxml/annotation.ts index a9476cd5a..e2345e062 100644 --- a/src/parsing/musicxml/annotation.ts +++ b/src/parsing/musicxml/annotation.ts @@ -21,6 +21,15 @@ export class Annotation { return new Annotation(config, log, machine.getText(), 'center', 'bottom'); } + static fromFingering(config: Config, log: Logger, musicXML: { fingering: musicxml.Fingering }): Annotation | undefined { + const number = musicXML.fingering.getNumber(); + if (number === null || number === undefined) { + return undefined + } + + return new Annotation(config, log, `${number}`, 'center', 'top') + } + parse(): data.Annotation { return { type: 'annotation', diff --git a/src/parsing/musicxml/note.ts b/src/parsing/musicxml/note.ts index 49a0dca31..4da9fc19d 100644 --- a/src/parsing/musicxml/note.ts +++ b/src/parsing/musicxml/note.ts @@ -73,7 +73,18 @@ export class Note { } const stem = conversions.fromStemToStemDirection(musicXML.note.getStem()); - const annotations = musicXML.note.getLyrics().map((lyric) => Annotation.fromLyric(config, log, { lyric })); + const lyricAnnotations = musicXML.note.getLyrics().map((lyric) => Annotation.fromLyric(config, log, { lyric })); + const fingeringAnnotations = musicXML.note + .getNotations() + .flatMap(n => n.getTechnicals()) + .flatMap(t => t.getFingerings()) + .map(fingering => Annotation.fromFingering(config, log, { fingering })) + .filter(a => a !== undefined) + + const annotations = [ + ...lyricAnnotations, + ...fingeringAnnotations + ]; const code = conversions.fromAccidentalTypeToAccidentalCode(musicXML.note.getAccidentalType()) ??