From edc913a05c46b4d5d75e95d88aa781ecf62865f1 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 22 Jan 2023 17:01:37 +0100 Subject: [PATCH] Removed MIDI-synced delay (does not work - not bpm stable :( ). Some fixes. --- MicroDexed.ino | 71 +++----------------- UI.hpp | 116 +++++++-------------------------- addon/SD/PERFORMANCE/0/fx.json | 6 +- config.h | 11 +--- dexed_sd.cpp | 5 -- 5 files changed, 38 insertions(+), 171 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 7dd4380..19afc25 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -228,7 +228,7 @@ AudioConnection patchCord[] = { uint8_t nDynamic = 0; #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT AudioConnection* dynamicConnections[NUM_DEXED * 16 + NUM_DRUMS * 4]; -#elif MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT +#elif MOD_FILTER_OUTPUT == MOD_NO_FILTER_OUTPUT AudioConnection* dynamicConnections[NUM_DEXED * 15 + NUM_DRUMS * 4]; #endif FLASHMEM void create_audio_dexed_chain(uint8_t instance_id) { @@ -242,7 +242,7 @@ FLASHMEM void create_audio_dexed_chain(uint8_t instance_id) { chorus_mixer[instance_id] = new AudioMixer<2>(); delay_fb_mixer[instance_id] = new AudioMixer<2>(); #if defined(USE_DELAY_8M) - delay_fx[instance_id] = new AudioEffectDelayExternal8(DELAY_MAX_TIME); + delay_fx[instance_id] = new AudioEffectDelayExternal8(3, DELAY_MAX_TIME); #else delay_fx[instance_id] = new AudioEffectDelay(); #endif @@ -574,6 +574,7 @@ void setup() { Serial.println(F("SD card not accessable.")); #endif } else { + Serial.println(F("SD card found.")); check_and_create_directories(); for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { @@ -982,7 +983,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) { } } -// EPiano + // EPiano if (configuration.epiano.midi_channel == MIDI_CHANNEL_OMNI || configuration.epiano.midi_channel == inChannel) { if (inNumber >= configuration.epiano.lowest_note && inNumber <= configuration.epiano.highest_note) { ep.noteOff(inNumber + configuration.epiano.transpose - 24); @@ -1004,7 +1005,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) { inCtrl = constrain(inCtrl, 0, 127); inValue = constrain(inValue, 0, 127); -// EPiano + // EPiano if (configuration.epiano.midi_channel == MIDI_CHANNEL_OMNI || configuration.epiano.midi_channel == inChannel) ep.processMidiController(inCtrl, inValue); @@ -1569,56 +1570,11 @@ void handleTuneRequest(void) { } void handleClock(void) { - if (midi_bpm_counter % 24 == 0) { - midi_bpm = (60000.0f / float(midi_bpm_timer) + 0.5); - - if (_midi_bpm > -1 && _midi_bpm != midi_bpm) { -#ifdef DEBUG - Serial.print(F("MIDI Clock: ")); - Serial.print(midi_bpm); - Serial.print(F(" bpm (")); - Serial.print(midi_bpm_timer, DEC); - Serial.println(F("ms per quarter)")); -#endif - - /* - 1 1/16 = 6 ticks / 0.0625 - 2 1/16T = 9 ticks / 0.09375 - 3 1/8 = 12 ticks / 0.125 - 4 1/8T = 18 ticks / 0.1875 - 5 1/4 = 24 ticks / 0.25 - 6 1/4T = 36 ticks / 0.375 - 7 1/2 = 48 ticks / 0.5 - 8 1/2T = 72 ticks / 0.75 - 9 1/1 = 96 ticks / 1.0 - */ - for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { - if (configuration.fx.delay_sync[instance_id] > 0) { - uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / float(midi_bpm) + 0.5); - delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10)); -#ifdef DEBUG - Serial.print(F("Setting Delay-Sync of instance ")); - Serial.print(instance_id); - Serial.print(F(" to ")); - Serial.print(constrain(midi_sync_delay_time, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10), DEC); - Serial.println(F(" ms")); -#endif - } - } - } - - _midi_bpm = midi_bpm; - midi_bpm_counter = 0; - midi_bpm_timer = 0; - } - - midi_bpm_counter++; + ; } void handleStart(void) { - midi_bpm_timer = 0; - midi_bpm_counter = 0; - _midi_bpm = -1; + ; } void handleContinue(void) { @@ -1804,11 +1760,9 @@ void check_configuration_fx(void) { configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id], CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id], CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); configuration.fx.chorus_level[instance_id] = constrain(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); - if (configuration.fx.delay_sync[instance_id] == 0) - configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); + configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); - configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX); configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX); } @@ -1968,7 +1922,6 @@ void init_configuration(void) { configuration.fx.delay_time[instance_id] = DELAY_TIME_DEFAULT / 10; configuration.fx.delay_feedback[instance_id] = DELAY_FEEDBACK_DEFAULT; configuration.fx.delay_level[instance_id] = DELAY_LEVEL_DEFAULT; - configuration.fx.delay_sync[instance_id] = DELAY_SYNC_DEFAULT; configuration.fx.reverb_send[instance_id] = REVERB_SEND_DEFAULT; MicroDexed[instance_id]->ControllersRefresh(); @@ -2047,12 +2000,8 @@ void set_fx_params(void) { delay_fb_mixer[instance_id]->gain(1, midi_volume_transform(map(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0, 127))); if (configuration.fx.delay_level[selected_instance_id] <= DELAY_LEVEL_MIN) delay_fx[instance_id]->disable(0); - else if (configuration.fx.delay_sync[instance_id] == 0) + else delay_fx[instance_id]->delay(0, constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10); - if (configuration.fx.delay_sync[instance_id] > 0) { - uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / midi_bpm); - delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX * 10)); - } // REVERB SEND reverb_mixer_r.gain(instance_id, volume_transform(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, VOL_MAX_FLOAT))); @@ -2754,8 +2703,6 @@ void show_configuration(void) { Serial.println(configuration.fx.delay_feedback[instance_id], DEC); Serial.print(F(" Delay Level ")); Serial.println(configuration.fx.delay_level[instance_id], DEC); - Serial.print(F(" Delay Sync ")); - Serial.println(configuration.fx.delay_sync[instance_id], DEC); Serial.print(F(" Reverb Send ")); Serial.println(configuration.fx.reverb_send[instance_id], DEC); Serial.print(F(" Sound Intensity ")); diff --git a/UI.hpp b/UI.hpp index b3d673c..befa34a 100644 --- a/UI.hpp +++ b/UI.hpp @@ -336,7 +336,6 @@ void display_meter_float(const char* title, float value, float factor, float off void lcd_active_instance_number(uint8_t instance_id); void lcd_OP_active_instance_number(uint8_t instance_id, uint8_t op); void lcd_special_chars(uint8_t mode); -void lcd_display_delay_sync(uint8_t sync); void string_trim(char* s); void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id); void draw_favorite_icon(uint8_t b, uint8_t v, uint8_t instance_id); @@ -1263,15 +1262,15 @@ 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_delay_sync(configuration.fx.delay_sync[selected_instance_id]); //goto MIDI Sync - } else { -#if DELAY_TIME_MAX >= 100 - display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); + +#if DELAY_TIME_MAX >= 1000 + display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 5, false, false, true); +#elif DELAY_TIME_MAX >= 100 + 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 - display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); + 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(); } @@ -1280,48 +1279,30 @@ void UI_func_delay_time(uint8_t param) { { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) { - 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()) { - 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]); - } - } + 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 NUM_DEXED > 1 - else if (LCDML.BT_checkEnter()) { - selected_instance_id = !selected_instance_id; - lcd_active_instance_number(selected_instance_id); - UI_update_instance_icons(); - } -#endif + if (LCDML.BT_checkEnter()) { + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); + UI_update_instance_icons(); } +#endif - if (configuration.fx.delay_sync[selected_instance_id] > 0) { - lcd_display_delay_sync(configuration.fx.delay_sync[selected_instance_id]); //MIDI Sync Delay - } else { -#if DELAY_TIME_MAX >= 100 - display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 4, false, false, true); +#if DELAY_TIME_MAX >= 1000 + display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 45, false, false, true); +#elif DELAY_TIME_MAX >= 100 + 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 - display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, true); + 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); - } + 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 ********* @@ -6475,53 +6456,6 @@ void lcd_special_chars(uint8_t mode) { } } -void lcd_display_delay_sync(uint8_t sync) { - display.show(0, 0, LCD_cols - 2, "Delay Sync"); - display.show(1, 0, 10, "MIDI Sync "); - switch (sync) { - case 1: - display.show(1, 10, 6, "1/16"); - break; - case 2: - display.show(1, 10, 6, "1/16T"); - break; - case 3: - display.show(1, 10, 6, "1/8"); - break; - case 4: - display.show(1, 10, 6, "1/8T"); - break; - case 5: - display.show(1, 10, 6, "1/4"); - break; - case 6: - display.show(1, 10, 6, "1/4T"); - break; - case 7: - display.show(1, 10, 6, "1/2"); - break; - case 8: - display.show(1, 10, 6, "1/2T"); - break; - case 9: - display.show(1, 10, 6, "1/1"); - break; - } - - uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[sync] / midi_bpm + 0.5); - if (midi_sync_delay_time > DELAY_MAX_TIME) { -#ifdef DEBUG - Serial.println(F("Calculated MIDI-Sync delay: ")); - Serial.print(round(60000.0 * midi_ticks_factor[sync] / midi_bpm), DEC); - Serial.println(F("ms")); - Serial.println(F("MIDI-Sync delay: midi_sync_delay_time")); - Serial.print(midi_sync_delay_time, DEC); - Serial.println(F("ms")); -#endif - } - display.show(1, 15, 1, "!"); -} - void string_trim(char* s) { int i; diff --git a/addon/SD/PERFORMANCE/0/fx.json b/addon/SD/PERFORMANCE/0/fx.json index c3819bc..1597260 100644 --- a/addon/SD/PERFORMANCE/0/fx.json +++ b/addon/SD/PERFORMANCE/0/fx.json @@ -35,10 +35,6 @@ 83, 82 ], - "delay_sync": [ - 3, - 3 - ], "reverb_send": [ 81, 99 @@ -62,4 +58,4 @@ "ep_chorus_depth": 0, "ep_chorus_level": 0, "ep_reverb_send": 0 -} \ No newline at end of file +} diff --git a/config.h b/config.h index f676e7a..6357fcb 100644 --- a/config.h +++ b/config.h @@ -132,9 +132,9 @@ #endif // DELAYTIME -//#define USE_DELAY_8M 1 +#define USE_DELAY_8M 1 #if defined(USE_DELAY_8M) -#define DELAY_MAX_TIME 5000 +#define DELAY_MAX_TIME 9990 #else #define DELAY_MAX_TIME 500 #endif @@ -367,10 +367,6 @@ #define DELAY_LEVEL_MAX 100 #define DELAY_LEVEL_DEFAULT 0 -#define DELAY_SYNC_MIN 0 -#define DELAY_SYNC_MAX 9 -#define DELAY_SYNC_DEFAULT 0 - #define REVERB_ROOMSIZE_MIN 0 #define REVERB_ROOMSIZE_MAX 100 #define REVERB_ROOMSIZE_DEFAULT 0 @@ -737,10 +733,9 @@ typedef struct fx_s { uint8_t chorus_waveform[MAX_DEXED]; uint8_t chorus_depth[MAX_DEXED]; uint8_t chorus_level[MAX_DEXED]; - uint8_t delay_time[MAX_DEXED]; + uint16_t delay_time[MAX_DEXED]; uint8_t delay_feedback[MAX_DEXED]; uint8_t delay_level[MAX_DEXED]; - uint8_t delay_sync[MAX_DEXED]; uint8_t reverb_send[MAX_DEXED]; uint8_t reverb_roomsize; uint8_t reverb_damping; diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 175805c..035655e 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -763,11 +763,7 @@ bool load_sd_fx_json(uint8_t number) { configuration.fx.delay_time[i] = data_json["delay_time"][i]; configuration.fx.delay_feedback[i] = data_json["delay_feedback"][i]; configuration.fx.delay_level[i] = data_json["delay_level"][i]; - configuration.fx.delay_sync[i] = data_json["delay_sync"][i]; configuration.fx.reverb_send[i] = data_json["reverb_send"][i]; - if (configuration.fx.delay_sync[i] > 0) { - configuration.fx.delay_time[i] = 0; - } } configuration.fx.reverb_roomsize = data_json["reverb_roomsize"]; configuration.fx.reverb_damping = data_json["reverb_damping"]; @@ -845,7 +841,6 @@ bool save_sd_fx_json(uint8_t number) { data_json["delay_time"][i] = configuration.fx.delay_time[i]; data_json["delay_feedback"][i] = configuration.fx.delay_feedback[i]; data_json["delay_level"][i] = configuration.fx.delay_level[i]; - data_json["delay_sync"][i] = configuration.fx.delay_sync[i]; data_json["reverb_send"][i] = configuration.fx.reverb_send[i]; } data_json["reverb_roomsize"] = configuration.fx.reverb_roomsize;