From f43a7de8030d627e443d2f1c2246eddf24e52c5b Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 15 May 2020 12:20:21 +0200 Subject: [PATCH] Voice selection screen has now a MIDI inidicator (with decay). --- MicroDexed.ino | 41 ++++++++++++++++++ UI.hpp | 112 +++++++++++++++++++++++++++---------------------- 2 files changed, 102 insertions(+), 51 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 28c15ae..48352ac 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -188,6 +188,7 @@ uint16_t midi_timing_quarter = 0; elapsedMillis long_button_pressed; elapsedMillis control_rate; uint8_t active_voices[NUM_DEXED]; +uint8_t midi_voices[NUM_DEXED]; #ifdef SHOW_CPU_LOAD_MSEC elapsedMillis cpu_mem_millis; #endif @@ -207,6 +208,12 @@ char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; char receive_bank_filename[FILENAME_LEN]; uint8_t selected_instance_id = 0; +#if NUM_DEXED>1 +int8_t midi_decay[NUM_DEXED] = { -1, -1}; +#else +int8_t midi_decay[NUM_DEXED] = { -1}; +#endif +elapsedMillis midi_decay_timer; #if defined(USE_FX) // Allocate the delay lines for chorus @@ -493,6 +500,9 @@ void loop() for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { active_voices[instance_id] = MicroDexed[instance_id]->getNumNotesPlaying(); + if (active_voices[instance_id] == 0) + midi_voices[instance_id] = 0; + #if defined(CPU_OVERLOAD_THROTTLE) if (AudioProcessorUsageMax() > CPU_OVERLOAD_THROTTLE && cpu_overload_throttle_timer >= CPU_OVERLOAD_THROTTLE_TIMER) { @@ -510,6 +520,30 @@ void loop() } #endif } + + if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) + { + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) + { + if (midi_decay_timer > 100 && midi_decay[instance_id] > 0) + { + midi_decay[instance_id]--; + lcd.createChar(6 + instance_id, (uint8_t*)inverse_num[15 - (7 - midi_decay[instance_id])]); + lcd.setCursor(14 + instance_id, 1); + lcd.write(6 + instance_id); + } + else if (midi_voices[instance_id] == 0 && midi_decay[instance_id] == 0) + { + midi_decay[instance_id]--; + lcd.setCursor(14 + instance_id, 1); + lcd.write(20); // blank + } + } + if (midi_decay_timer > 250) + { + midi_decay_timer = 0; + } + } } else yield(); @@ -547,6 +581,12 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) if (inNumber >= configuration.dexed[instance_id].lowest_note && inNumber <= configuration.dexed[instance_id].highest_note) { MicroDexed[instance_id]->keydown(inNumber, uint8_t(float(configuration.dexed[instance_id].velocity_level / 127.0)*inVelocity + 0.5)); + midi_voices[instance_id]++; + if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_voice_select)) + { + midi_decay_timer = 0; + midi_decay[instance_id] = min(inVelocity / 5, 7); + } #ifdef DEBUG char note_name[4]; getNoteName(note_name, inNumber); @@ -572,6 +612,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) if (inNumber >= configuration.dexed[instance_id].lowest_note && inNumber <= configuration.dexed[instance_id].highest_note) { MicroDexed[instance_id]->keyup(inNumber); + midi_voices[instance_id]--; #ifdef DEBUG char note_name[4]; getNoteName(note_name, inNumber); diff --git a/UI.hpp b/UI.hpp index b2c71b7..06545e3 100644 --- a/UI.hpp +++ b/UI.hpp @@ -157,21 +157,28 @@ const uint8_t meter_bar[5][8] = { {B00000, B00001, B00001, B00001, B00001, B00001, B00001, B00000} }; -const uint8_t inverse_num[8][8] = { - {B11111, B11011, B10011, B11011, B11011, B11011, B11011, B11111}, // 1 small invers - {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, // 2 small invers - {B11111, B11011, B10011, B11011, B11011, B11011, B11011, B11111}, // 1 OP invers - {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, // 2 OP invers - {B11111, B10001, B11101, B11011, B11101, B10101, B11011, B11111}, // 3 OP invers - {B11111, B10111, B10111, B10101, B10001, B11101, B11101, B11111}, // 4 OP invers - {B11111, B10001, B10111, B10011, B11101, B11101, B10011, B11111}, // 5 OP invers - {B11111, B11001, B10111, B10011, B10101, B10101, B11011, B11111} // 6 OP invers +const uint8_t inverse_num[16][8] = { + {B11111, B11011, B10011, B11011, B11011, B11011, B11011, B11111}, // [0] 1 small invers + {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, // [1] 2 small invers + {B11111, B11011, B10011, B11011, B11011, B11011, B11011, B11111}, // [2] 1 OP invers + {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, // [3] 2 OP invers + {B11111, B10001, B11101, B11011, B11101, B10101, B11011, B11111}, // [4] 3 OP invers + {B11111, B10111, B10111, B10101, B10001, B11101, B11101, B11111}, // [5] 4 OP invers + {B11111, B10001, B10111, B10011, B11101, B11101, B10011, B11111}, // [6] 5 OP invers + {B11111, B11001, B10111, B10011, B10101, B10101, B11011, B11111}, // [7] 6 OP invers + {B00000, B00000, B00000, B00000, B00000, B00000, B00000, B11111}, // [8] Level 1 + {B00000, B00000, B00000, B00000, B00000, B00000, B11111, B11111}, // [9] Level 2 + {B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111}, // [10] Level 3 + {B00000, B00000, B00000, B00000, B11111, B11111, B11111, B11111}, // [11] Level 4 + {B00000, B00000, B00000, B11111, B11111, B11111, B11111, B11111}, // [12] Level 5 + {B00000, B00000, B11111, B11111, B11111, B11111, B11111, B11111}, // [13] Level 6 + {B00000, B11111, B11111, B11111, B11111, B11111, B11111, B11111}, // [14] Level 7 + {B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111}, // [15] Level 8 }; enum { SCROLLBAR, BLOCKBAR, METERBAR }; enum { ENC_R, ENC_L }; enum {MENU_VOICE_BANK, MENU_VOICE_SOUND}; -uint8_t menu_voice_select = MENU_VOICE_SOUND; void lcdml_menu_display(void); void lcdml_menu_clear(void); @@ -3668,36 +3675,39 @@ void UI_func_voice_select(uint8_t param) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); - - lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); - lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); - lcd.show(0, 4, 10, bank_name); - lcd.show(1, 4, 10, voice_name); - + /* + lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); + lcd.show(0, 2, 10, bank_name); + lcd.show(1, 2, 10, voice_name); + */ #if NUM_DEXED > 1 + lcd.setCursor(14, 0); + lcd.write(0); lcd.setCursor(15, 0); - lcd.write(5); - lcd.setCursor(15, 1); - lcd.write(6); + lcd.write(1); #endif - switch (menu_voice_select) - { - case MENU_VOICE_BANK: - lcd.show(0, 2, 2, " ["); - lcd.show(0, 14, 1, "]"); - lcd.show(1, 2, 2, " "); - lcd.show(1, 14, 1, " "); - break; - case MENU_VOICE_SOUND: - lcd.show(0, 2, 2, " "); - lcd.show(0, 14, 1, " "); - lcd.show(1, 2, 2, " ["); - lcd.show(1, 14, 1, "]"); - break; - } + /* + switch (menu_voice_select) + { + case MENU_VOICE_BANK: + lcd.show(0, 2, 1, "["); + lcd.show(0, 13, 1, "]"); + lcd.show(1, 2, 1, " "); + lcd.show(1, 13, 1, " "); + break; + case MENU_VOICE_SOUND: + lcd.show(0, 2, 2, " "); + lcd.show(0, 13, 1, " "); + lcd.show(1, 2, 2, " ["); + lcd.show(1, 13, 1, "]"); + break; + } + */ } + if (LCDML.FUNC_loop()) // ****** LOOP ********* { char bank_name[BANK_NAME_LEN]; @@ -3819,13 +3829,13 @@ void UI_func_voice_select(uint8_t param) lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); - lcd.show(0, 4, 10, bank_name); - lcd.show(1, 4, 10, voice_name); + lcd.show(0, 3, 10, bank_name); + lcd.show(1, 3, 10, voice_name); + lcd.setCursor(14, 0); + lcd.write(0); lcd.setCursor(15, 0); - lcd.write(5); - lcd.setCursor(15, 1); - lcd.write(6); + lcd.write(1); } else menu_voice_select = MENU_VOICE_BANK; @@ -3855,22 +3865,22 @@ void UI_func_voice_select(uint8_t param) lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); - lcd.show(0, 4, 10, bank_name); - lcd.show(1, 4, 10, voice_name); + lcd.show(0, 3, 10, bank_name); + lcd.show(1, 3, 10, voice_name); switch (menu_voice_select) { case MENU_VOICE_BANK: - lcd.show(0, 2, 2, " ["); - lcd.show(0, 14, 1, "]"); - lcd.show(1, 2, 2, " "); - lcd.show(1, 14, 1, " "); + lcd.show(0, 2, 1, "["); + lcd.show(0, 13, 1, "]"); + lcd.show(1, 2, 1, " "); + lcd.show(1, 13, 1, " "); break; case MENU_VOICE_SOUND: - lcd.show(0, 2, 2, " "); - lcd.show(0, 14, 1, " "); - lcd.show(1, 2, 2, " ["); - lcd.show(1, 14, 1, "]"); + lcd.show(0, 2, 1, " "); + lcd.show(0, 13, 1, " "); + lcd.show(1, 2, 1, "["); + lcd.show(1, 13, 1, "]"); break; } } @@ -5172,8 +5182,8 @@ void lcd_active_instance_number(uint8_t instance_id) } } - lcd.createChar(5, instance_num[0]); - lcd.createChar(6, instance_num[1]); + lcd.createChar(0, instance_num[0]); + lcd.createChar(1, instance_num[1]); } void lcd_OP_active_instance_number(uint8_t instance_id, uint8_t op)