You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.2 KiB
103 lines
3.2 KiB
|
|
#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(void)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
|