Skip to content

Unpitched grace note in a voice exports a malformed musicxml file #1732

@ggsimao

Description

@ggsimao

music21 version

9.1.0

Problem summary
If there is an unpitched grace note in a measure with multiple voices, the exported musicxml is malformed, with the error being that the 'voice' element is not defined.

Steps to reproduce

from music21 import note, duration, stream
grace = note.Unpitched(duration=duration.GraceDuration())
v1 = stream.Voice(grace)
v2 = stream.Voice(note.Note())
stream.Measure([v1, v2]).show("musicxml")

Expected vs. actual behavior
The <voice> element should be after the <unpitched> element, but it comes before.

More information
I changed the line
helpers.insertBeforeElements(mxNote, mxUnpitched, tagList=['duration', 'type'])
in the unpitchedToXml method in the m21ToXml.py file to have the element 'voice' in the variable tagList and the output was well-formed. Not sure if it can cause a problem elsewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions