Skip to content

Support chords in grace notes #436

@leleogere

Description

@leleogere

As far as I can tell, it seems that grace notes are simply notes with a zero duration, which does work for simple cases like a single grace note, or a succession of single grace notes. However, grace notes can contain chords, such as in the ASAP score Liszt/Concert_Etude_S145/2:
Grace chords

In that case, I've observed two behaviours:

  • 1, 3, 4: Partitura parses the grace notes correctly, however there is no way to tell if the grace notes are forming a chord, or were simply two successive grace notes.
  • 2: Partitura fails to parse correctly the grace notes. It links the two grace notes from the second chord (A4-C#5) to the correct main note, and links the two grace notes from the first chord (A4-D5) to the next F# (probably due to some conflicting behaviour between chords and grace note processing):
Code
from pathlib import Path

import partitura as pt
import partitura.score

path = Path("~/Documents/datasets/asap-dataset/Liszt/Concert_Etude_S145/2/xml_score.musicxml").expanduser()

score = pt.load_musicxml(path)
part = score.parts[0]

measure = part.measures[8]
for element in part.iter_all(
    cls=pt.score.Note,
    include_subclasses=True,
    start=measure.start.t,
    end=measure.end.t,
):
    if isinstance(element, pt.score.GraceNote):
        print("   ", element)
    else:
        print(">>>", element)
>>> 576--588 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=C#6
    576--576 GraceNote id=None voice=1 staff=1 type=eighth pitch=F#5 main_note=576--588 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=C#6
    576--576 GraceNote id=None voice=1 staff=1 type=eighth pitch=A5 main_note=576--588 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=C#6
>>> 588--600 Note id=None voice=5 staff=2 type=eighth articulations=(staccato) pitch=A5
    588--588 GraceNote id=None voice=5 staff=2 type=eighth pitch=C#5 main_note=588--600 Note id=None voice=5 staff=2 type=eighth articulations=(staccato) pitch=A5
    588--588 GraceNote id=None voice=5 staff=2 type=eighth pitch=F#5 main_note=588--600 Note id=None voice=5 staff=2 type=eighth articulations=(staccato) pitch=A5
>>> 600--612 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
    600--600 GraceNote id=None voice=1 staff=1 type=eighth pitch=A4 main_note=600--612 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
    600--600 GraceNote id=None voice=1 staff=1 type=eighth pitch=C#5 main_note=600--612 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
>>> 612--624 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
    612--612 GraceNote id=None voice=1 staff=1 type=eighth pitch=A4 main_note=612--624 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
    612--612 GraceNote id=None voice=1 staff=1 type=eighth pitch=D5 main_note=612--624 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=F#5
>>> 624--636 Note id=None voice=5 staff=2 type=eighth articulations=(staccato) pitch=A4
    624--624 GraceNote id=None voice=5 staff=2 type=eighth pitch=F#4 main_note=624--636 Note id=None voice=5 staff=2 type=eighth articulations=(staccato) pitch=A4
>>> 636--648 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=B4
    636--636 GraceNote id=None voice=1 staff=1 type=eighth pitch=D4 main_note=636--648 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=B4
    636--636 GraceNote id=None voice=1 staff=1 type=eighth pitch=F#4 main_note=636--648 Note id=None voice=1 staff=1 type=eighth articulations=(staccato) pitch=B4

Main note attribution bug

To summarize, there is two problems with how Partitura handles grace chords:

  • There is no way to tell apart two successive grace notes from two simultaneous grace notes in a chord.
    • This is probably not trivial to solve with the current implementation. It would likely be needed to rethink how the Partitura schema works, by defining a Chord object, containing Notes. This would be quite a big change, and I'm not sure that we want to do this. There might be better ways of dealing with that, feel free to propose if you have any idea.
  • Successive grace chords seems to result in a bug in the main note attribution, resulting in some grace notes belonging to the wrong main note.
    • This is why I also added the label "bug" to this issue. I could separate them into two issues, but as they are closely linked to the same underlying problem (support of grace chords), I felt like it might be better to let them together. Let me know if you would rather have two issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions