Better organization of loading voice and global paramters for better SysEx handling soon.

pull/3/head
Holger Wirtz 5 years ago
parent f946ac7a81
commit 78690c345a
  1. 2
      MicroDexed.ino
  2. 107
      dexed.cpp
  3. 4
      dexed.h
  4. 2
      dexed_sysex.cpp

@ -721,7 +721,7 @@ void handleSystemExclusive(byte * sysex, uint len)
Serial.print(voice_name);
Serial.print(F("] loaded."));
dexed->loadSysexVoice(tmp_data);
dexed->loadVoiceParameters(tmp_data);
}
#ifdef DEBUG
else

@ -425,7 +425,7 @@ uint8_t Dexed::getNumNotesPlaying(void)
return (count_playing_voices);
}
bool Dexed::loadSysexVoice(uint8_t* new_data)
bool Dexed::loadVoiceParameters(uint8_t* data)
{
uint8_t* p_data = data;
uint8_t op;
@ -446,21 +446,21 @@ bool Dexed::loadSysexVoice(uint8_t* new_data)
// DEXED_OP_LEV_SCL_BRK_PT, // 8
// DEXED_OP_SCL_LEFT_DEPTH, // 9
// DEXED_OP_SCL_RGHT_DEPTH, // 10
memcpy(&data[op * 21], &new_data[op * 17], 11);
tmp = new_data[(op * 17) + 11];
memcpy(&data[op * 21], &data[op * 17], 11);
tmp = data[(op * 17) + 11];
*(p_data + DEXED_OP_SCL_LEFT_CURVE + (op * 21)) = (tmp & 0x3);
*(p_data + DEXED_OP_SCL_RGHT_CURVE + (op * 21)) = (tmp & 0x0c) >> 2;
tmp = new_data[(op * 17) + 12];
tmp = data[(op * 17) + 12];
*(p_data + DEXED_OP_OSC_DETUNE + (op * 21)) = (tmp & 0x78) >> 3;
*(p_data + DEXED_OP_OSC_RATE_SCALE + (op * 21)) = (tmp & 0x07);
tmp = new_data[(op * 17) + 13];
tmp = data[(op * 17) + 13];
*(p_data + DEXED_OP_KEY_VEL_SENS + (op * 21)) = (tmp & 0x1c) >> 2;
*(p_data + DEXED_OP_AMP_MOD_SENS + (op * 21)) = (tmp & 0x03);
*(p_data + DEXED_OP_OUTPUT_LEV + (op * 21)) = new_data[(op * 17) + 14];
tmp = new_data[(op * 17) + 15];
*(p_data + DEXED_OP_OUTPUT_LEV + (op * 21)) = data[(op * 17) + 14];
tmp = data[(op * 17) + 15];
*(p_data + DEXED_OP_FREQ_COARSE + (op * 21)) = (tmp & 0x3e) >> 1;
*(p_data + DEXED_OP_OSC_MODE + (op * 21)) = (tmp & 0x01);
*(p_data + DEXED_OP_FREQ_FINE + (op * 21)) = new_data[(op * 17) + 16];
*(p_data + DEXED_OP_FREQ_FINE + (op * 21)) = data[(op * 17) + 16];
}
// DEXED_PITCH_EG_R1, // 0
// DEXED_PITCH_EG_R2, // 1
@ -470,41 +470,42 @@ bool Dexed::loadSysexVoice(uint8_t* new_data)
// DEXED_PITCH_EG_L2, // 5
// DEXED_PITCH_EG_L3, // 6
// DEXED_PITCH_EG_L4, // 7
memcpy(&data[DEXED_VOICE_OFFSET], &new_data[102], 8);
tmp = new_data[110];
memcpy(&data[DEXED_VOICE_OFFSET], &data[102], 8);
tmp = data[110];
*(p_data + DEXED_VOICE_OFFSET + DEXED_ALGORITHM) = (tmp & 0x1f);
tmp = new_data[111];
tmp = data[111];
*(p_data + DEXED_VOICE_OFFSET + DEXED_OSC_KEY_SYNC) = (tmp & 0x08) >> 3;
*(p_data + DEXED_VOICE_OFFSET + DEXED_FEEDBACK) = (tmp & 0x07);
// DEXED_LFO_SPEED, // 11
// DEXED_LFO_DELAY, // 12
// DEXED_LFO_PITCH_MOD_DEP, // 13
// DEXED_LFO_AMP_MOD_DEP, // 14
memcpy(&data[DEXED_VOICE_OFFSET + DEXED_LFO_SPEED], &new_data[112], 4);
tmp = new_data[116];
memcpy(&data[DEXED_VOICE_OFFSET + DEXED_LFO_SPEED], &data[112], 4);
tmp = data[116];
*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_SENS) = (tmp & 0x30) >> 4;
*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_WAVE) = (tmp & 0x0e) >> 1;
*(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_SYNC) = (tmp & 0x01);
*(p_data + DEXED_VOICE_OFFSET + DEXED_TRANSPOSE) = new_data[117];
memcpy(&data[DEXED_VOICE_OFFSET + DEXED_NAME], &new_data[118], 10);
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE) = 99;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN) = 7;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE) = 99;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN) = 7;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE) = 99;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN) = 7;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE) = 99;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN) = 7;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE) = 0;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP1_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP2_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP3_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP4_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP5_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP6_ENABLE) = 1;
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MAX_NOTES) = MAX_NOTES;
*(p_data + DEXED_VOICE_OFFSET + DEXED_TRANSPOSE) = data[117];
memcpy(&data[DEXED_VOICE_OFFSET + DEXED_NAME], &data[118], 10);
//panic();
doRefreshVoice();
//activate();
strncpy(voice_name, (char *)&data[145], sizeof(voice_name) - 1);
#ifdef DEBUG
Serial.print(F("Voice ["));
Serial.print(voice_name);
Serial.println(F("] loaded."));
#endif
return (true);
}
bool Dexed::loadGlobalParameters(uint8_t* data)
{
uint8_t* p_data = data;
controllers.values_[kControllerPitchRange] = data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE];
controllers.values_[kControllerPitchStep] = data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP];
@ -526,22 +527,46 @@ bool Dexed::loadSysexVoice(uint8_t* new_data)
(*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP5_ENABLE) << 1) |
*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP6_ENABLE ));
setMaxNotes(*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MAX_NOTES));
setMaxNotes(*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MAX_NOTES));
//panic();
doRefreshVoice();
//activate();
strncpy(voice_name, (char *)&data[145], sizeof(voice_name) - 1);
#ifdef DEBUG
//char voicename[11];
//memset(voicename, 0, sizeof(voicename));
//strncpy(voicename, (char *)&data[145], sizeof(voicename) - 1);
Serial.println(F("Global parameters loaded."));
#endif
return (true);
}
Serial.print(F("Voice ["));
//Serial.print(voicename);
Serial.print(voice_name);
Serial.println(F("] loaded."));
bool Dexed::initGlobalParameters(void)
{
uint8_t init_data[18];
#ifdef DEBUG
Serial.println(F("Initializing global parameters"));
#endif
init_data[DEXED_PITCHBEND_RANGE] = 1;
init_data[DEXED_PITCHBEND_STEP] = 1;
init_data[DEXED_MODWHEEL_RANGE] = 99;
init_data[DEXED_MODWHEEL_ASSIGN] = 7;
init_data[DEXED_FOOTCTRL_RANGE] = 99;
init_data[DEXED_FOOTCTRL_ASSIGN] = 7;
init_data[DEXED_BREATHCTRL_RANGE] = 99;
init_data[DEXED_BREATHCTRL_ASSIGN] = 7;
init_data[DEXED_AT_RANGE] = 99;
init_data[DEXED_AT_ASSIGN] = 7;
init_data[DEXED_MASTER_TUNE] = 0;
init_data[DEXED_OP1_ENABLE] = 1;
init_data[DEXED_OP2_ENABLE] = 1;
init_data[DEXED_OP3_ENABLE] = 1;
init_data[DEXED_OP4_ENABLE] = 1;
init_data[DEXED_OP5_ENABLE] = 1;
init_data[DEXED_OP6_ENABLE] = 1;
init_data[DEXED_MAX_NOTES] = MAX_NOTES;
loadGlobalParameters(init_data);
return (true);
}

@ -156,7 +156,9 @@ class Dexed
uint8_t getMaxNotes(void);
void doRefreshVoice(void);
void setOPs(uint8_t ops);
bool loadSysexVoice(uint8_t* data);
bool loadVoiceParameters(uint8_t* data);
bool loadGlobalParameters(uint8_t* data);
bool initGlobalParameters(void);
void keyup(uint8_t pitch);
void keydown(uint8_t pitch, uint8_t velo);
void setSustain(bool sustain);

@ -256,7 +256,7 @@ bool load_sysex(uint8_t b, uint8_t v)
Serial.print(voice_names[v]);
Serial.println(F("]"));
#endif
return (dexed->loadSysexVoice(data));
return (dexed->loadVoiceParameters(data));
}
#ifdef DEBUG
else

Loading…
Cancel
Save