From 862db5835afef4354f992a70c9d04991e00d1c56 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sun, 25 Jul 2021 21:19:13 +0200 Subject: [PATCH] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MicroDexed.ino | 64 ++++++++++++++-- UI.hpp | 189 ++++++++++++++++++++++++++--------------------- drums.h | 4 +- midi_devices.hpp | 4 +- 4 files changed, 168 insertions(+), 93 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 069dddf..818a0b7 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -268,6 +268,7 @@ int16_t _midi_bpm = -1; elapsedMillis midi_bpm_timer; elapsedMillis long_button_pressed; elapsedMillis control_rate; +elapsedMillis sequencer_timer; uint8_t active_voices[NUM_DEXED]; uint8_t midi_voices[NUM_DEXED]; #ifdef SHOW_CPU_LOAD_MSEC @@ -288,7 +289,17 @@ 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; - +uint8_t seqsteptimer = 0; +uint32_t seqtimer_old = 0; +bool seq_running = false; +bool seq_recording = false; +uint8_t seq_note_in; +//uint8_t seqdata[1][16]={48,48,54,48,49,54,54,48,54,54,48,54,49,54,54,54}; +//uint8_t seqdata[1][16]={72,72,78,72,75,78,78,72,78,78,72,78,75,78,78,78}; +uint8_t seqdata[3][16] = {72, 72, 0, 72, 75, 0, 0, 72, 0, 0, 72, 0, 75, 0, 0, 0, + 73, 73, 0, 73, 0, 0, 73, 73, 0, 0, 73, 73, 0, 0, 0, 0, + 78, 0, 0, 78, 0, 0, 78, 0, 78, 78, 0, 0, 0, 0, 0, 0 + }; #ifdef TEENSY4 #if NUM_DEXED>1 int8_t midi_decay[NUM_DEXED] = { -1, -1}; @@ -316,10 +327,6 @@ extern uint8_t drum_type[NUM_DRUMS]; extern drum_config_t drum_config[NUM_DRUMCONFIG]; #endif -uint8_t seqdata[3][16]; -uint8_t seqsteptimer; -bool seq_running; - #ifdef ENABLE_LCD_UI extern LCDMenuLib2 LCDML; #endif @@ -603,6 +610,53 @@ void loop() ENCODER[ENC_L].update(); ENCODER[ENC_R].update(); + if (seq_running) { + + if (sequencer_timer > seqtimer_old + 125) + + { + seqtimer_old = sequencer_timer; + + if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) { + + + //write to sequencer if in sequencer menu (step recording and live recording) + if (seq_note_in>0 && seq_recording == true){ + seqdata[active_seq_track][seqsteptimer]=seq_note_in; + seq_note_in=0; + } + lcd.setCursor(seqsteptimer, 1); + lcd.print("X"); + if (seqsteptimer == 0) { + lcd.setCursor(15, 1); + lcd.print(seq_find_shortname(15)); + } + else + { + lcd.setCursor(seqsteptimer - 1, 1); + lcd.print(seq_find_shortname(seqsteptimer - 1)); + } + } + if (seqdata[0][seqsteptimer] > 0) + { + handleNoteOn(DRUM_MIDI_CHANNEL, seqdata[0][seqsteptimer] , 99); + } + if (seqdata[1][seqsteptimer] > 0) + { + handleNoteOn(DRUM_MIDI_CHANNEL, seqdata[1][seqsteptimer] , 99); + } + if (seqdata[2][seqsteptimer] > 0) + { + handleNoteOn(DRUM_MIDI_CHANNEL, seqdata[2][seqsteptimer] , 99); + } + seqsteptimer++; + + if (seqsteptimer > 15) { + seqsteptimer = 0; + } + + } + } #ifdef ENABLE_LCD_UI LCDML.loop(); #endif diff --git a/UI.hpp b/UI.hpp index 19f048c..1ca7524 100644 --- a/UI.hpp +++ b/UI.hpp @@ -66,6 +66,7 @@ extern char receive_bank_filename[FILENAME_LEN]; extern uint8_t seqdata[3][16]; extern uint8_t seqsteptimer; extern bool seq_running; +extern bool seq_recording; uint8_t seq_active_function = 99; uint8_t activesample; #if NUM_DRUMS > 0 @@ -638,7 +639,7 @@ void lcdml_menu_control(void) #endif encoderDir[ENC_R].ButtonShort(true); seq_button_r = true; - //nexus + LCDML.BT_enter(); } } @@ -3533,47 +3534,59 @@ void UI_handle_OP(uint8_t param) } } + +const char* seq_find_shortname(uint8_t seqstep) +{ + const char* shortname = " "; + bool found = false; + for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) + { + if (seqdata[active_seq_track][seqstep] == drum_config[d].midinote) + { + shortname = drum_config[d].shortname; + found = true; + break; + } + } + if (found == false) shortname = "-"; + + return shortname; +} + + void UI_func_sequencer(uint8_t param) { - bool foundsound = false; + char displayname[9]; if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); seq_button_r = false; + seq_note_in = 0; // setup function lcd.setCursor(1, 0); - strcpy(displayname, drum_config[activesample].filename); - lcd.print(*displayname + 5); - lcd.setCursor(8, 0); - lcd.print("["); + strncpy(displayname, drum_config[activesample].filename + 5, 6); + lcd.print(displayname); lcd.setCursor(9, 0); - if (seq_running) + if (seq_running == false && seq_recording == false) + { + lcd.print("PLY"); + } else if (seq_running == true && seq_recording == false) { + seq_note_in = 0; + lcd.print("REC"); + } else if (seq_running == true && seq_recording == true) + { + seq_note_in = 0; lcd.print("STP"); } - else { - lcd.print("RUN"); - } - lcd.setCursor(12, 0); - lcd.print("]"); lcd.setCursor(14, 0); lcd.print(active_seq_track + 1); lcd.setCursor(10, 0); for (int i = 0; i < 16; i++) { lcd.setCursor(i, 1); - for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) - { - if (seqdata[active_seq_track][i] == drum_config[d].midinote) - { - lcd.print(drum_config[d].shortname ); //one letter name of Category - foundsound = true; - break; - } - } - if (foundsound == false)lcd.print("-"); - foundsound = false; + lcd.print(seq_find_shortname(i) ); } } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -3591,9 +3604,9 @@ void UI_func_sequencer(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { if (LCDML.BT_checkDown()) - activesample = constrain(activesample + 1, 0, NUM_DRUMCONFIG - 1 ); + activesample = constrain(activesample + 1, 0, NUM_DRUMCONFIG + 2 ); else if (LCDML.BT_checkUp()) - activesample = constrain(activesample - 1, 0, NUM_DRUMCONFIG - 1 ); + activesample = constrain(activesample - 1, 0, NUM_DRUMCONFIG + 2 ); } } else if (seq_active_function == 2) { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) @@ -3612,25 +3625,52 @@ void UI_func_sequencer(uint8_t param) seq_active_function = 0; } else if ( seq_menu == 0 && seq_active_function == 0) { + if (activesample == NUM_DRUMCONFIG + 2) { + memset(seqdata[0], 0, sizeof(seqdata[0])); + memset(seqdata[1], 0, sizeof(seqdata[1])); + memset(seqdata[2], 0, sizeof(seqdata[2])); + for (int i = 0; i < 16; i++) { + lcd.setCursor(i, 1); + lcd.print(seq_find_shortname(i) ); + } + + } else if (activesample == NUM_DRUMCONFIG + 1) { + memset(seqdata[active_seq_track], 0, sizeof(seqdata[active_seq_track])); + for (int i = 0; i < 16; i++) { + lcd.setCursor(i, 1); + lcd.print(seq_find_shortname(i) ); + } + } seq_active_function = 99; } if ( seq_menu == 1) { lcd.setCursor(9, 0); - if (seq_running == true) - { - seq_running = false; - lcd.print("RUN"); - } else + + if (seq_running == false && seq_recording == false) { seq_running = true; - lcd.print("STP"); - } + lcd.print("REC"); + } else + + if (seq_running == true && seq_recording == false) + { + seq_running = true; + seq_recording = true; + seq_note_in = 0; + lcd.print("STP"); + } else if (seq_running == true && seq_recording == true) + { + seq_running = false; + seq_recording = false; + seq_note_in = 0; + lcd.print("PLY"); + } + } else if ( seq_menu == 2) { if (seq_active_function != 2) seq_active_function = 2; else seq_active_function = 99; - } - if (seq_menu > 2) + } else if (seq_menu > 2) { if (seq_active_function == 99) { seqdata[active_seq_track][seq_menu - 3] = drum_config[activesample].midinote; @@ -3647,9 +3687,21 @@ void UI_func_sequencer(uint8_t param) lcd.print(" "); lcd.setCursor(0, 0); lcd.print("["); - lcd.setCursor(1, 0); - strcpy(displayname, drum_config[activesample].filename); - lcd.print(*displayname + 5); + + if (activesample < NUM_DRUMCONFIG) { + lcd.setCursor(1, 0); + strncpy(displayname, drum_config[activesample].filename + 5, 6); + lcd.print(displayname); + } else if (activesample == NUM_DRUMCONFIG) { + lcd.setCursor(1, 0); + lcd.print("EMPTY "); + } else if (activesample == NUM_DRUMCONFIG + 1) { + lcd.setCursor(1, 0); + lcd.print("ClrTrk"); + } else if (activesample == NUM_DRUMCONFIG + 2) { + lcd.setCursor(1, 0); + lcd.print("ClrAll"); + } lcd.setCursor(7, 0); lcd.print("]"); } @@ -3665,13 +3717,19 @@ void UI_func_sequencer(uint8_t param) lcd.setCursor(8, 0); lcd.print("["); lcd.setCursor(9, 0); - if (seq_running) + + if (seq_running == false && seq_recording == false) { + lcd.print("PLY"); + } else if (seq_running == true && seq_recording == false) + { + seq_note_in = 0; + lcd.print("REC"); + } else if (seq_running == true && seq_recording == true) + { + seq_note_in = 0; lcd.print("STP"); } - else { - lcd.print("RUN"); - } lcd.setCursor(12, 0); lcd.print("]"); } @@ -3689,17 +3747,7 @@ void UI_func_sequencer(uint8_t param) lcd.setCursor(0, 1); for (int i = 0; i < 16; i++) { lcd.setCursor(i, 1); - for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) - { - if (seqdata[active_seq_track][i] == drum_config[d].midinote) - { - lcd.print(drum_config[d].shortname ); //one letter name of Category - foundsound = true; - break; - } - } - if (foundsound == false)lcd.print("-"); - foundsound = false; + lcd.print(seq_find_shortname(i) ); } } if (seq_menu == 3) { @@ -3710,45 +3758,16 @@ void UI_func_sequencer(uint8_t param) lcd.setCursor(0, 1); lcd.print("x"); lcd.setCursor(1, 1); - for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) - { - if (seqdata[active_seq_track][1] == drum_config[d].midinote) - { - lcd.print(drum_config[d].shortname ); //one letter name of Category - foundsound = true; - break; - } - } - if (foundsound == false) lcd.print("-"); - foundsound = false; + lcd.print(seq_find_shortname(1) ); } if (seq_menu > 3) { lcd.setCursor(seq_menu - 3, 1); lcd.print("x"); lcd.setCursor(seq_menu - 4, 1); - for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) - { - if (seqdata[active_seq_track][seq_menu - 4] == drum_config[d].midinote) - { - lcd.print(drum_config[d].shortname ); //one letter name of Category - foundsound = true; - break; - } - } - if (foundsound == false) lcd.print("-"); - foundsound = false; + lcd.print(seq_find_shortname(seq_menu - 4) ); lcd.setCursor(seq_menu - 2, 1); - for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) - { - if (seqdata[active_seq_track][seq_menu - 2] == drum_config[d].midinote) - { - lcd.print(drum_config[d].shortname ); //one letter name of Category - foundsound = true; - break; - } - } - if (foundsound == false) lcd.print("-"); - foundsound = false; + lcd.print(seq_find_shortname(seq_menu - 2) ); + } } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/drums.h b/drums.h index 2a1e517..7683bf6 100644 --- a/drums.h +++ b/drums.h @@ -166,8 +166,8 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { 0.6, 0.0 }, - { - DRUM_SNARE, + { + DRUM_NONE, 0, "/drm/EMPTY ", "-", diff --git a/midi_devices.hpp b/midi_devices.hpp index d87ec3a..e2f2928 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -27,7 +27,7 @@ #include "config.h" extern config_t configuration; - +extern uint8_t seq_note_in; /* #if defined(MIDI_DEVICE_USB) #include #endif */ @@ -83,6 +83,7 @@ void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value); void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity) { handleNoteOn(inChannel, inNumber, inVelocity); + seq_note_in=inNumber; #ifdef DEBUG Serial.print(F("[MIDI_DIN] NoteOn")); #endif @@ -582,6 +583,7 @@ void handleSystemReset_MIDI_DEVICE_DIN(void) void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity) { handleNoteOn(inChannel, inNumber, inVelocity); + seq_note_in=inNumber; #ifdef DEBUG Serial.print(F("[MIDI_USB_HOST] NoteOn")); #endif