Hopefully fixed different states for MIDI learning (especially for learning MIDI drum note).

dev
Holger Wirtz 2 years ago
parent 40c124db0b
commit a0af0a584e
  1. 9
      MicroDexed.ino
  2. 45
      UI.hpp
  3. 7
      config.h

@ -363,7 +363,7 @@ uint8_t midi_voices[NUM_DEXED];
#ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis;
#endif
bool midi_learn_mode = false;
uint8_t midi_learn_mode = MIDI_LEARN_MODE_OFF;
uint32_t cpumax = 0;
uint32_t peak_dexed = 0;
float peak_dexed_value = 0.0;
@ -911,7 +911,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) {
//
// MIDI learn mode
//
if (midi_learn_mode == true) {
if (midi_learn_mode == MIDI_LEARN_MODE_ON || midi_learn_mode == MIDI_LEARN_MODE_NOTE) {
int8_t tmp_channel = handle_midi_learn(inNumber);
if (tmp_channel >= 0)
inChannel = tmp_channel;
@ -1046,7 +1046,7 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity) {
//
// MIDI learn mode
//
if (midi_learn_mode == true) {
if (midi_learn_mode == MIDI_LEARN_MODE_ON || midi_learn_mode == MIDI_LEARN_MODE_NOTE) {
int8_t tmp_channel = handle_midi_learn(inNumber);
if (tmp_channel >= 0)
inChannel = tmp_channel;
@ -2390,7 +2390,10 @@ int8_t handle_midi_learn(int8_t note) {
LCDML.OTHER_jumpToFunc(UI_func_drum_reverb_send);
} else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_drum_midi_note)) {
ret_channel = configuration.drums.midi_channel;
if (midi_learn_mode != MIDI_LEARN_MODE_NOTE)
active_sample = get_drums_id_by_note(note);
else
midi_learn_mode = note;
LCDML.OTHER_jumpToFunc(UI_func_drum_midi_note);
} else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_drum_pitch)) {
ret_channel = configuration.drums.midi_channel;

@ -55,7 +55,7 @@
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
extern bool check_sd_performance_exists(uint8_t number);
extern bool midi_learn_mode;
extern uint8_t midi_learn_mode;
extern uint8_t active_sample;
extern config_t configuration;
@ -1766,7 +1766,7 @@ void UI_func_lowest_note(uint8_t param) {
lcd_active_instance_number(selected_instance_id);
UI_update_instance_icons();
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1794,7 +1794,7 @@ void UI_func_lowest_note(uint8_t param) {
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -1815,7 +1815,7 @@ void UI_func_highest_note(uint8_t param) {
lcd_active_instance_number(selected_instance_id);
UI_update_instance_icons();
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1843,7 +1843,7 @@ void UI_func_highest_note(uint8_t param) {
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -2040,7 +2040,7 @@ void UI_func_epiano_lowest_note(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_R].reset();
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
getNoteName(note_name, configuration.epiano.lowest_note);
display.setCursor(0, 0);
@ -2069,7 +2069,7 @@ void UI_func_epiano_lowest_note(uint8_t param) {
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -2079,7 +2079,7 @@ void UI_func_epiano_highest_note(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_R].reset();
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
getNoteName(note_name, configuration.dexed[selected_instance_id].highest_note);
display.setCursor(0, 0);
@ -2108,7 +2108,7 @@ void UI_func_epiano_highest_note(uint8_t param) {
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -4073,7 +4073,7 @@ void UI_func_drum_pitch(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
memset(tmp_name, ' ', 8);
strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name));
@ -4137,7 +4137,7 @@ void UI_func_drum_pitch(uint8_t param) {
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
encoderDir[ENC_L].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -4152,7 +4152,7 @@ void UI_func_drum_pan(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
memset(tmp_name, ' ', 8);
strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name));
@ -4216,7 +4216,7 @@ void UI_func_drum_pan(uint8_t param) {
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
encoderDir[ENC_L].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -4227,7 +4227,7 @@ void UI_func_drum_reverb_send(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
midi_learn_mode = true;
midi_learn_mode = MIDI_LEARN_MODE_ON;
memset(tmp_name, ' ', 8);
strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name));
@ -4291,7 +4291,7 @@ void UI_func_drum_reverb_send(uint8_t param) {
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
encoderDir[ENC_L].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}
@ -4302,7 +4302,10 @@ void UI_func_drum_midi_note(uint8_t param) {
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
midi_learn_mode = true;
if (!display_name)
midi_learn_mode = MIDI_LEARN_MODE_NOTE;
else
midi_learn_mode = MIDI_LEARN_MODE_ON;
memset(tmp_name, ' ', 8);
strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name));
@ -4320,6 +4323,10 @@ void UI_func_drum_midi_note(uint8_t param) {
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
if (midi_learn_mode > MIDI_LEARN_MODE_NULL)
configuration.drums.midinote[active_sample] = midi_learn_mode;
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 (display_name == true) {
@ -4362,12 +4369,16 @@ void UI_func_drum_midi_note(uint8_t param) {
display.print(tmp_val);
_check_display_name(display_name, 3);
if (!display_name)
midi_learn_mode = MIDI_LEARN_MODE_NOTE;
else
midi_learn_mode = MIDI_LEARN_MODE_ON;
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
encoderDir[ENC_L].reset();
midi_learn_mode = false;
midi_learn_mode = MIDI_LEARN_MODE_OFF;
}
}

@ -952,6 +952,13 @@ enum reverb_mixer_ports {
REVERB_MIX_CH_EPIANO
};
enum midi_learn_modes {
MIDI_LEARN_MODE_OFF,
MIDI_LEARN_MODE_ON,
MIDI_LEARN_MODE_NOTE,
MIDI_LEARN_MODE_NULL
};
#ifndef _MAPFLOAT
#define _MAPFLOAT
inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) {

Loading…
Cancel
Save