diff --git a/MicroDexed.ino b/MicroDexed.ino index 7ad7dd1..68d9040 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -338,6 +338,7 @@ int perform_release_mod[NUM_DEXED] = { 0, 0 }; int16_t* delayline[NUM_DEXED]; int16_t* ep_delayline_r; int16_t* ep_delayline_l; +uint8_t midinote_old[NUM_DRUMSET_CONFIG]; #if NUM_DRUMS > 0 //extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; @@ -2237,8 +2238,10 @@ int8_t handle_midi_learn(int8_t note) { LCDML.OTHER_jumpToFunc(UI_func_drum_vol_min_max); } else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_drum_midi_note)) { ret_channel = configuration.drums.midi_channel; - if (midi_learn_mode & 0x80) + if (midi_learn_mode & 0x80) { + configuration.drums.midinote[active_sample] = midinote_old[active_sample]; active_sample = get_drums_id_by_note(note); + } else configuration.drums.midinote[active_sample] = note; midi_learn_mode |= note; LCDML.OTHER_jumpToFunc(UI_func_drum_midi_note); } else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_drum_pitch)) { diff --git a/UI.hpp b/UI.hpp index 17c5e59..2d69d25 100644 --- a/UI.hpp +++ b/UI.hpp @@ -132,6 +132,7 @@ extern uint8_t midi_bpm; extern bool save_sys_flag; extern elapsedMillis save_sys; extern bool save_sys_flag; +extern uint8_t midinote_old[NUM_DRUMSET_CONFIG]; /*********************************************************************** GLOBAL @@ -4427,7 +4428,6 @@ void UI_func_drum_midi_note(uint8_t param) { } #else static bool display_name; - static uint8_t midinote_old[NUM_DRUMSET_CONFIG]; static int8_t ask_before_quit_mode; char tmp_val[4]; @@ -4441,7 +4441,7 @@ void UI_func_drum_midi_note(uint8_t param) { midinote_old[i] = configuration.drums.midinote[i]; if (display_name) - midi_learn_mode = MIDI_LEARN_MODE_ON| 0x80; + midi_learn_mode = MIDI_LEARN_MODE_ON | 0x80; else midi_learn_mode = MIDI_LEARN_MODE_ON; @@ -4488,8 +4488,10 @@ void UI_func_drum_midi_note(uint8_t param) { LCDML.loop_menu(); } else { if (display_name == true) { - if (active_sample < NUM_DRUMSET_CONFIG - 2) + if (active_sample < NUM_DRUMSET_CONFIG - 2) { + configuration.drums.midinote[active_sample] = midinote_old[active_sample]; active_sample++; + } } else configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] + ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); } @@ -4504,8 +4506,10 @@ void UI_func_drum_midi_note(uint8_t param) { LCDML.loop_menu(); } else { if (display_name == true) { - if (active_sample > 0) + if (active_sample > 0) { + configuration.drums.midinote[active_sample] = midinote_old[active_sample]; active_sample--; + } } else configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] - ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); } @@ -4533,9 +4537,8 @@ void UI_func_drum_midi_note(uint8_t param) { LCDML.OTHER_updateFunc(); LCDML.loop_menu(); } - } else { + } else display_name = !display_name; - } } }