#include "config.h" #include "sequencer.h" #include #include 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 (step recording and live recording) 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_note_in = 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)); } } 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) { handleNoteOn(DRUM_MIDI_CHANNEL, seq_data[2][seq_step_timer] , 99); } if (seq_data[3][seq_step_timer] > 0) //test instrument sequencer Instance=2 { handleNoteOn(configuration.dexed[0].midi_channel, seq_data[3][seq_step_timer] + seq_transpose , 99); } 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[3][seq_step_timer - 1] > 0) //test instrument sequencer Instance=2 { 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 { handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][15] + seq_transpose , 0); ; } } } seq_noteoffsent = true; } }