From 46239291ec12e6b1706b5deeb2562648ab507d66 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Tue, 31 Aug 2021 21:42:16 +0200 Subject: [PATCH] Added Pattern Transpose for Instruments and Pitched Samples --- UI.hpp | 135 +++++++++++++++++++++++++++++++++++++++++++--------- sequencer.h | 1 + 2 files changed, 114 insertions(+), 22 deletions(-) diff --git a/UI.hpp b/UI.hpp index 2c6a962..0ebd2b0 100644 --- a/UI.hpp +++ b/UI.hpp @@ -76,10 +76,10 @@ extern void get_sd_seq_name_json(uint8_t number); extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; extern char seq_name[FILENAME_LEN]; extern char seq_name_temp[FILENAME_LEN]; -extern uint8_t seq_vel[10][16]; -extern uint8_t seq_patternchain[4][4]; -extern uint8_t seq_content_type[10]; -extern uint8_t seq_track_type[4]; +extern uint8_t seq_vel[NUM_SEQ_PATTERN][16]; +extern uint8_t seq_patternchain[NUM_SEQ_TRACKS][4]; +extern uint8_t seq_content_type[NUM_SEQ_PATTERN]; +extern uint8_t seq_track_type[NUM_SEQ_TRACKS]; extern uint8_t seq_step; extern uint8_t seq_chord_key_ammount; extern int seq_tempo_ms; @@ -96,7 +96,7 @@ extern uint8_t seq_temp_active_menu; extern uint8_t seq_chain_active_chainstep; //for editor extern uint8_t seq_chain_active_step; extern int seq_transpose; -extern uint8_t seq_inst_dexed[4]; +extern uint8_t seq_inst_dexed[NUM_SEQ_TRACKS]; extern uint8_t arp_step; extern uint8_t arp_note; extern uint8_t arp_chord; @@ -108,6 +108,7 @@ extern uint8_t seq_element_shift; extern int seq_oct_shift; extern char arp_style_names[4][3]; extern char seq_chord_names[7][4]; +extern uint8_t seq_data_buffer[16]; extern float drums_volume; extern uint8_t drum_midi_channel; uint8_t seq_active_function = 99; @@ -4212,7 +4213,7 @@ const char* seq_find_shortname(uint8_t sstep) { const char* shortname; bool found = false; - if (seq_content_type[seq_active_track] == 0) //is Drumtrack + if (seq_content_type[seq_active_track] == 0 && seq_vel[seq_active_track][sstep] < 210) //is Drumtrack and not a pitched sample { for (uint8_t d = 0; d < NUM_DRUMSET_CONFIG - 1; d++) { @@ -4829,7 +4830,6 @@ void UI_func_seq_pattern_editor(uint8_t param) if (LCDML.FUNC_setup()) // ****** SETUP ********* { lcd.createChar(0, (uint8_t*)special_chars[19]); //play symbol + record symbol switching - #ifdef TESTDISPLAY20x4 lcd.createChar(1, (uint8_t*)special_chars[9]); //bar graph lcd.createChar(2, (uint8_t*)special_chars[10]); //bar graph @@ -4843,8 +4843,6 @@ void UI_func_seq_pattern_editor(uint8_t param) encoderDir[ENC_R].reset(); seq_note_in = 0; // setup function - lcd.setCursor(1, 0); - lcd.show(0, 1, 6, basename(drum_config[activesample].name)); seq_refresh_display_play_status(); #ifdef TESTDISPLAY20x4 lcd.setCursor(18, 0); @@ -4869,7 +4867,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_temp_active_menu = constrain(seq_temp_active_menu - 1, 0, 3); } } - } else if (seq_menu == 32 ) { // is in sub-function - fill pattern + } + else if (seq_menu == 32 ) { // is in sub-function - fill pattern seq_active_function = 97; if (seq_content_type[seq_active_track] == 0) { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) @@ -4881,7 +4880,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_temp_select_menu = constrain(seq_temp_select_menu - 1, 0, NUM_DRUMSET_CONFIG - 1); } } - } else + } + else { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { @@ -4891,7 +4891,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_temp_select_menu = constrain(seq_temp_select_menu - 1, 0, 108 ); } } - } else if (seq_menu == 30 || seq_menu == 31 ) { // is in sub-function - swap pattern or copy pattern + } + else if (seq_menu == 30 || seq_menu == 31 ) { // is in sub-function - swap pattern or copy pattern seq_active_function = 98; if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { @@ -4907,7 +4908,22 @@ void UI_func_seq_pattern_editor(uint8_t param) if (temp_int < 0)temp_int = NUM_SEQ_PATTERN - 1; } } - } else if (seq_active_function == 99) + } + else if (seq_menu == 34 ) { // is in transpose edit + seq_active_function = 94; + if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) + { + if (LCDML.BT_checkDown()) { + temp_int = constrain(temp_int + 1, -36, 36); + if (temp_int > 36)temp_int = 36; + } + else if (LCDML.BT_checkUp()) { + temp_int = constrain(temp_int - 1, -36, 36); + if (temp_int < -36)temp_int = -36; + } + } + } + else if (seq_active_function == 99) { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { @@ -4916,24 +4932,26 @@ void UI_func_seq_pattern_editor(uint8_t param) else if (LCDML.BT_checkUp()) seq_menu = constrain(seq_menu - 1, 0, 18); } - } else if (seq_active_function == 0 ) { + } + else if (seq_active_function == 0 ) { if (seq_content_type[seq_active_track] == 0) // is in Drumedit mode { 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_DRUMSET_CONFIG + 4 ); + activesample = constrain(activesample + 1, 0, NUM_DRUMSET_CONFIG + 5 ); else if (LCDML.BT_checkUp()) - activesample = constrain(activesample - 1, 0, NUM_DRUMSET_CONFIG + 4 ); + activesample = constrain(activesample - 1, 0, NUM_DRUMSET_CONFIG + 5 ); } - } else //is in Instrument Mode + } + else //is in Instrument Mode { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { if (LCDML.BT_checkDown()) - temp_int = constrain(temp_int + 1, 0, 115 ); + temp_int = constrain(temp_int + 1, 0, 116 ); else if (LCDML.BT_checkUp()) - temp_int = constrain(temp_int - 1, 0, 115 ); + temp_int = constrain(temp_int - 1, 0, 116 ); } } } else if (seq_active_function == 2) @@ -4951,14 +4969,24 @@ void UI_func_seq_pattern_editor(uint8_t param) } if (LCDML.BT_checkEnter()) //handle button presses during menu >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> { - if (seq_menu == 32 && seq_active_function == 97) //fill pattern every 1/4, 1/8, 1/16 step with active sample/note step 1 + if (seq_menu == 34 ) //transpose pattern + { + seq_menu = 0; + seq_active_function = 0; + activesample = 0; + temp_int = seq_data[seq_active_track][0]; + lcd.setCursor(8, 0); + lcd.print(" "); + seq_refresh_display_play_status(); + seq_printAllSeqSteps(); + } + else if (seq_menu == 32 && seq_active_function == 97) //fill pattern every 1/4, 1/8, 1/16 step with active sample/note step 1 { seq_active_function = 96; seq_menu = 33; } else if (seq_menu == 33 && seq_active_function == 95) //fill pattern every 1/4, 1/8, 1/16 step with active sample/note step 2 { if (seq_content_type[seq_active_track] == 0) { //Drumtrack - for (uint8_t i = 0; i < 16; i++) { seq_data[seq_active_track][i] = drum_config[seq_temp_select_menu].midinote; @@ -4979,6 +5007,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_active_function = 0; activesample = 0; temp_int = seq_data[seq_active_track][0]; + lcd.setCursor(8, 0); + lcd.print(" "); seq_refresh_display_play_status(); seq_printAllSeqSteps(); } else if (seq_menu == 31) //copy patterns @@ -4990,6 +5020,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_active_function = 0; activesample = 0; temp_int = seq_data[seq_active_track][0]; + lcd.setCursor(8, 0); + lcd.print(" "); seq_refresh_display_play_status(); seq_printAllSeqSteps(); } else if (seq_menu == 30) //swap patterns @@ -5010,6 +5042,8 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_active_function = 0; activesample = 0; temp_int = seq_data[seq_active_track][0]; + lcd.setCursor(8, 0); + lcd.print(" "); seq_refresh_display_play_status(); seq_printAllSeqSteps(); } @@ -5018,6 +5052,19 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_active_function = 0; } else if ( seq_menu == 0 && seq_active_function == 0) { + if ( (seq_content_type[seq_active_track] == 0 && activesample == NUM_DRUMSET_CONFIG + 5) || (seq_content_type[seq_active_track] > 0 && temp_int == 116) ) + { //transpose pattern + lcd.setCursor(0, 0); + lcd.print("Transpose: 00"); + for (uint8_t i = 0; i < 16; i++) + { + seq_data_buffer[i] = seq_data[seq_active_track][i]; + } + seq_menu = 34; + temp_int = 0; + seq_temp_select_menu = 0; + seq_temp_active_menu = 0; + } if ( (seq_content_type[seq_active_track] == 0 && activesample == NUM_DRUMSET_CONFIG + 4) || (seq_content_type[seq_active_track] > 0 && temp_int == 115) ) { //fill patterns lcd.setCursor(0, 0); @@ -5131,7 +5178,44 @@ void UI_func_seq_pattern_editor(uint8_t param) } //button check end <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - if (seq_menu == 33 ) { //fill pattern 2nd parameter + if (seq_menu == 35 ) + { //transpose + ; + } + else if (seq_menu == 34 && seq_active_function == 94) + { //transpose + char displayname[4] = {0, 0, 0, 0}; + lcd.setCursor(10, 0); + if (temp_int > 1) { + lcd.print("+"); + } else if (temp_int < 0) + { + lcd.print("-"); + } + else { + lcd.print(" "); + } + sprintf(displayname, "%02d", abs(temp_int)); + lcd.setCursor(11, 0); + lcd.print( displayname); + for (uint8_t i = 0; i < 16; i++) + { + if (seq_content_type[seq_active_track] == 0) { //drums + if (seq_data_buffer[i] != 0 && seq_data_buffer[i] + temp_int >= 0 && seq_data_buffer[i] + temp_int < 254 + && seq_vel[seq_active_track][i] >= 210 ) // pitched drums only + seq_data[seq_active_track][i] = seq_data_buffer[i] + temp_int; + } + else + //instruments + if (seq_content_type[seq_active_track] > 0) { + if (seq_data_buffer[i] != 0 && seq_data_buffer[i] != 130 && seq_data_buffer[i] + temp_int > 0 && seq_data_buffer[i] + temp_int < 254) + seq_data[seq_active_track][i] = seq_data_buffer[i] + temp_int; + } + } + seq_printAllSeqSteps(); + } + else if (seq_menu == 33) + { //fill pattern 2nd parameter lcd.setCursor(4, 1); lcd.print(" "); lcd.setCursor(9, 1); @@ -5232,6 +5316,10 @@ void UI_func_seq_pattern_editor(uint8_t param) lcd.setCursor(1, 0); lcd.print("Fill P"); } + else if (activesample == NUM_DRUMSET_CONFIG + 5) { + lcd.setCursor(1, 0); + lcd.print("Transp"); + } lcd.setCursor(7, 0); lcd.print("]"); } else //Inst. Mode @@ -5263,6 +5351,9 @@ void UI_func_seq_pattern_editor(uint8_t param) } else if (temp_int == 115) { lcd.setCursor(1, 0); lcd.print("Fill P"); + } else if (temp_int == 116) { + lcd.setCursor(1, 0); + lcd.print("Transp"); } lcd.setCursor(7, 0); lcd.print("]"); diff --git a/sequencer.h b/sequencer.h index 7d37bf5..40b14cc 100644 --- a/sequencer.h +++ b/sequencer.h @@ -64,6 +64,7 @@ uint8_t arp_prev_oct; uint8_t arp_speed = 0; uint8_t arp_counter = 0; uint8_t arp_lenght = 8; +uint8_t seq_data_buffer[16] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; uint8_t seq_data[NUM_SEQ_PATTERN][16] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,