|
|
|
@ -90,6 +90,11 @@ public: |
|
|
|
|
return rc; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads sysex stream |
|
|
|
|
* Returns 0 if it was parsed sucessfully |
|
|
|
|
* Returns -1 if it cannot open the stream |
|
|
|
|
*/ |
|
|
|
|
int load(InputStream &fis) { |
|
|
|
|
uint8 buffer[65535]; |
|
|
|
|
int sz = fis.read(buffer, 65535); |
|
|
|
@ -98,8 +103,17 @@ public: |
|
|
|
|
return load(buffer, sz); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads sysex buffer |
|
|
|
|
* Returns 0 if it was parsed sucessfully |
|
|
|
|
* Returns 1 if sysex checksum didn't match |
|
|
|
|
* Returns 2 if no sysex data found, probably random data |
|
|
|
|
*/ |
|
|
|
|
int load(const uint8_t *stream, int size) { |
|
|
|
|
const uint8 voiceHeaderBroken[] = { 0xF0, 0x43, 0x00, 0x00, 0x20, 0x00 }; |
|
|
|
|
// I've added a stupid bug that saved the wrong sysex data for dx7 sysex (0.9.1)
|
|
|
|
|
// This is there to support this version. One day we will be able to remove this. :(
|
|
|
|
|
|
|
|
|
|
uint8 voiceHeader[] = SYSEX_HEADER; |
|
|
|
|
uint8 tmp[65535]; |
|
|
|
|
uint8 *pos = tmp; |
|
|
|
@ -113,16 +127,14 @@ public: |
|
|
|
|
while(size >= 4104) { |
|
|
|
|
// random data
|
|
|
|
|
if ( pos[0] != 0xF0 ) { |
|
|
|
|
if ( status != 0 ) |
|
|
|
|
if ( status != 3 ) |
|
|
|
|
return status; |
|
|
|
|
memcpy(voiceData, pos+6, 4096); |
|
|
|
|
TRACE("SYSEX Header not found, loading random data"); |
|
|
|
|
return 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pos[3] = 0; |
|
|
|
|
if ( memcmp(pos, voiceHeader, 6) == 0 || memcmp(pos, voiceHeaderBroken, 6) == 0) { |
|
|
|
|
TRACE("SYSEX voice header found at %d", pos); |
|
|
|
|
memcpy(voiceData, pos, SYSEX_SIZE); |
|
|
|
|
if ( sysexChecksum(voiceData + 6, 4096) == pos[4102] ) |
|
|
|
|
status = 0; |
|
|
|
@ -143,6 +155,12 @@ public: |
|
|
|
|
stream += i; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// nothing good has been found, map it then to random data
|
|
|
|
|
if ( status > 1 ) { |
|
|
|
|
memcpy(voiceData, pos+6, 4096); |
|
|
|
|
return 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return status; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -168,7 +186,7 @@ public: |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// To avoid to erase the performance data, we skip the sysex stream until
|
|
|
|
|
// we see the header 0xF0, 0x43, 0x00, 0x00, 0x20, 0x00
|
|
|
|
|
// we see the header 0xF0, 0x43, 0x00, 0x09, 0x20, 0x00
|
|
|
|
|
|
|
|
|
|
int pos = 0; |
|
|
|
|
bool found = 0; |
|
|
|
|