Several small fixes for voice menu and internal parameter handling.

pull/15/head
Holger Wirtz 5 years ago
parent 76768533a4
commit 3a3071273d
  1. 98
      MicroDexed.ino
  2. 52
      UI.hpp

@ -208,6 +208,7 @@ void setup()
Serial.print(F("Version: "));
Serial.println(VERSION);
Serial.println(F("<setup start>"));
Serial.flush();
setup_midi_devices();
@ -215,12 +216,9 @@ void setup()
{
Serial.print(F("Creating MicroDexed instance "));
Serial.print(i, DEC);
Serial.flush();
MicroDexed[i] = new AudioSourceMicroDexed(SAMPLE_RATE);
//create_audio_connections(*MicroDexed[i]);
Serial.println(F("... created"));
Serial.flush();
}
// Init EEPROM if both buttons are pressed at startup
@ -280,7 +278,6 @@ void setup()
#else
Serial.println(F("Internal DAC enabled."));
#endif
Serial.flush();
// start SD card
#ifndef TEENSY4
@ -326,7 +323,6 @@ void setup()
Serial.print(F("["));
Serial.print(voice_names[instance_id][n]);
Serial.println(F("]"));
Serial.flush();
}
#endif
@ -1050,6 +1046,10 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
float tmp2;
configuration.vol = v;
if (configuration.vol > 100)
configuration.vol = 100;
//configuration.dexed[instance_id].pan = p; // TODO: Fixing pan per Dexed
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
@ -1139,7 +1139,7 @@ void initial_values_from_eeprom(bool init)
else
{
EEPROM.get(EEPROM_START_ADDRESS, tmp_conf);
checksum = crc32((uint32_t*)&tmp_conf + 4, sizeof(tmp_conf) - 4);
checksum = crc32((byte*)&tmp_conf + 4, sizeof(tmp_conf) - 4);
#ifdef DEBUG
Serial.print(F("EEPROM checksum: 0x"));
@ -1158,46 +1158,48 @@ void initial_values_from_eeprom(bool init)
else
{
EEPROM.get(EEPROM_START_ADDRESS, configuration);
/*
configuration.instances %= INSTANCES_MAX;
configuration.instance_mode %= INSTANCE_MODE_MAX;
configuration.instance_splitpoint %= INSTANCE_SPLITPOINT_MAX;
configuration.vol %= VOLUME_MAX;
configuration.mono %= MONO_MAX;
configuration.reverb_roomsize %= REVERB_ROOMSIZE_MAX;
configuration.reverb_damping %= REVERB_DAMPING_MAX;
configuration.chorus_frequency %= CHORUS_FREQUENCY_MAX;
configuration.chorus_waveform %= CHORUS_WAVEFORM_MAX;
configuration.chorus_depth %= CHORUS_DEPTH_MAX;
configuration.delay_time %= DELAY_TIME_MAX;
configuration.delay_feedback %= DELAY_FEEDBACK_MAX;
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.dexed[instance_id].midi_channel %= MIDI_CHANNEL_MAX;
configuration.dexed[instance_id].bank %= MAX_BANKS;
configuration.dexed[instance_id].voice %= MAX_VOICES;
configuration.dexed[instance_id].pan %= PANORAMA_MAX;
configuration.dexed[instance_id].reverb_level %= REVERB_LEVEL_MAX;
configuration.dexed[instance_id].chorus_level %= CHORUS_LEVEL_MAX;
configuration.dexed[instance_id].delay_level %= DELAY_LEVEL_MAX;
configuration.dexed[instance_id].filter_cutoff %= FILTER_CUTOFF_MAX;
configuration.dexed[instance_id].filter_resonance %= FILTER_RESONANCE_MAX;
configuration.dexed[instance_id].loudness %= LOUDNESS_MAX;
configuration.dexed[instance_id].polyphony %= POLYPHONY_MAX;
configuration.dexed[instance_id].engine %= ENGINE_MAX;
configuration.dexed[instance_id].monopoly %= MONOPOLY_MAX;
configuration.dexed[instance_id].pb_range %= PB_RANGE_MAX;
configuration.dexed[instance_id].pb_step %= PB_STEP_MAX;
configuration.dexed[instance_id].mw_range %= MW_RANGE_MAX;
configuration.dexed[instance_id].mw_assign %= MW_ASSIGN_MAX;
configuration.dexed[instance_id].fc_range %= FC_RANGE_MAX;
configuration.dexed[instance_id].fc_assign %= FC_ASSIGN_MAX;
configuration.dexed[instance_id].bc_range %= BC_RANGE_MAX;
configuration.dexed[instance_id].bc_assign %= BC_ASSIGN_MAX;
configuration.dexed[instance_id].at_range %= AT_RANGE_MAX;
configuration.dexed[instance_id].at_assign %= AT_ASSIGN_MAX;
configuration.dexed[instance_id].op_enabled %= 0x3f; */
configuration.instances %= INSTANCES_MAX;
configuration.instance_mode %= INSTANCE_MODE_MAX;
configuration.instance_splitpoint %= INSTANCE_SPLITPOINT_MAX;
configuration.vol %= VOLUME_MAX;
configuration.mono %= MONO_MAX;
configuration.reverb_roomsize %= REVERB_ROOMSIZE_MAX;
configuration.reverb_damping %= REVERB_DAMPING_MAX;
configuration.chorus_frequency %= CHORUS_FREQUENCY_MAX;
configuration.chorus_waveform %= CHORUS_WAVEFORM_MAX;
configuration.chorus_depth %= CHORUS_DEPTH_MAX;
configuration.delay_time %= DELAY_TIME_MAX;
configuration.delay_feedback %= DELAY_FEEDBACK_MAX;
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
configuration.dexed[instance_id].midi_channel %= MIDI_CHANNEL_MAX;
configuration.dexed[instance_id].bank %= MAX_BANKS;
configuration.dexed[instance_id].voice %= MAX_VOICES;
configuration.dexed[instance_id].pan %= PANORAMA_MAX;
configuration.dexed[instance_id].reverb_level %= REVERB_LEVEL_MAX;
configuration.dexed[instance_id].chorus_level %= CHORUS_LEVEL_MAX;
configuration.dexed[instance_id].delay_level %= DELAY_LEVEL_MAX;
configuration.dexed[instance_id].filter_cutoff %= FILTER_CUTOFF_MAX;
configuration.dexed[instance_id].filter_resonance %= FILTER_RESONANCE_MAX;
configuration.dexed[instance_id].loudness %= LOUDNESS_MAX;
configuration.dexed[instance_id].polyphony %= POLYPHONY_MAX;
configuration.dexed[instance_id].engine %= ENGINE_MAX;
configuration.dexed[instance_id].monopoly %= MONOPOLY_MAX;
configuration.dexed[instance_id].pb_range %= PB_RANGE_MAX;
configuration.dexed[instance_id].pb_step %= PB_STEP_MAX;
configuration.dexed[instance_id].mw_range %= MW_RANGE_MAX;
configuration.dexed[instance_id].mw_assign %= MW_ASSIGN_MAX;
configuration.dexed[instance_id].fc_range %= FC_RANGE_MAX;
configuration.dexed[instance_id].fc_assign %= FC_ASSIGN_MAX;
configuration.dexed[instance_id].bc_range %= BC_RANGE_MAX;
configuration.dexed[instance_id].bc_assign %= BC_ASSIGN_MAX;
configuration.dexed[instance_id].at_range %= AT_RANGE_MAX;
configuration.dexed[instance_id].at_assign %= AT_ASSIGN_MAX;
configuration.dexed[instance_id].op_enabled %= 0x3f;
MicroDexed[instance_id]->setPBController(configuration.dexed[instance_id].pb_range, configuration.dexed[instance_id].pb_step);
MicroDexed[instance_id]->setMWController(configuration.dexed[instance_id].mw_range, configuration.dexed[instance_id].mw_assign);
MicroDexed[instance_id]->setFCController(configuration.dexed[instance_id].fc_range, configuration.dexed[instance_id].fc_assign);
@ -1276,14 +1278,14 @@ void eeprom_write(void)
void eeprom_update(void)
{
eeprom_update_flag = false;
configuration.checksum = crc32((uint32_t*)&configuration + 4, sizeof(configuration) - 4);
configuration.checksum = crc32((byte*)&configuration + 4, sizeof(configuration) - 4);
EEPROM.put(EEPROM_START_ADDRESS, configuration);
Serial.println(F("Updating EEPROM"));
show_configuration();
}
uint32_t crc32(uint32_t* calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc
{
uint32_t* index;
const uint32_t crc_table[16] =
{
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
@ -1293,7 +1295,7 @@ uint32_t crc32(uint32_t* calc_start, uint16_t calc_bytes) // base code from http
};
uint32_t crc = ~0L;
for (index = calc_start ; index < (calc_start + calc_bytes) ; ++index)
for (byte* index = calc_start ; index < (calc_start + calc_bytes) ; ++index)
{
crc = crc_table[(crc ^ *index) & 0x0f] ^ (crc >> 4);
crc = crc_table[(crc ^ (*index >> 4)) & 0x0f] ^ (crc >> 4);
@ -1466,7 +1468,6 @@ void show_patch(uint8_t instance_id)
{
Serial.print(MicroDexed[instance_id]->data[DEXED_VOICE_OFFSET + i], DEC);
Serial.print(F(" "));
Serial.flush();
}
Serial.println();
Serial.print(F("ALG: "));
@ -1502,7 +1503,6 @@ void show_patch(uint8_t instance_id)
Serial.print(i, DEC);
Serial.print(F(": "));
Serial.println(MicroDexed[instance_id]->data[i]);
Serial.flush();
}
Serial.println();

@ -414,7 +414,7 @@ void lcdml_menu_control(void)
bool button[NUM_ENCODER] = {digitalRead(BUT_R_PIN), digitalRead(BUT_L_PIN)};
/************************************************************************************
Basic encoder handlying (from LCDMenuLib2
Basic encoder handlying (from LCDMenuLib2)
************************************************************************************/
// RIGHT
if (g_LCDML_CONTROL_Encoder_position[ENC_R] <= -3)
@ -539,7 +539,7 @@ void encoder_right_up(void)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2 && LCDML.FUNC_getID() != 255)
instance_id = 1;
switch (menu_state)
@ -601,7 +601,7 @@ void encoder_right_down(void)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2 && LCDML.FUNC_getID() != 255)
instance_id = 1;
switch (menu_state)
@ -1015,7 +1015,7 @@ void UI_func_reverb_level(uint8_t param)
#ifdef USE_REVERB
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1232,7 +1232,7 @@ void UI_func_chorus_level(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1369,7 +1369,7 @@ void UI_func_delay_level(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1418,7 +1418,7 @@ void UI_func_filter_cutoff(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1470,7 +1470,7 @@ void UI_func_filter_resonance(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1518,7 +1518,7 @@ void UI_func_midi_channel(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1571,7 +1571,7 @@ void UI_func_loudness(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1619,7 +1619,7 @@ void UI_func_panorama(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1675,7 +1675,7 @@ void UI_func_stereo_mono(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1739,7 +1739,7 @@ void UI_func_polyphony(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1787,7 +1787,7 @@ void UI_func_engine(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1846,7 +1846,7 @@ void UI_func_mono_poly(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1902,7 +1902,7 @@ void UI_func_pb_range(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -1963,7 +1963,7 @@ void UI_func_pb_step(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2011,7 +2011,7 @@ void UI_func_mw_range(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2059,7 +2059,7 @@ void UI_func_mw_assign(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2133,7 +2133,7 @@ void UI_func_fc_range(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2181,7 +2181,7 @@ void UI_func_fc_assign(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2255,7 +2255,7 @@ void UI_func_bc_range(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2303,7 +2303,7 @@ void UI_func_bc_assign(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2377,7 +2377,7 @@ void UI_func_at_range(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2425,7 +2425,7 @@ void UI_func_at_assign(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -2588,7 +2588,7 @@ void UI_func_volume(uint8_t param)
{
uint8_t instance_id = 0;
if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2)
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1;
#ifdef DEBUG

Loading…
Cancel
Save