From d4673ab918cf6c7d495df6e33ba1b94f0abe5b6d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 13 Jul 2021 07:14:57 +0200 Subject: [PATCH] Adding UI for MIDI-synced delay. --- UI.hpp | 69 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/UI.hpp b/UI.hpp index c4384ef..4132a86 100644 --- a/UI.hpp +++ b/UI.hpp @@ -212,7 +212,6 @@ void UI_func_panorama(uint8_t param); void UI_func_stereo_mono(uint8_t param); void UI_func_note_refresh(uint8_t param); void UI_func_polyphony(uint8_t param); -void UI_func_engine(uint8_t param); void UI_func_mono_poly(uint8_t param); void UI_func_pb_range(uint8_t param); void UI_func_pb_step(uint8_t param); @@ -1375,11 +1374,18 @@ void UI_func_delay_time(uint8_t param) encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); + if (configuration.fx.delay_sync[selected_instance_id] > 0) + { + lcd_display_bar_int("Delay Sync", configuration.fx.delay_sync[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); + } + else + { #if DELAY_TIME_MAX >= 100 - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); #else - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); #endif + } lcd_active_instance_number(selected_instance_id); UI_update_instance_icons(); } @@ -1390,13 +1396,34 @@ void UI_func_delay_time(uint8_t param) { if (LCDML.BT_checkDown()) { - configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] + ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); - MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); + if (configuration.fx.delay_time[selected_instance_id] == DELAY_TIME_MIN && configuration.fx.delay_sync[selected_instance_id] > DELAY_SYNC_MIN) + { + // MIDI-sync delay + configuration.fx.delay_sync[selected_instance_id] = constrain(configuration.fx.delay_sync[selected_instance_id] - 1, DELAY_SYNC_MIN, DELAY_SYNC_MAX); + } + else + { + configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] + ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); + MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); + } } else if (LCDML.BT_checkUp()) { - configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] - ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); - MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); + if (configuration.fx.delay_time[selected_instance_id] == DELAY_TIME_MIN && configuration.fx.delay_sync[selected_instance_id] > DELAY_SYNC_MIN) + { + // MIDI-sync delay + configuration.fx.delay_sync[selected_instance_id] = constrain(configuration.fx.delay_sync[selected_instance_id] + 1, DELAY_SYNC_MIN, DELAY_SYNC_MAX); + } + else + { + if (configuration.fx.delay_time[selected_instance_id] == DELAY_TIME_MIN) + configuration.fx.delay_sync[selected_instance_id] = DELAY_SYNC_MIN + 1; + else + { + configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] - ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); + MD_sendControlChange(configuration.dexed[selected_instance_id].midi_channel, 105, configuration.fx.delay_time[selected_instance_id]); + } + } } #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) @@ -1408,15 +1435,22 @@ void UI_func_delay_time(uint8_t param) #endif } + if (configuration.fx.delay_sync[selected_instance_id] > 0) + { + lcd_display_bar_int("Delay Sync", configuration.fx.delay_sync[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); + } + else + { #if DELAY_TIME_MAX >= 100 - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); #else - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); #endif - if (configuration.fx.delay_time[selected_instance_id] <= DELAY_TIME_MIN) - delay_fx[selected_instance_id]->disable(0); - else - delay_fx[selected_instance_id]->delay(0, constrain(configuration.fx.delay_time[selected_instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10); + if (configuration.fx.delay_time[selected_instance_id] <= DELAY_TIME_MIN) + delay_fx[selected_instance_id]->disable(0); + else + delay_fx[selected_instance_id]->delay(0, constrain(configuration.fx.delay_time[selected_instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10); + } } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1424,8 +1458,10 @@ void UI_func_delay_time(uint8_t param) lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.delay_time[0]), configuration.fx.delay_time[0]); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.delay_sync[0]), configuration.fx.delay_sync[0]); #if NUM_DEXED > 1 EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.delay_time[1]), configuration.fx.delay_time[1]); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.delay_sync[1]), configuration.fx.delay_sync[1]); #endif } } @@ -2287,11 +2323,6 @@ void UI_func_polyphony(uint8_t param) } } -void UI_func_engine(uint8_t param) -{ - ; -} - void UI_func_mono_poly(uint8_t param) { if (LCDML.FUNC_setup()) // ****** SETUP ********* @@ -2327,7 +2358,7 @@ void UI_func_mono_poly(uint8_t param) lcd_active_instance_number(selected_instance_id); #endif } - + lcd.setCursor(0, 1); switch (configuration.dexed[selected_instance_id].monopoly) {