Sequence Track Name MIDI messages wrongly null-terminated

• Sep 7, 2020 - 22:20
Reported version
3.5
Type
Functional
Frequency
Few
Severity
S4 - Minor
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

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

Frequency Few Many

Raising frequency because it happens every time MIDI is exported, and we are starting to get bug reports at music21 over it.

Reported version 3.5 3.6

This problem resurfaced in the current stable and nightly build.
If I export a midi score from MuseScore and run this simple Python script:

import os,sys
import muspy

midi = muspy.read_midi('midi_file.mid')
print([track.name for track in midi.tracks])

It outputs something like ['Piano\x00', 'Strings\x00'] instead of ['Piano', 'Strings'], happens only if the MIDI file was exported from MuseScore.

Fix version
4.0.0