|
|
@ -26,10 +26,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t sysexChecksum(const char *sysex) { |
|
|
|
uint8_t sysexChecksum(const char *sysex) { |
|
|
|
uint8_t sum = 0; |
|
|
|
int sum = 0; |
|
|
|
for (int i=0; i<4096; i++) |
|
|
|
int i; |
|
|
|
sum = (sum + sysex[i]) % (1 << 8); |
|
|
|
|
|
|
|
return ((1 << 8) - sum); |
|
|
|
for (i = 0; i < 4096; sum -= sysex[i++]); |
|
|
|
|
|
|
|
return sum & 0x7F; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void extractProgramNames(const char *block, StringArray &dest) { |
|
|
|
void extractProgramNames(const char *block, StringArray &dest) { |
|
|
@ -127,14 +128,18 @@ void packProgram(uint8_t *dest, uint8_t *src, int idx, String name) { |
|
|
|
* This function normalize data that comes from corrupted sysex. |
|
|
|
* This function normalize data that comes from corrupted sysex. |
|
|
|
* It used to avoid engine crashing upon extrem values |
|
|
|
* It used to avoid engine crashing upon extrem values |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
char normparm(char value, char max) { |
|
|
|
char normparm(char value, char max, int id) { |
|
|
|
if ( value <= max ) |
|
|
|
if ( value <= max && value >= 0 ) |
|
|
|
return value; |
|
|
|
return value; |
|
|
|
|
|
|
|
|
|
|
|
// if this is beyond the max, we expect a 0-255 range, normalize this
|
|
|
|
// if this is beyond the max, we expect a 0-255 range, normalize this
|
|
|
|
// to the expected return value; and this value as a random data.
|
|
|
|
// to the expected return value; and this value as a random data.
|
|
|
|
|
|
|
|
|
|
|
|
return ((float)value)/255 * max; |
|
|
|
value = abs(value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char v = ((float)value)/255 * max; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DexedAudioProcessor::unpackProgram(int idx) { |
|
|
|
void DexedAudioProcessor::unpackProgram(int idx) { |
|
|
@ -144,7 +149,7 @@ void DexedAudioProcessor::unpackProgram(int idx) { |
|
|
|
// eg rate and level, brk pt, depth, scaling
|
|
|
|
// eg rate and level, brk pt, depth, scaling
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<11; i++) { |
|
|
|
for(int i=0; i<11; i++) { |
|
|
|
data[op * 21 + i] = normparm(bulk[op * 17 + i], 99); |
|
|
|
data[op * 21 + i] = normparm(bulk[op * 17 + i], 99, i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
memcpy(data + op * 21, bulk + op * 17, 11); |
|
|
|
memcpy(data + op * 21, bulk + op * 17, 11); |
|
|
@ -165,9 +170,9 @@ void DexedAudioProcessor::unpackProgram(int idx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<8; i++) { |
|
|
|
for (int i=0; i<8; i++) { |
|
|
|
data[126+i] = normparm(bulk[102+i], 99); |
|
|
|
data[126+i] = normparm(bulk[102+i], 99, 126+i); |
|
|
|
} |
|
|
|
} |
|
|
|
data[134] = normparm(bulk[110], 31); |
|
|
|
data[134] = normparm(bulk[110], 31, 134); |
|
|
|
|
|
|
|
|
|
|
|
char oks_fb = bulk[111]; |
|
|
|
char oks_fb = bulk[111]; |
|
|
|
data[135] = oks_fb & 7; |
|
|
|
data[135] = oks_fb & 7; |
|
|
@ -193,14 +198,13 @@ int DexedAudioProcessor::importSysex(const char *imported) { |
|
|
|
extractProgramNames(sysex, programNames); |
|
|
|
extractProgramNames(sysex, programNames); |
|
|
|
|
|
|
|
|
|
|
|
if ( checksum != imported[4102] ) { |
|
|
|
if ( checksum != imported[4102] ) { |
|
|
|
TRACE("sysex import checksum doesnt match"); |
|
|
|
TRACE("sysex import checksum doesnt match %d != %d", checksum, imported[4102]); |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { |
|
|
|
void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { |
|
|
|
memcpy(data, rawdata, 160); |
|
|
|
memcpy(data, rawdata, 160); |
|
|
|
triggerAsyncUpdate(); |
|
|
|
triggerAsyncUpdate(); |
|
|
@ -208,6 +212,7 @@ void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { |
|
|
|
|
|
|
|
|
|
|
|
void DexedAudioProcessor::loadBuiltin(int idx) { |
|
|
|
void DexedAudioProcessor::loadBuiltin(int idx) { |
|
|
|
char syx_data[4104]; |
|
|
|
char syx_data[4104]; |
|
|
|
|
|
|
|
memset(&syx_data, 0, 4104); |
|
|
|
cartManager.getSysex(idx, (char *) &syx_data); |
|
|
|
cartManager.getSysex(idx, (char *) &syx_data); |
|
|
|
importSysex((char *) &syx_data); |
|
|
|
importSysex((char *) &syx_data); |
|
|
|
} |
|
|
|
} |
|
|
|