Sequence Track Name MIDI messages wrongly null-terminated
Create a one-measure file with an instrument named Classical Guitar.
Insert a note.
Export to midi.
Inspect the MIDI file -- the Sequence Track Name message is null-terminated:
In python:
>>> binascii.unhexlify('ff0311436c6173736963616c204775697461720000')
b'\xff\x03\x11Classical Guitar\x00\x00'
Impact:
A MIDI importer, such as music21, might ingest the empty byte into the part name and then generate malformed musicxml when trying to write 'Classical Guitar\x00' as the part-name.
Another user verified this on a forum post on this topic:
https://musescore.org/en/node/310149
I confirm seeing the same here with MuseScore 3.5.1.13199/Windows 7.
That item in MIDI is not to be null-terminated (there is an explicit length parameter in the meta-event encoding.)
Attachment | Size |
---|---|
emptyByte.mid | 118 bytes |
emptyByte.mscz | 3.15 KB |
Comments
Raising frequency because it happens every time MIDI is exported, and we are starting to get bug reports at music21 over it.
That is Reproducibility. Frequency is the number of people reporting it and you're all but one
Well, and that other user in the forum post
I get exactly the same problem when trying to handle multiple midi files in a project using music21.
https://github.com/musescore/MuseScore/pull/7003
.
"PR Created"? What happened to the title of this issue?
No idea what went wrong here
(actually I do, @pereverzev_v just fixed it)
This problem resurfaced in the current stable and nightly build.
If I export a midi score from MuseScore and run this simple Python script:
It outputs something like
['Piano\x00', 'Strings\x00']
instead of['Piano', 'Strings']
, happens only if the MIDI file was exported from MuseScore.See https://github.com/musescore/MuseScore/pull/10374 for the master branch
Fixed in branch master, commit f74adf60c1
_Fix #310158: Don't null terminate MIDI text meta events
Port of PR #7003 to the master branch_
Automatically closed -- issue fixed for 2 weeks with no activity.
No more fixes for 3.x
It is part of https://github.com/musescore/MuseScore/pull/9000 though, so you could use the artifacts of that