Writing sysex messages issue

In MidiFile::writeTrack() writeVariableLengthInt() adds the length of the message right after the sysex type:

            else if ((statusByte & 0xf0) == 0xf0)  // Write sysex message with length bytes.
            {
                out.writeByte ((char) statusByte);

                ++data;
                --dataSize;

                MidiFileHelpers::writeVariableLengthInt (out, dataSize);
            }

So for example a regular tempo message (FF 51 03 tt tt tt) turns into FF 5 51 03 tt tt tt

Are you really looking for a sysex message ?
The tempo message shown in your post is a standard MIDI File event, not a MIDI system exclusive message.
Did you use MidiMessage::tempoMetaEvent to built your event ?

Robert

I stand corrected, it’s really not a sysex event, and I do use MidiMessage::tempoMetaEvent()
Jules added this code like 10 days ago, and now meta events get written not as they should be.

Doh! Sorry, looks like a typo. I think that line should read:

else if (statusByte == 0xf0) // Write sysex message with length bytes.

Thanks for letting me know!

That was my typo, sorry!

http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8078&hilit=Joerg&start=15

Thanks a lot for your correction of writeTrack, Joerg. I was going crazy as to why some of my tracks were becoming unreadable after save. I would never have put Jules’ code in doubt… :wink: