diff --git a/MicroDexed.ino b/MicroDexed.ino index 746ea66..31098f4 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -100,7 +100,7 @@ uint8_t active_voices = 0; #ifdef SHOW_CPU_LOAD_MSEC elapsedMillis cpu_mem_millis; #endif -config_t configuration = {0xffff, 0, 0, VOLUME, 0.5f, DEFAULT_MIDI_CHANNEL}; +config_t configuration = {0xffff, 0, 0, VOLUME, 0.5f, 0, DEFAULT_MIDI_CHANNEL}; bool eeprom_update_flag = false; value_change_t soften_volume = {0.0, 0}; value_change_t soften_filter_res = {0.0, 0}; @@ -820,29 +820,7 @@ void set_volume(float v, float p) { configuration.vol = v; configuration.pan = p; - - /* - #ifdef DEBUG - Serial.print(F("Setting volume: VOL=")); - Serial.print(v, DEC); - Serial.print(F("[")); - Serial.print(configuration.vol, DEC); - Serial.print(F("] PAN=")); - Serial.print(F("[")); - Serial.print(configuration.pan, DEC); - Serial.print(F("] ")); - Serial.print(pow(configuration.vol * sinf(configuration.pan * PI / 2), VOLUME_CURVE), 3); - Serial.print(F("/")); - Serial.println(pow(configuration.vol * cosf( configuration.pan * PI / 2), VOLUME_CURVE), 3); - #endif - - dexed->fx.Gain = v; - - // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html - volume_r.gain(sinf(p * PI / 2)); - volume_l.gain(cosf(p * PI / 2)); - */ - + dexed->fx.Gain = v; uint16_t tmp = v * 1023.0 + 0.5; @@ -867,10 +845,11 @@ void set_volume(float v, float p) // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html volume_r.gain(tmp3 * sinf(tmp2 * PI / 2)); volume_l.gain(tmp3 * cosf(tmp2 * PI / 2)); - /* if (configuration.mono == 2) - volume_l.gain(0.0); - else if (configuration.mono == 3) - volume_r.gain(0.0); */ + + if (configuration.mono == 2) + volume_l.gain(0.0); + else if (configuration.mono == 3) + volume_r.gain(0.0); } // https://www.dr-lex.be/info-stuff/volumecontrols.html#table1 @@ -879,7 +858,6 @@ inline float logvol(float x) return (0.001 * expf(6.908 * x)); } - /****************************************************************************** EEPROM HELPER ******************************************************************************/ diff --git a/UI.hpp b/UI.hpp index 638a43a..192551b 100644 --- a/UI.hpp +++ b/UI.hpp @@ -191,7 +191,7 @@ void lcdml_menu_control(void) break; case MENU_VOICE: #ifdef DEBUG - Serial.println(F("State: MENU_VOICE, Encoder left down")); + Serial.println(F("State: MENU_VOICE, Encoder left up")); #endif switch (menu_voice) { @@ -204,7 +204,7 @@ void lcdml_menu_control(void) } break; case MENU_VOICE_SOUND: - if (configuration.voice < 31) + if (configuration.voice < MAX_VOICES) configuration.voice++; else { @@ -212,10 +212,10 @@ void lcdml_menu_control(void) { configuration.bank++; configuration.voice = 0; - load_sysex(configuration.bank, configuration.voice); - get_voice_names_from_bank(configuration.bank); } } + load_sysex(configuration.bank, configuration.voice); + get_voice_names_from_bank(configuration.bank); eeprom_write(); } UI_func_voice_selection(0); @@ -244,7 +244,7 @@ void lcdml_menu_control(void) break; case MENU_VOICE: #ifdef DEBUG - Serial.println(F("State: MENU_VOICE, Encoder left up")); + Serial.println(F("State: MENU_VOICE, Encoder left down")); #endif switch (menu_voice) { @@ -265,10 +265,10 @@ void lcdml_menu_control(void) { configuration.bank--; configuration.voice = 31; - load_sysex(configuration.bank, configuration.voice); - get_voice_names_from_bank(configuration.bank); } } + load_sysex(configuration.bank, configuration.voice); + get_voice_names_from_bank(configuration.bank); eeprom_write(); } UI_func_voice_selection(0); @@ -344,9 +344,8 @@ void lcdml_menu_control(void) #ifdef DEBUG Serial.println(F("Volume +")); #endif - if (configuration.vol < 0.95) + if (configuration.vol < 0.96) { - //set_volume(configuration.vol + 0.05, configuration.pan); soften_volume.diff = 0.05 / SOFTEN_VALUE_CHANGE_STEPS; soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS; eeprom_write(); @@ -369,9 +368,8 @@ void lcdml_menu_control(void) #ifdef DEBUG Serial.println(F("Volume -")); #endif - if (configuration.vol > 0.05) + if (configuration.vol > 0.04) { - //set_volume(configuration.vol - 0.05, configuration.pan); soften_volume.diff = -0.05 / SOFTEN_VALUE_CHANGE_STEPS; soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS; eeprom_write(); @@ -731,17 +729,18 @@ void UI_func_volume(uint8_t param) // update LCD content LCDML.DISP_clear(); - lcd.setCursor(0, 0); // set cursor - lcd.print("Volume"); // print change content - lcd.setCursor(0, 1); // set cursor - + lcd.show(0, 0, 8, "Volume: "); + lcd.show(0, 9, 3, configuration.vol * 100.0 + 0.5); + lcd.setCursor(1, 1); for (uint8_t i = 0; i < LCD_cols; i++) { - if (i < int(LCD_cols * configuration.vol + 0.5)) + if (i < int((LCD_cols - 2) * configuration.vol + 0.5)) lcd.print("*"); else lcd.print(" "); } + lcd.show(1, 0, 1, "["); + lcd.show(1, 15, 1, "]"); } #endif #endif diff --git a/config.h b/config.h index 78a562c..34b772f 100644 --- a/config.h +++ b/config.h @@ -203,6 +203,7 @@ struct config_t { uint8_t voice; float vol; float pan; + uint8_t mono; uint8_t midi_channel; };