diff --git a/MicroDexed.ino b/MicroDexed.ino index 82fecba..39aefe8 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -205,8 +205,6 @@ void setup() Serial.println(VERSION); Serial.println(F("")); - initial_values_from_eeprom(); - for (uint8_t i = 0; i < NUM_DEXED; i++) { Serial.print(F("Creating MicroDexed engine ")); @@ -218,6 +216,8 @@ void setup() create_audio_connections(*MicroDexed[i]); } + initial_values_from_eeprom(); + setup_midi_devices(); // start audio card @@ -393,6 +393,7 @@ void setup() MicroDexed[i]->fx.Gain = mapfloat(configuration.loudness[i], LOUDNESS_MIN, LOUDNESS_MAX, 0.0, 1.0); MicroDexed[i]->fx.Reso = mapfloat(configuration.filter_resonance[i], FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 0.0, 1.0); MicroDexed[i]->fx.Cutoff = mapfloat(configuration.filter_cutoff[i], FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 0.0, 1.0); + MicroDexed[i]->doRefreshVoice(); } // set initial volume and pan (read from EEPROM) @@ -1093,13 +1094,13 @@ void initial_values_from_eeprom(void) Serial.print(F("EEPROM checksum: 0x")); Serial.print(tmp_conf.checksum, HEX); Serial.print(F(" / 0x")); - Serial.print(checksum, HEX); + Serial.println(checksum, HEX); #endif if (checksum != tmp_conf.checksum) { #ifdef DEBUG - Serial.print(F(" - mismatch -> initializing EEPROM!")); + Serial.println(F("Checksum mismatch -> initializing EEPROM!")); #endif configuration.checksum = 0xffff; @@ -1185,15 +1186,20 @@ void initial_values_from_eeprom(void) configuration.at_range[i] %= AT_RANGE_MAX; configuration.at_assign[i] %= AT_ASSIGN_MAX; configuration.op_enabled[i] %= 0x3f; - - //MicroDexed[i]->setControllers(configuration.pb_range[i], configuration.pb_step[i], configuration.mw_range[i], configuration.mw_assign[i], configuration.fc_range[i], configuration.fc_assign[i], configuration.bc_range[i], configuration.bc_assign[i], configuration.at_range[i], configuration.at_assign[i]); + + MicroDexed[i]->setPBController(configuration.pb_range[i], configuration.pb_step[i]); + MicroDexed[i]->setMWController(configuration.mw_range[i], configuration.mw_assign[i]); + MicroDexed[i]->setFCController(configuration.fc_range[i], configuration.fc_assign[i]); + MicroDexed[i]->setBCController(configuration.bc_range[i], configuration.bc_assign[i]); + MicroDexed[i]->setATController(configuration.at_range[i], configuration.at_assign[i]); + + MicroDexed[i]-> setOPs(configuration.op_enabled[i]); } - Serial.print(F(" - OK, loading!")); + Serial.println(F("OK, loaded!")); } eeprom_update(); #ifdef DEBUG - Serial.println(); show_configuration(); #endif diff --git a/UI.hpp b/UI.hpp index ad21d9d..b8369d2 100644 --- a/UI.hpp +++ b/UI.hpp @@ -151,6 +151,8 @@ void UI_func_mw_range(uint8_t param); void UI_func_mw_assign(uint8_t param); void UI_func_fc_range(uint8_t param); void UI_func_fc_assign(uint8_t param); +void UI_func_bc_range(uint8_t param); +void UI_func_bc_assign(uint8_t param); void UI_func_at_range(uint8_t param); void UI_func_at_assign(uint8_t param); void UI_func_information(uint8_t param); @@ -186,14 +188,14 @@ LCDML_add(15, LCDML_0_1_2, 11, "Mod Wheel 1", NULL); LCDML_add(16, LCDML_0_1_2_8, 1, "MW Range 1", UI_func_mw_range); LCDML_add(17, LCDML_0_1_2_8, 2, "MW Assign 1", UI_func_mw_assign); LCDML_add(18, LCDML_0_1_2, 12, "Foot Ctrl 1", NULL); -LCDML_add(19, LCDML_0_1_2_9, 1, "FC Range 1", UI_function_not_implemented); -LCDML_add(20, LCDML_0_1_2_9, 2, "FC Assign 1", UI_function_not_implemented); +LCDML_add(19, LCDML_0_1_2_9, 1, "FC Range 1", UI_func_fc_range); +LCDML_add(20, LCDML_0_1_2_9, 2, "FC Assign 1", UI_func_fc_assign); LCDML_add(21, LCDML_0_1_2, 13, "Breath Ctrl 1", NULL); -LCDML_add(22, LCDML_0_1_2_10, 1, "BC Range 1", UI_function_not_implemented); -LCDML_add(23, LCDML_0_1_2_10, 2, "BC Assign 1", UI_function_not_implemented); +LCDML_add(22, LCDML_0_1_2_10, 1, "BC Range 1", UI_func_bc_range); +LCDML_add(23, LCDML_0_1_2_10, 2, "BC Assign 1", UI_func_bc_assign); LCDML_add(24, LCDML_0_1_2, 14, "Aftertouch 1", NULL); -LCDML_add(25, LCDML_0_1_2_11, 1, "AT Range 1", UI_function_not_implemented); -LCDML_add(26, LCDML_0_1_2_11, 2, "AT Assign 1", UI_function_not_implemented); +LCDML_add(25, LCDML_0_1_2_11, 1, "AT Range 1", UI_func_at_range); +LCDML_add(26, LCDML_0_1_2_11, 2, "AT Assign 1", UI_func_at_assign); LCDML_add(27, LCDML_0_1_2, 15, "Portamento 1", NULL); LCDML_add(28, LCDML_0_1_2_12, 1, "Port. Mode 1", UI_function_not_enabled); LCDML_add(29, LCDML_0_1_2_12, 2, "Port. Gliss 1", UI_function_not_enabled); @@ -219,17 +221,17 @@ LCDML_add(48, LCDML_0_1_3, 10, "Pitchbend 2", NULL); LCDML_add(49, LCDML_0_1_3_7, 1, "PB Range 2", UI_func_pb_range); LCDML_add(50, LCDML_0_1_3_7, 2, "PB Step 2", UI_func_pb_step); LCDML_add(51, LCDML_0_1_3, 11, "Mod Wheel 2", NULL); -LCDML_add(52, LCDML_0_1_3_8, 1, "MW Range 2", UI_function_not_implemented); -LCDML_add(53, LCDML_0_1_3_8, 2, "MW Assign 2", UI_function_not_implemented); +LCDML_add(52, LCDML_0_1_3_8, 1, "MW Range 2", UI_func_mw_range); +LCDML_add(53, LCDML_0_1_3_8, 2, "MW Assign 2", UI_func_mw_assign); LCDML_add(54, LCDML_0_1_3, 12, "Foot Ctrl 2", NULL); -LCDML_add(55, LCDML_0_1_3_9, 1, "FC Range 2", UI_function_not_implemented); -LCDML_add(56, LCDML_0_1_3_9, 2, "FC Assign 2", UI_function_not_implemented); +LCDML_add(55, LCDML_0_1_3_9, 1, "FC Range 2", UI_func_fc_range); +LCDML_add(56, LCDML_0_1_3_9, 2, "FC Assign 2", UI_func_fc_assign); LCDML_add(57, LCDML_0_1_3, 13, "Breat Ctrl 2", NULL); -LCDML_add(58, LCDML_0_1_3_10, 1, "BC Range 2", UI_function_not_implemented); -LCDML_add(59, LCDML_0_1_3_10, 2, "BC Assign 2", UI_function_not_implemented); +LCDML_add(58, LCDML_0_1_3_10, 1, "BC Range 2", UI_func_bc_range); +LCDML_add(59, LCDML_0_1_3_10, 2, "BC Assign 2", UI_func_bc_assign); LCDML_add(60, LCDML_0_1_3, 14, "Aftertouch 2", NULL); -LCDML_add(61, LCDML_0_1_3_11, 1, "AT Range 2", UI_function_not_implemented); -LCDML_add(62, LCDML_0_1_3_11, 2, "AT Assign 2", UI_function_not_implemented); +LCDML_add(61, LCDML_0_1_3_11, 1, "AT Range 2", UI_func_at_range); +LCDML_add(62, LCDML_0_1_3_11, 2, "AT Assign 2", UI_func_at_assign); LCDML_add(63, LCDML_0_1_3, 15, "Portamento 2", NULL); LCDML_add(64, LCDML_0_1_3_12, 1, "Port. Mode 2", UI_function_not_enabled); LCDML_add(65, LCDML_0_1_3_12, 2, "Port. Gliss 2", UI_function_not_enabled); @@ -279,14 +281,14 @@ LCDML_add(13, LCDML_0_1, 11, "Mod Wheel", NULL); LCDML_add(14, LCDML_0_1_11, 1, "MW Range", UI_func_mw_range); LCDML_add(15, LCDML_0_1_11, 2, "MW Assign", UI_func_mw_assign); LCDML_add(16, LCDML_0_1, 12, "Foot Ctrl", NULL); -LCDML_add(17, LCDML_0_1_12, 1, "FC Range", UI_function_not_implemented); -LCDML_add(18, LCDML_0_1_12, 2, "FC Assign", UI_function_not_implemented); +LCDML_add(17, LCDML_0_1_12, 1, "FC Range", UI_func_fc_range); +LCDML_add(18, LCDML_0_1_12, 2, "FC Assign", UI_func_fc_assign); LCDML_add(19, LCDML_0_1, 13, "Breath Ctrl", NULL); -LCDML_add(20, LCDML_0_1_13, 1, "BC Range", UI_function_not_implemented); -LCDML_add(21, LCDML_0_1_13, 2, "BC Assign", UI_function_not_implemented); +LCDML_add(20, LCDML_0_1_13, 1, "BC Range", UI_func_bc_range); +LCDML_add(21, LCDML_0_1_13, 2, "BC Assign", UI_func_bc_assign); LCDML_add(22, LCDML_0_1, 14, "Aftertouch", NULL); -LCDML_add(23, LCDML_0_1_14, 1, "AT Range", UI_function_not_implemented); -LCDML_add(24, LCDML_0_1_14, 2, "AT Assign", UI_function_not_implemented); +LCDML_add(23, LCDML_0_1_14, 1, "AT Range", UI_func_at_range); +LCDML_add(24, LCDML_0_1_14, 2, "AT Assign", UI_func_at_assign); LCDML_add(25, LCDML_0_1, 15, "Portamento", NULL); LCDML_add(26, LCDML_0_1_15, 1, "Port. Mode", UI_function_not_implemented); LCDML_add(27, LCDML_0_1_15, 2, "Port. Gliss", UI_function_not_implemented); @@ -2041,7 +2043,6 @@ void UI_func_mw_assign(uint8_t param) lcd.setCursor(0, 1); switch (configuration.mw_assign[instance_id]) { - default: case 0: lcd.print(F("[ NONE ]")); break; @@ -2080,22 +2081,368 @@ void UI_func_mw_assign(uint8_t param) void UI_func_fc_range(uint8_t param) { + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("FC Range")); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.fc_range[instance_id] < FC_RANGE_MAX) + { + configuration.fc_range[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.fc_range[instance_id] > FC_RANGE_MIN) + { + configuration.fc_range[instance_id]--; + } + } + + lcd.setCursor(0, 1); + lcd_display_int(configuration.fc_range[instance_id], 2, false, true, false); + MicroDexed[instance_id]->setFCController(configuration.fc_range[instance_id], configuration.fc_assign[instance_id]); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } } void UI_func_fc_assign(uint8_t param) { + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("FC Assign")); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.fc_assign[instance_id] < FC_ASSIGN_MAX) + { + configuration.fc_assign[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.fc_assign[instance_id] > FC_ASSIGN_MIN) + { + configuration.fc_assign[instance_id]--; + } + } + + lcd.setCursor(0, 1); + switch (configuration.fc_assign[instance_id]) + { + case 0: + lcd.print(F("[ NONE ]")); + break; + case 1: + lcd.print(F("[PTCH ]")); + break; + case 2: + lcd.print(F("[ AMP ]")); + break; + case 3: + lcd.print(F("[PTCH AMP ]")); + break; + case 4: + lcd.print(F("[ EG-BS]")); + break; + case 5: + lcd.print(F("[PTCH EG-BS]")); + break; + case 6: + lcd.print(F("[ AMP EG-BS]")); + break; + case 7: + lcd.print(F("[PTCH AMP EG-BS]")); + break; + } + + MicroDexed[instance_id]->setFCController(configuration.fc_range[instance_id], configuration.fc_assign[instance_id]); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } +} + +void UI_func_bc_range(uint8_t param) +{ + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("BC Range")); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.bc_range[instance_id] < BC_RANGE_MAX) + { + configuration.bc_range[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.bc_range[instance_id] > BC_RANGE_MIN) + { + configuration.bc_range[instance_id]--; + } + } + + lcd.setCursor(0, 1); + lcd_display_int(configuration.bc_range[instance_id], 2, false, true, false); + + MicroDexed[instance_id]->setBCController(configuration.bc_range[instance_id], configuration.bc_assign[instance_id]); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } +} + +void UI_func_bc_assign(uint8_t param) +{ + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("BC Assign")); + } + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.bc_assign[instance_id] < BC_ASSIGN_MAX) + { + configuration.bc_assign[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.bc_assign[instance_id] > BC_ASSIGN_MIN) + { + configuration.bc_assign[instance_id]--; + } + } + + lcd.setCursor(0, 1); + switch (configuration.bc_assign[instance_id]) + { + case 0: + lcd.print(F("[ NONE ]")); + break; + case 1: + lcd.print(F("[PTCH ]")); + break; + case 2: + lcd.print(F("[ AMP ]")); + break; + case 3: + lcd.print(F("[PTCH AMP ]")); + break; + case 4: + lcd.print(F("[ EG-BS]")); + break; + case 5: + lcd.print(F("[PTCH EG-BS]")); + break; + case 6: + lcd.print(F("[ AMP EG-BS]")); + break; + case 7: + lcd.print(F("[PTCH AMP EG-BS]")); + break; + } + + MicroDexed[instance_id]->setBCController(configuration.bc_range[instance_id], configuration.bc_assign[instance_id]); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } } void UI_func_at_range(uint8_t param) { + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("AT Range")); + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.at_range[instance_id] < AT_RANGE_MAX) + { + configuration.at_range[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.at_range[instance_id] > AT_RANGE_MIN) + { + configuration.at_range[instance_id]--; + } + } + + lcd.setCursor(0, 1); + lcd_display_int(configuration.at_range[instance_id], 2, false, true, false); + + MicroDexed[instance_id]->setATController(configuration.at_range[instance_id], configuration.at_assign[instance_id]); + } + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } } void UI_func_at_assign(uint8_t param) { + uint8_t instance_id = 0; + + if (LCDML.FUNC_getID() < MENU_ID_OF_INSTANCE_2) + instance_id = 1; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + // setup function + lcd.setCursor(0, 0); + lcd.print(F("AT Assign")); + } + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if (LCDML.BT_checkEnter()) + { + LCDML.FUNC_goBackToMenu(); + } + else if (LCDML.BT_checkDown()) + { + if (configuration.at_assign[instance_id] < AT_ASSIGN_MAX) + { + configuration.at_assign[instance_id]++; + } + } + else if (LCDML.BT_checkUp()) + { + if (configuration.at_assign[instance_id] > AT_ASSIGN_MIN) + { + configuration.at_assign[instance_id]--; + } + } + + lcd.setCursor(0, 1); + switch (configuration.at_assign[instance_id]) + { + case 0: + lcd.print(F("[ NONE ]")); + break; + case 1: + lcd.print(F("[PTCH ]")); + break; + case 2: + lcd.print(F("[ AMP ]")); + break; + case 3: + lcd.print(F("[PTCH AMP ]")); + break; + case 4: + lcd.print(F("[ EG-BS]")); + break; + case 5: + lcd.print(F("[PTCH EG-BS]")); + break; + case 6: + lcd.print(F("[ AMP EG-BS]")); + break; + case 7: + lcd.print(F("[PTCH AMP EG-BS]")); + break; + } + + MicroDexed[instance_id]->setATController(configuration.at_range[instance_id], configuration.at_assign[instance_id]); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + // you can here reset some global vars or do nothing + eeprom_write(); + } } void UI_func_information(uint8_t param) diff --git a/config.h b/config.h index 40a8d6d..b30f8e6 100644 --- a/config.h +++ b/config.h @@ -355,8 +355,8 @@ enum { DEXED, REVERB, DELAY, CHORUS }; #define PB_STEP_DEFAULT 1 #define MW_RANGE_MIN 0 -#define MW_RANGE_MAX 12 -#define MW_RANGE_DEFAULT 12 +#define MW_RANGE_MAX 99 +#define MW_RANGE_DEFAULT 50 #define MW_ASSIGN_MIN 0 #define MW_ASSIGN_MAX 7 diff --git a/dexed.cpp b/dexed.cpp index 83fb6e7..18a4c0c 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -172,12 +172,12 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) fx.process(sumbuf, n_samples); -#ifdef USE_TEENSY_DSP - arm_float_to_q15(sumbuf, buffer, AUDIO_BLOCK_SAMPLES); -#else +//#ifdef USE_TEENSY_DSP + //arm_float_to_q15(sumbuf, buffer, AUDIO_BLOCK_SAMPLES); +//#else for (i = 0; i < n_samples; ++i) buffer[i] = static_cast(sumbuf[i] * 0x7fff); -#endif +//#endif } void Dexed::keydown(uint8_t pitch, uint8_t velo) { @@ -640,6 +640,7 @@ void Dexed::setMWController(uint8_t mw_range, uint8_t mw_assign) #endif data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE] = mw_range; + controllers.wheel.setRange(mw_range); data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN] = mw_assign; controllers.wheel.setTarget(mw_assign); @@ -663,8 +664,8 @@ void Dexed::setFCController(uint8_t fc_range, uint8_t fc_assign) #endif data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE] = fc_range; + controllers.foot.setRange(fc_range); data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN] = fc_assign; - controllers.foot.setTarget(fc_assign); controllers.refresh(); @@ -687,6 +688,7 @@ void Dexed::setBCController(uint8_t bc_range, uint8_t bc_assign) #endif data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE] = bc_range; + controllers.breath.setRange(bc_range); data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN] = bc_assign; controllers.breath.setTarget(bc_assign); @@ -710,6 +712,7 @@ void Dexed::setATController(uint8_t at_range, uint8_t at_assign) #endif data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE] = at_range; + controllers.at.setRange(at_range); data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN] = at_assign; controllers.at.setTarget(at_assign);