mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Midi fixes for reading/writing variable-length sysexes.
This commit is contained in:
parent
ea0260cfc7
commit
e74219b736
2 changed files with 19 additions and 3 deletions
|
|
@ -403,6 +403,15 @@ void MidiFile::writeTrack (OutputStream& mainOut, const int trackNum)
|
|||
++data;
|
||||
--dataSize;
|
||||
}
|
||||
else if ((statusByte & 0xf0) == 0xf0) // Write sysex message with length bytes.
|
||||
{
|
||||
out.writeByte ((char) statusByte);
|
||||
|
||||
++data;
|
||||
--dataSize;
|
||||
|
||||
MidiFileHelpers::writeVariableLengthInt (out, dataSize);
|
||||
}
|
||||
|
||||
out.write (data, dataSize);
|
||||
lastStatusByte = statusByte;
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin
|
|||
{
|
||||
const uint8* d = src;
|
||||
bool haveReadAllLengthBytes = false;
|
||||
int numVariableLengthSysexBytes = 0;
|
||||
|
||||
while (d < src + sz)
|
||||
{
|
||||
|
|
@ -230,19 +231,25 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin
|
|||
if (haveReadAllLengthBytes) // if we see a 0x80 bit set after the initial data length
|
||||
break; // bytes, assume it's the end of the sysex
|
||||
|
||||
++numVariableLengthSysexBytes;
|
||||
++d;
|
||||
continue;
|
||||
}
|
||||
|
||||
haveReadAllLengthBytes = true;
|
||||
if (! haveReadAllLengthBytes)
|
||||
{
|
||||
haveReadAllLengthBytes = true;
|
||||
++numVariableLengthSysexBytes;
|
||||
}
|
||||
|
||||
++d;
|
||||
}
|
||||
|
||||
size = 1 + (int) (d - src);
|
||||
|
||||
data = new uint8 [size];
|
||||
data = new uint8 [size - numVariableLengthSysexBytes];
|
||||
*data = (uint8) byte;
|
||||
memcpy (data + 1, src, size - 1);
|
||||
memcpy (data + 1, src + numVariableLengthSysexBytes, size - numVariableLengthSysexBytes - 1);
|
||||
}
|
||||
else if (byte == 0xff)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue