From 362cec9db31fe77b2245c14f0d68841500c58db2 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sat, 31 Jul 2021 17:26:36 +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 Added Velocity Input+Output to Sequencer --- UI.hpp | 17 +++++++++++++++++ drums.h | 2 +- midi_devices.hpp | 3 +++ sequencer.cpp | 35 +++++++++++++++++++---------------- sequencer.h | 15 ++++++++++++++- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/UI.hpp b/UI.hpp index 0426ce0..2c7ccd7 100644 --- a/UI.hpp +++ b/UI.hpp @@ -74,6 +74,7 @@ extern uint8_t seq_active_track; extern elapsedMillis seq_millis_timer; extern uint8_t seq_menu; extern bool seq_button_r; +extern uint8_t seq_reverb[4][16]; #if NUM_DRUMS > 0 #include "drums.h" #endif @@ -3563,6 +3564,21 @@ const char* seq_find_shortname(uint8_t sstep) return shortname; } +// deactivated for now since audio library seems not like to change reverb settings at runtime (and is skipping notes) +//void seq_set_rev_for_single_instr_per_step(uint8_t track, uint8_t note) +//{ +// +// if (track < 3) { +// for (uint8_t d = 0; d < NUM_DRUMCONFIG - 1; d++) +// { +// if (seq_data[track][seq_step_timer] == drum_config[d].midinote) +// { +// drum_config[d].reverb_send = float(seq_reverb[track][seq_step_timer]) / float(100); +// break; +// } +// } +// } +//} void UI_func_sequencer(uint8_t param) { @@ -3638,6 +3654,7 @@ void UI_func_sequencer(uint8_t param) memset(seq_data[0], 0, sizeof(seq_data[0])); memset(seq_data[1], 0, sizeof(seq_data[1])); memset(seq_data[2], 0, sizeof(seq_data[2])); + memset(seq_data[3], 0, sizeof(seq_data[3])); for (int i = 0; i < 16; i++) { lcd.setCursor(i, 1); lcd.print(seq_find_shortname(i) ); diff --git a/drums.h b/drums.h index 0fb91cc..4f9c8ea 100644 --- a/drums.h +++ b/drums.h @@ -164,7 +164,7 @@ drum_config_t drum_config[NUM_DRUMCONFIG] = { 1.0, 0.9, 0.0, - 0.4 + 0.1 }, { DRUM_SNARE, diff --git a/midi_devices.hpp b/midi_devices.hpp index e2f2928..07b0c4f 100644 --- a/midi_devices.hpp +++ b/midi_devices.hpp @@ -28,6 +28,7 @@ extern config_t configuration; extern uint8_t seq_note_in; +extern uint8_t seq_note_in_velocity; /* #if defined(MIDI_DEVICE_USB) #include #endif */ @@ -84,6 +85,7 @@ 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 Serial.print(F("[MIDI_DIN] NoteOn")); #endif @@ -584,6 +586,7 @@ void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVel { handleNoteOn(inChannel, inNumber, inVelocity); seq_note_in=inNumber; + seq_note_in_velocity=inVelocity; #ifdef DEBUG Serial.print(F("[MIDI_USB_HOST] NoteOn")); #endif diff --git a/sequencer.cpp b/sequencer.cpp index a0dbfd8..87a0ee0 100644 --- a/sequencer.cpp +++ b/sequencer.cpp @@ -11,6 +11,7 @@ extern void handleNoteOn(byte , byte , byte ); extern void handleNoteOff(byte , byte , byte ); extern void UI_func_sequencer(uint8_t); extern const char* seq_find_shortname(uint8_t); +extern void seq_set_rev_for_single_instr_per_step(byte, byte); void sequencer() { @@ -31,13 +32,15 @@ void sequencer() if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) { - //write to sequencer if in sequencer menu (step recording and live recording) + //write to sequencer if in sequencer menu if (seq_note_in > 0 && seq_recording == true) { if (seq_active_track == 3) handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer] + seq_transpose , 0); seq_data[seq_active_track][seq_step_timer] = seq_note_in; + seq_vel[seq_active_track][seq_step_timer] = seq_note_in_velocity; seq_note_in = 0; + seq_note_in_velocity=0; } lcd.setCursor(seq_step_timer, 1); lcd.print("X"); @@ -51,21 +54,21 @@ void sequencer() lcd.print(seq_find_shortname(seq_step_timer - 1)); } } - if (seq_data[0][seq_step_timer] > 0) - { - handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[0][seq_step_timer] , 99); - } - if (seq_data[1][seq_step_timer] > 0) - { - handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[1][seq_step_timer] , 99); - } - if (seq_data[2][seq_step_timer] > 0) + + //loop for drum track 0-2 + + for (uint8_t d = 0; d < 3; d++) { - handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[2][seq_step_timer] , 99); + if (seq_data[d][seq_step_timer] > 0 && seq_vel[d][seq_step_timer] > 0) + { + handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[d][seq_step_timer] , seq_vel[d][seq_step_timer]); + } } - if (seq_data[3][seq_step_timer] > 0) //test instrument sequencer Instance=2 + + // instrument track + if (seq_data[3][seq_step_timer] > 0) //test instrument sequencer Instance=0 { - handleNoteOn(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer] + seq_transpose , 99); + handleNoteOn(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer] + seq_transpose , seq_vel[3][seq_step_timer]); } seq_noteoffsent = false; @@ -77,18 +80,18 @@ void sequencer() } - if (seq_millis_timer > seq_timer_previous + 80 && seq_noteoffsent == false) + if (seq_millis_timer > seq_timer_previous + 80 && seq_noteoffsent == false) { if (seq_step_timer > 0) { - if (seq_data[3][seq_step_timer - 1] > 0) //test instrument sequencer Instance=2 + if (seq_data[3][seq_step_timer - 1] > 0) //test instrument sequencer Instance=0 { handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer - 1] + seq_transpose , 0); } } else { if (seq_step_timer == 0) { - if (seq_data[3][15] > 0) //test instrument sequencer Instance=2 + if (seq_data[3][15] > 0) //test instrument sequencer Instance=0 { handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][15] + seq_transpose , 0); ; diff --git a/sequencer.h b/sequencer.h index 4a2bab3..5d3c4ed 100644 --- a/sequencer.h +++ b/sequencer.h @@ -9,9 +9,22 @@ uint32_t seq_timer_previous = 0; bool seq_running = false; bool seq_recording = false; uint8_t seq_note_in; +uint8_t seq_note_in_velocity; int seq_transpose; -uint8_t seq_data[4][16] = {72, 0, 0, 0, 72, 0, 0, 0, 72, 0, 0, 0, 72, 0, 0, 0, +uint8_t seq_data[4][16] = {72, 0, 0, 0, 72, 0, 0, 72, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 45, 45, 57, 57, 45, 45, 57, 57, 45, 45, 57, 57, 45, 45, 57, 57, + }; +uint8_t seq_vel[4][16] = {128, 0, 0, 0, 108, 0, 0, 33, 117, 0, 0, 0, 109, 0, 0, 0, + 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, + 78, 58, 88, 48, 78, 38, 78, 78, 68, 48, 68, 48, 88, 48, 78, 48, + 85, 45, 87, 27, 2, 6, 5, 37, 7, 45, 33, 37, 5, 35, 2, 27, + }; + +//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, +// 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 +//};