|
|
|
@ -1584,8 +1584,10 @@ void handleProgramChange(byte inChannel, byte inProgram) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
void handleSystemExclusive(byte* sysex, unsigned int len) |
|
|
|
|
{ |
|
|
|
|
int16_t sysex_return; |
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
{ |
|
|
|
|
if (!checkMidiChannel((sysex[2] & 0x0f) + 1 , instance_id)) |
|
|
|
@ -1624,61 +1626,97 @@ void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Check for SYSEX end byte
|
|
|
|
|
if (sysex[len - 1] != 0xf7) |
|
|
|
|
{ |
|
|
|
|
sysex_return = MicroDexed[instance_id]->handleSystemExclusive(sysex, len); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: SysEx end status byte not detected.")); |
|
|
|
|
Serial.print(F("SYSEX handler return value:")); |
|
|
|
|
Serial.print(sysex_return, DEC); |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (sysex[1] != 0x43) // check for Yamaha sysex
|
|
|
|
|
switch (sysex_return) |
|
|
|
|
{ |
|
|
|
|
case -1: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: SysEx end status byte not detected.")); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case -2: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: SysEx vendor not Yamaha.")); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case -3: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Substatus: [")); |
|
|
|
|
Serial.print((sysex[2] & 0x70) >> 4); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
Serial.println(F("E: Unknown SysEx parameter change.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// parse parameter change
|
|
|
|
|
if (len == 7) |
|
|
|
|
{ |
|
|
|
|
if (((sysex[3] & 0x7c) >> 2) != 0 && ((sysex[3] & 0x7c) >> 2) != 2) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
case -4: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Not a SysEx parameter or function parameter change.")); |
|
|
|
|
Serial.println(F("E: Unknown SysEx voice or function.")); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sysex[4] &= 0x7f; |
|
|
|
|
sysex[5] &= 0x7f; |
|
|
|
|
|
|
|
|
|
if ((sysex[3] & 0x7c) >> 2 == 0) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
case -5: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SysEx Voice parameter:")); |
|
|
|
|
Serial.print("Parameter #"); |
|
|
|
|
Serial.print(sysex[4] + ((sysex[3] & 0x03) * 128), DEC); |
|
|
|
|
Serial.print(" Value: "); |
|
|
|
|
Serial.println(sysex[5], DEC); |
|
|
|
|
Serial.println(F("E: Not a SysEx voice bulk upload.")); |
|
|
|
|
#endif |
|
|
|
|
MicroDexed[instance_id]->setVoiceDataElement(sysex[4] + ((sysex[3] & 0x03) * 128), sysex[5]); |
|
|
|
|
} |
|
|
|
|
else if ((sysex[3] & 0x7c) >> 2 == 2) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
case -6: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Wrong length for SysEx voice bulk upload (not 155).")); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case -7: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Checksum error for one voice.")); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case -8: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Not a SysEx bank bulk upload.")); |
|
|
|
|
#endif |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("Error (TYPE) ")); |
|
|
|
|
delay(MESSAGE_WAIT_TIME); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
break; |
|
|
|
|
case -9: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Wrong length for SysEx bank bulk upload (not 4096).")); |
|
|
|
|
#endif |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("Error (SIZE) ")); |
|
|
|
|
delay(MESSAGE_WAIT_TIME); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
break; |
|
|
|
|
case -10: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SysEx Function parameter:")); |
|
|
|
|
Serial.print("Parameter #"); |
|
|
|
|
Serial.println(F("E: Checksum error for bank.")); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case -11: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Unknown SysEx message.")); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case 64: |
|
|
|
|
case 65: |
|
|
|
|
case 66: |
|
|
|
|
case 67: |
|
|
|
|
case 68: |
|
|
|
|
case 69: |
|
|
|
|
case 70: |
|
|
|
|
case 71: |
|
|
|
|
case 72: |
|
|
|
|
case 73: |
|
|
|
|
case 74: |
|
|
|
|
case 75: |
|
|
|
|
case 76: |
|
|
|
|
case 77: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SysEx Function parameter change : ")); |
|
|
|
|
Serial.print(F("Parameter #")); |
|
|
|
|
Serial.print(sysex[4], DEC); |
|
|
|
|
Serial.print(" Value: "); |
|
|
|
|
Serial.print(F(" Value : ")); |
|
|
|
|
Serial.println(sysex[5], DEC); |
|
|
|
|
#endif |
|
|
|
|
switch (sysex[4]) |
|
|
|
@ -1800,64 +1838,9 @@ void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
LCDML.loop_menu(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
MicroDexed[instance_id]->setVoiceDataElement(sysex[4], sysex[5]); // set function parameter
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
MicroDexed[instance_id]->ControllersRefresh(); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.println(F("E: Unknown SysEx voice or function.")); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
else if (len == 163) |
|
|
|
|
{ |
|
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
int8_t bulk_checksum = sysex[161]; |
|
|
|
|
|
|
|
|
|
// 1 Voice bulk upload
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("One Voice bulk upload")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if ((sysex[3] & 0x7f) != 0) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Not a SysEx voice bulk upload.")); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (((sysex[4] << 7) | sysex[5]) != 0x9b) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Wrong length for SysEx voice bulk upload (not 155).")); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// checksum calculation
|
|
|
|
|
for (uint8_t i = 0; i < 155 ; i++) |
|
|
|
|
{ |
|
|
|
|
bulk_checksum_calc -= sysex[i + 6]; |
|
|
|
|
} |
|
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
|
|
|
|
|
|
if (bulk_checksum_calc != bulk_checksum) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("E: Checksum error for one voice [0x")); |
|
|
|
|
Serial.print(bulk_checksum, HEX); |
|
|
|
|
Serial.print(F("/0x")); |
|
|
|
|
Serial.print(bulk_checksum_calc, HEX); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
#endif |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case 100: |
|
|
|
|
// fix voice name
|
|
|
|
|
for (uint8_t i = 0; i < 10; i++) |
|
|
|
|
{ |
|
|
|
@ -1869,10 +1852,9 @@ void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
MicroDexed[instance_id]->loadVoiceParameters(&sysex[6]); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("One Voice bulk upload")); |
|
|
|
|
show_patch(instance_id); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// show voice name
|
|
|
|
|
strncpy(g_voice_name[instance_id], (char*)&sysex[151], VOICE_NAME_LEN - 1); |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) |
|
|
|
@ -1880,74 +1862,13 @@ void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
LCDML.OTHER_updateFunc(); |
|
|
|
|
LCDML.loop_menu(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (len == 4104) |
|
|
|
|
{ |
|
|
|
|
break; |
|
|
|
|
case 200: |
|
|
|
|
if (strlen(receive_bank_filename) > 0 && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sysex_receive_bank)) |
|
|
|
|
{ |
|
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
int8_t bulk_checksum = sysex[4102]; |
|
|
|
|
|
|
|
|
|
// 1 Bank bulk upload
|
|
|
|
|
if ((sysex[3] & 0x7f) != 9) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Not a SysEx bank bulk upload.")); |
|
|
|
|
#endif |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("Error (TYPE) ")); |
|
|
|
|
delay(MESSAGE_WAIT_TIME); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Bank bulk upload.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (((sysex[4] << 7) | sysex[5]) != 0x1000) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("E: Wrong length for SysEx bank bulk upload (not 4096).")); |
|
|
|
|
#endif |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("Error (SIZE) ")); |
|
|
|
|
delay(MESSAGE_WAIT_TIME); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Bank type ok")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// checksum calculation
|
|
|
|
|
for (uint16_t i = 0; i < 4096 ; i++) |
|
|
|
|
{ |
|
|
|
|
bulk_checksum_calc -= sysex[i + 6]; |
|
|
|
|
} |
|
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
|
|
|
|
|
|
if (bulk_checksum_calc != bulk_checksum) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("E: Checksum error for bank [0x")); |
|
|
|
|
Serial.print(bulk_checksum, HEX); |
|
|
|
|
Serial.print(F("/0x")); |
|
|
|
|
Serial.print(bulk_checksum_calc, HEX); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
#endif |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("Error (CHECKSUM)")); |
|
|
|
|
delay(MESSAGE_WAIT_TIME); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Bank checksum ok")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (save_sd_bank(receive_bank_filename, sysex)) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -1976,13 +1897,28 @@ void handleSystemExclusive(byte * sysex, uint len) |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
Serial.println(F("E: Not in MIDI receive bank mode.")); |
|
|
|
|
Serial.println(F("E : Not in MIDI receive bank mode.")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 300: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
Serial.println(F("E: SysEx parameter length wrong.")); |
|
|
|
|
Serial.println(F("SysEx Voice parameter:")); |
|
|
|
|
Serial.print(F("Parameter #")); |
|
|
|
|
Serial.print(sysex[4] + ((sysex[3] & 0x03) * 128), DEC); |
|
|
|
|
Serial.print(F(" Value: ")); |
|
|
|
|
Serial.println(sysex[5], DEC); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SysEx Voice parameter change : ")); |
|
|
|
|
Serial.print(F("Parameter #")); |
|
|
|
|
Serial.print(sysex_return); |
|
|
|
|
Serial.print(F(" Value : ")); |
|
|
|
|
Serial.println(sysex[5], DEC); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|