Fixing errors for encoding voice data.

pull/32/head
Holger Wirtz 5 years ago
parent 02644ef03b
commit 9b9aa4540a
  1. 16
      MicroDexed.ino
  2. 13
      dexed.cpp
  3. 4
      dexed_sd.cpp

@ -967,18 +967,20 @@ void handleSystemExclusive(byte * sysex, uint len)
// load sysex-data into voice memory
MicroDexed[instance_id]->loadVoiceParameters(&sysex[6]);
#ifdef DEBUG
show_patch(instance_id);
#endif
// show voice name
for (uint8_t i = 0; i < 10; i++)
{
if (sysex[151 + i] > 126) // filter characters
sysex[151 + i] = 32;
}
strncpy(g_voice_name[instance_id], (char*)&sysex[151], VOICE_NAME_LEN - 1);
LCDML.OTHER_updateFunc();
LCDML.loop_menu();
/*
// manipulate UI names and numbers
strncpy(voice_name[instance_id], (char *)&sysex[151], sizeof(voice_name[instance_id]) - 1);
Serial.print(F("Got voice ["));
Serial.print(voice_name[instance_id]);
Serial.println(F("]."));*/
}
#ifdef DEBUG
else

@ -564,11 +564,11 @@ bool Dexed::encodeVoice(uint8_t* encoded_data)
// DEXED_OP_SCL_LEFT_DEPTH, // 9
// DEXED_OP_SCL_RGHT_DEPTH, // 10
memcpy(&encoded_data[op * 17], &data[op * 21], 11);
encoded_data[(op * 17) + 11] = ((*(p_data + DEXED_OP_SCL_RGHT_CURVE + (op * 21)) & 0x0c) << 2) & (*(p_data + DEXED_OP_SCL_LEFT_CURVE + (op * 21)) & 0x03);
encoded_data[(op * 17) + 12] = ((*(p_data + DEXED_OP_OSC_DETUNE + (op * 21)) & 0x78) << 3) & (*(p_data + DEXED_OP_OSC_RATE_SCALE + (op * 21)) & 0x07);
encoded_data[(op * 17) + 13] = ((*(p_data + DEXED_OP_KEY_VEL_SENS + (op * 21)) & 0x1c) << 2) & (*(p_data + DEXED_OP_AMP_MOD_SENS + (op * 21)) & 0x03);
encoded_data[(op * 17) + 11] = ((*(p_data + DEXED_OP_SCL_RGHT_CURVE + (op * 21)) & 0x0c) << 2) | (*(p_data + DEXED_OP_SCL_LEFT_CURVE + (op * 21)) & 0x03);
encoded_data[(op * 17) + 12] = ((*(p_data + DEXED_OP_OSC_DETUNE + (op * 21)) & 0x0f) << 3) | (*(p_data + DEXED_OP_OSC_RATE_SCALE + (op * 21)) & 0x07);
encoded_data[(op * 17) + 13] = ((*(p_data + DEXED_OP_KEY_VEL_SENS + (op * 21)) & 0x07) << 2) | (*(p_data + DEXED_OP_AMP_MOD_SENS + (op * 21)) & 0x03);
encoded_data[(op * 17) + 14] = *(p_data + DEXED_OP_OUTPUT_LEV + (op * 21));
encoded_data[(op * 17) + 15] = ((*(p_data + DEXED_OP_FREQ_COARSE + (op * 21)) & 0x3e) << 1) & (*(p_data + DEXED_OP_OSC_MODE + (op * 21)) & 0x01);
encoded_data[(op * 17) + 15] = ((*(p_data + DEXED_OP_FREQ_COARSE + (op * 21)) & 0x1f) << 1) | (*(p_data + DEXED_OP_OSC_MODE + (op * 21)) & 0x01);
encoded_data[(op * 17) + 16] = *(p_data + DEXED_OP_FREQ_FINE + (op * 21));
}
// DEXED_PITCH_EG_R1, // 0
@ -581,14 +581,15 @@ bool Dexed::encodeVoice(uint8_t* encoded_data)
// DEXED_PITCH_EG_L4, // 7
memcpy(&encoded_data[102], &data[DEXED_VOICE_OFFSET], 8);
encoded_data[110] = (*(p_data + DEXED_VOICE_OFFSET + DEXED_ALGORITHM) & 0x1f);
encoded_data[111] = ((*(p_data + DEXED_VOICE_OFFSET + DEXED_OSC_KEY_SYNC) & 0x08) << 3) & (*(p_data + DEXED_VOICE_OFFSET + DEXED_FEEDBACK) & 0x07);
encoded_data[111] = (((*(p_data + DEXED_VOICE_OFFSET + DEXED_OSC_KEY_SYNC) & 0x01) << 3) | ((*(p_data + DEXED_VOICE_OFFSET + DEXED_FEEDBACK)) & 0x07));
// DEXED_LFO_SPEED, // 11
// DEXED_LFO_DELAY, // 12
// DEXED_LFO_PITCH_MOD_DEP, // 13
// DEXED_LFO_AMP_MOD_DEP, // 14
memcpy(&encoded_data[112], &data[DEXED_VOICE_OFFSET + DEXED_LFO_SPEED], 4);
encoded_data[116] = ((*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_SENS) & 0x30) << 4) & ((*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_WAVE) & 0x0e) << 1) & (*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_SYNC) & 0x01);
encoded_data[116] = (((*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_SENS) & 0x07) << 4) | (((*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_WAVE)) & 0x07) << 1) | ((*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_SYNC)) & 0x01));
encoded_data[117] = *(p_data + DEXED_VOICE_OFFSET + DEXED_TRANSPOSE);
memset(&encoded_data[118], 0, 10);
memcpy(&encoded_data[118], &data[DEXED_VOICE_OFFSET + DEXED_NAME], 10);
return (true);

@ -229,7 +229,7 @@ bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data)
int32_t bulk_checksum_calc = 0;
sysex.seek(0);
if (sysex.size() != 4104) // check sysex size
{
#ifdef DEBUG
@ -268,7 +268,7 @@ bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data)
return (false);
}
sysex.seek(6 + voice_number * 128);
sysex.seek(6 + (voice_number * 128));
sysex.write(data, 128);
// checksum calculation

Loading…
Cancel
Save