Merge branch 'dev' of https://codeberg.org/dcoredump/MicroDexed into dev
commit
c2ce0c270d
@ -0,0 +1,103 @@ |
|||||||
|
|
||||||
|
#include "config.h" |
||||||
|
#include "sequencer.h" |
||||||
|
#include <LCDMenuLib2.h> |
||||||
|
#include <LiquidCrystal_I2C.h> |
||||||
|
|
||||||
|
extern LCDMenuLib2 LCDML; |
||||||
|
extern LiquidCrystal_I2C lcd; |
||||||
|
extern config_t configuration; |
||||||
|
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); |
||||||
|
|
||||||
|
void sequencer() |
||||||
|
{ |
||||||
|
bool seq_noteoffsent = false; |
||||||
|
|
||||||
|
if (seq_note_in > 0 && seq_recording == false && seq_active_track == 3 && seq_note_in < 71) { |
||||||
|
handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer] + seq_transpose , 0); |
||||||
|
handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer - 1] + seq_transpose , 0); |
||||||
|
|
||||||
|
seq_transpose = seq_note_in - 6 * 12 + 3; |
||||||
|
seq_note_in = 0; |
||||||
|
} |
||||||
|
|
||||||
|
if (seq_millis_timer > seq_timer_previous + 136) |
||||||
|
|
||||||
|
{ |
||||||
|
seq_timer_previous = seq_millis_timer; |
||||||
|
|
||||||
|
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_sequencer)) { |
||||||
|
|
||||||
|
//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"); |
||||||
|
if (seq_step_timer == 0) { |
||||||
|
lcd.setCursor(15, 1); |
||||||
|
lcd.print(seq_find_shortname(15)); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
lcd.setCursor(seq_step_timer - 1, 1); |
||||||
|
lcd.print(seq_find_shortname(seq_step_timer - 1)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//loop for drum track 0-2
|
||||||
|
|
||||||
|
for (uint8_t d = 0; d < 3; d++) |
||||||
|
{ |
||||||
|
if (seq_data[ seq_patternchain[0][d] ][seq_step_timer] > 0 && seq_vel[ seq_patternchain[0][d] ][seq_step_timer] > 0) |
||||||
|
{ |
||||||
|
handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[ seq_patternchain[0][d] ][seq_step_timer] , seq_vel[ seq_patternchain[0][d] ][seq_step_timer]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// instrument track
|
||||||
|
if (seq_data[ seq_patternchain[0][3] ][seq_step_timer] > 0) //test instrument sequencer Instance=0
|
||||||
|
{ |
||||||
|
handleNoteOn(configuration.dexed[0].midi_channel, seq_data[ seq_patternchain[0][3] ][seq_step_timer] + seq_transpose , seq_vel[ seq_patternchain[0][3] ][seq_step_timer]); |
||||||
|
} |
||||||
|
|
||||||
|
seq_noteoffsent = false; |
||||||
|
seq_step_timer++; |
||||||
|
|
||||||
|
if (seq_step_timer > 15) { |
||||||
|
seq_step_timer = 0; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
if (seq_millis_timer > seq_timer_previous + 80 && seq_noteoffsent == false) |
||||||
|
|
||||||
|
{ |
||||||
|
if (seq_step_timer > 0) { |
||||||
|
if (seq_data[ seq_patternchain[0][3] ][seq_step_timer - 1] > 0) //test instrument sequencer Instance=0
|
||||||
|
{ |
||||||
|
handleNoteOff(configuration.dexed[0].midi_channel, seq_data[ seq_patternchain[0][3] ][seq_step_timer - 1] + seq_transpose , 0); |
||||||
|
} |
||||||
|
} else |
||||||
|
{ |
||||||
|
if (seq_step_timer == 0) { |
||||||
|
if (seq_data[ seq_patternchain[0][3] ][15] > 0) //test instrument sequencer Instance=0
|
||||||
|
{ |
||||||
|
handleNoteOff(configuration.dexed[0].midi_channel, seq_data[ seq_patternchain[0][3] ][15] + seq_transpose , 0); |
||||||
|
; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
seq_noteoffsent = true; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
|
||||||
|
uint8_t seq_active_track = 0; |
||||||
|
uint8_t seq_menu; |
||||||
|
bool seq_button_r = false; |
||||||
|
bool seq_noteoffsent = false; |
||||||
|
elapsedMillis seq_millis_timer; |
||||||
|
uint8_t seq_step_timer = 0; |
||||||
|
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_chain_select_menu; |
||||||
|
uint8_t seq_chain_active_menu = 99; |
||||||
|
uint8_t seq_chain_active_chainstep; |
||||||
|
uint8_t seq_lenght=1; // 1=16 steps, 2=32 Steps, 3=46 Steps, 4=64 Steps
|
||||||
|
|
||||||
|
uint8_t seq_data[9][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, |
||||||
|
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, |
||||||
|
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 |
||||||
|
}; |
||||||
|
uint8_t seq_vel[9][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, |
||||||
|
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, |
||||||
|
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, |
||||||
|
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, |
||||||
|
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, |
||||||
|
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 |
||||||
|
}; |
||||||
|
|
||||||
|
//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
|
||||||
|
// };
|
||||||
|
|
||||||
|
uint8_t seq_patternchain[4][4] = { 0, 1, 2, 3, |
||||||
|
0, 4, 2, 5, |
||||||
|
0, 1, 2, 7, |
||||||
|
0, 1, 3, 6 |
||||||
|
}; |
Loading…
Reference in new issue