From 396150a5b2c1197ba09c50c33cfdba81b7ab4dd9 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sun, 15 Aug 2021 10:02:29 +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 Live recording to sequencer now functions effortless with notes landing on the correct step. Also no more double triggering of notes while recording. --- midi_devices.hpp | 6 +++--- sequencer.cpp | 43 ++++++++++++++++++------------------------- sequencer.h | 4 ++-- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/midi_devices.hpp b/midi_devices.hpp index 07b0c4f..a98481f 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -83,10 +83,10 @@ void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value); #ifdef MIDI_DEVICE_DIN void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity) { - handleNoteOn(inChannel, inNumber, inVelocity); seq_note_in=inNumber; seq_note_in_velocity=inVelocity; -#ifdef DEBUG + handleNoteOn(inChannel, inNumber, inVelocity); + #ifdef DEBUG Serial.print(F("[MIDI_DIN] NoteOn")); #endif if (configuration.sys.soft_midi_thru == 1) @@ -584,9 +584,9 @@ void handleSystemReset_MIDI_DEVICE_DIN(void) #ifdef MIDI_DEVICE_USB_HOST void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity) { - handleNoteOn(inChannel, inNumber, inVelocity); seq_note_in=inNumber; seq_note_in_velocity=inVelocity; + handleNoteOn(inChannel, inNumber, inVelocity); #ifdef DEBUG Serial.print(F("[MIDI_USB_HOST] NoteOn")); #endif diff --git a/sequencer.cpp b/sequencer.cpp index 4e69626..6255758 100644 --- a/sequencer.cpp +++ b/sequencer.cpp @@ -25,18 +25,13 @@ void sequencer_part1(void) //seq_note_in = 0; //} - // if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) { //is in UI of Sequencer - - //write to sequencer if in sequencer menu - // if (seq_note_in > 0 && seq_recording == true) { - // - // // if ( seq_content_type[ seq_patternchain[seq_chain_active_step][active_track] ] == 1) handleNoteOff(configuration.dexed[0].midi_channel, seq_data[active_track][seq_step] + seq_transpose , 0); - // - // seq_data[seq_active_track][seq_step] = seq_note_in; - // seq_vel[seq_active_track][seq_step] = seq_note_in_velocity; - // seq_note_in = 0; - // seq_note_in_velocity = 0; - // } + //record to sequencer if sequencer menu is active and recording is active + if (seq_note_in > 0 && seq_recording == true && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) { + seq_data[seq_active_track][seq_step] = seq_note_in; + seq_vel[seq_active_track][seq_step] = seq_note_in_velocity; + seq_note_in = 0; + seq_note_in_velocity = 0; + } for (uint8_t d = 0; d < 4; d++) { @@ -49,9 +44,9 @@ void sequencer_part1(void) else { if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 && seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0) // instrument track { - if (seq_track_type[d] == 1 || (seq_track_type[d] == 3 && arp_play_basenote) ) + if (seq_track_type[d] == 1 || (seq_track_type[d] == 3 && arp_play_basenote) ) { - handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + seq_transpose , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); + handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + seq_transpose , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); } seq_prev_note[d] = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + seq_transpose; seq_prev_vel[d] = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; @@ -68,22 +63,22 @@ void sequencer_part1(void) arp_step = 0; arp_counter = 0; arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + seq_transpose; - if (seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]-200>=0) - arp_chord = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]-200; + if (seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200 >= 0) + arp_chord = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200; } } } if (seq_track_type[d] == 3) { //Arp if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) { - - if (arp_step % 8 ==0 ) { + + if (arp_step % 8 == 0 ) { handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + arp_octave * 12 , seq_chord_velocity); arp_note_prev = arp_note + arp_octave * 12; } else { if (arp_style == 0) { //arp up - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_chords[arp_chord][arp_step] + arp_octave * 12, seq_chord_velocity); + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_chords[arp_chord][arp_step] + arp_octave * 12, seq_chord_velocity); arp_note_prev = arp_note + seq_chords[arp_chord][arp_step] + arp_octave * 12; } else if (arp_style == 3) { //arp random @@ -95,12 +90,10 @@ void sequencer_part1(void) } } } - seq_noteoffsent[d] = false; } - arp_counter++; + arp_counter++; seq_step++; - if (arp_speed == 0) // Arp Speed 1/16 { arp_step++; @@ -113,11 +106,11 @@ void sequencer_part1(void) arp_counter = 0; arp_step++; } - + } } //if (arp_step > 3 || seq_chords[arp_chord][arp_step] == 0 ) { - if (arp_step > 3 || seq_chords[arp_chord][arp_step] == 0 ) { + if (arp_step > 3 || seq_chords[arp_chord][arp_step] == 0 ) { arp_step = 0; arp_octave++; if (arp_octave >= arp_oct_usersetting) arp_octave = 0; @@ -138,7 +131,7 @@ void sequencer_part2(void) { for (uint8_t d = 0; d < 4; d++) { - if ( seq_noteoffsent[d] == false) { + if (seq_noteoffsent[d] == false) { if ( seq_prev_note[d] > 0 && seq_track_type[d] > 0) { handleNoteOff(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_prev_note[d] , 0); diff --git a/sequencer.h b/sequencer.h index a50aa03..4bef2a2 100644 --- a/sequencer.h +++ b/sequencer.h @@ -41,7 +41,7 @@ int seq_bpm = 102; uint8_t seq_temp_select_menu; uint8_t seq_temp_active_menu = 99; uint8_t seq_chain_active_chainstep; -uint8_t seq_chain_lenght = 3; // 0 = 16 steps, 1 = 32 Steps, 2 = 46 Steps, 3 = 64 Steps +uint8_t seq_chain_lenght = 0; // 0 = 16 steps, 1 = 32 Steps, 2 = 46 Steps, 3 = 64 Steps uint8_t seq_chain_active_step = 0; uint8_t seq_prev_note[4]; // note_offs for every (instr.) track uint8_t seq_prev_vel[4]; @@ -81,7 +81,7 @@ uint8_t seq_vel[10][16] = {120, 0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 120, 0, 0, uint8_t seq_patternchain[4][4] = { 0 , 1 , 6 , 9 , 0 , 1 , 5 , 8 , 0 , 1 , 6 , 9 , 2 , 1 , 5 , 7 }; uint8_t seq_content_type[10] = { 0, 0, 0, 0 , 1, 1, 1 , 1 , 1 , 1 }; // 0 = track is Drumtrack, 1= Instrumenttrack, 2= Chord or Arpeggio -uint8_t seq_track_type[4] = { 0, 0, 3, 1 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp +uint8_t seq_track_type[4] = { 0, 0, 0, 1 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp //uint8_t seq_reverb[4][16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0,