Skip to content

midi export deletes notes under specific circumstances (chords, ties, voices) #1843

@OttavioCresos

Description

@OttavioCresos

9.9.1

Mac OS Sequoia 15.6.1

Problem summary

Under specific circumstances (e.g. ties + chords, 2 piano voices) parsing a musicxml file with the converter, and then immediately writing a MIDI file from it, will result in notes missing and moved/overlapping.

We suspect that this could be related to the stripTies method.

To illustrate and reproduce the issue, I created two minimal examples of a single bar. With several bars, more related issues appear, but for now:
example_doubleVoice_2notes.musicxml:

Image

example_doubleVoice_3notes.musicxml

Image

I'm also providing the resulting MIDI files.

Steps to reproduce

import music21
converter = music21.converter
score = converter.parse('example_doubleVoice_2notes.musicxml')
midi_path = score.write('midi', fp='example_doubleVoice_2notes.midi')

Expected vs. actual behaviour

for the first example, this what the output should be (midi exported from MuseScore) as seen in sonic Visualiser:

Image

this is the music21 output, with 4 midi events instead of 2:

Image

for the second example, this what the output should be (midi exported from MuseScore) as seen in sonic Visualiser:

Image

this is the music21 output, with 4 midi events instead of 3, note that the second (top) voice has been deleted:

Image

I'd be happy to produce more examples if this can help to fix this issue, thank you so much!

issue_report_example_files.zip

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