Global sequencer data is now inside the struct

pull/112/head
Holger Wirtz 3 years ago
parent 33e54c1079
commit 213160d30f
  1. 56
      MicroDexed.ino
  2. 1046
      UI.hpp
  3. 169
      dexed_sd.cpp
  4. 13
      midi_devices.hpp
  5. 183
      sequencer.cpp
  6. 168
      sequencer.h

@ -338,8 +338,8 @@ elapsedMillis midi_decay_timer;
#endif #endif
#if NUM_DEXED>1 #if NUM_DEXED>1
int perform_attack_mod[NUM_DEXED] = { 0, 0}; int perform_attack_mod[NUM_DEXED] = { 0, 0 };
int perform_release_mod[NUM_DEXED] = { 0, 0}; int perform_release_mod[NUM_DEXED] = { 0, 0 };
#else #else
int perform_attack_mod[NUM_DEXED] = { 0 }; int perform_attack_mod[NUM_DEXED] = { 0 };
int perform_release_mod[NUM_DEXED] = { 0 }; int perform_release_mod[NUM_DEXED] = { 0 };
@ -350,6 +350,7 @@ int16_t delayline[NUM_DEXED][MOD_DELAY_SAMPLE_BUFFER];
#endif #endif
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
extern sequencer_t seq;
extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; extern drum_config_t drum_config[NUM_DRUMSET_CONFIG];
uint8_t drum_counter; uint8_t drum_counter;
uint8_t drum_type[NUM_DRUMS]; uint8_t drum_type[NUM_DRUMS];
@ -363,7 +364,6 @@ extern LCDMenuLib2 LCDML;
extern void getNoteName(char* noteName, uint8_t noteNumber); extern void getNoteName(char* noteName, uint8_t noteNumber);
PeriodicTimer timer1; PeriodicTimer timer1;
extern char seq_chord_names[7][4];
/*********************************************************************** /***********************************************************************
SETUP SETUP
@ -564,7 +564,7 @@ void setup()
} }
// Start timer (to avoid a crash when loading the performance data) // Start timer (to avoid a crash when loading the performance data)
timer1.begin(sequencer, seq_tempo_ms / 2, false); timer1.begin(sequencer, seq.seq_tempo_ms / 2, false);
// Load initial Performance or the last used one // Load initial Performance or the last used one
initial_values(false); initial_values(false);
@ -619,7 +619,7 @@ void setup()
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
master_mixer_r.gain(2, VOL_MAX_FLOAT); master_mixer_r.gain(2, VOL_MAX_FLOAT);
master_mixer_l.gain(2, VOL_MAX_FLOAT); master_mixer_l.gain(2, VOL_MAX_FLOAT);
drums_volume = VOL_MAX_FLOAT; seq.drums_volume = VOL_MAX_FLOAT;
#else #else
master_mixer_r.gain(2, 0.0); master_mixer_r.gain(2, 0.0);
master_mixer_l.gain(2, 0.0); master_mixer_l.gain(2, 0.0);
@ -646,7 +646,7 @@ void setup()
Serial.println(F("<setup end>")); Serial.println(F("<setup end>"));
#endif #endif
strcpy(seq_name, "INIT Perf"); strcpy(seq.seq_name, "INIT Perf");
LCDML.OTHER_jumpToFunc(UI_func_voice_select); LCDML.OTHER_jumpToFunc(UI_func_voice_select);
} }
@ -663,34 +663,34 @@ void loop()
LCDML.loop(); LCDML.loop();
#endif #endif
if (seq_running) if (seq.seq_running)
{ {
if (seq_step != seq_UI_last_step) if (seq.seq_step != seq_UI_last_step)
{ {
seq_UI_last_step = seq_step; seq_UI_last_step = seq.seq_step;
if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor)) //is in UI of Sequencer if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor)) //is in UI of Sequencer
{ {
lcd.setCursor(seq_step, 1); lcd.setCursor(seq.seq_step, 1);
lcd.write(124); lcd.write(124);
if (seq_step == 0) if (seq.seq_step == 0)
{ {
lcd.setCursor(15, 1); lcd.setCursor(15, 1);
lcd.print(seq_find_shortname(15)[0]); lcd.print(seq_find_shortname(15)[0]);
} }
else else
{ {
lcd.setCursor(seq_step - 1, 1); lcd.setCursor(seq.seq_step - 1, 1);
lcd.print(seq_find_shortname(seq_step - 1)[0]); lcd.print(seq_find_shortname(seq.seq_step - 1)[0]);
} }
} }
else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_arpeggio)) //is in UI of Arpeggiator else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_arpeggio)) //is in UI of Arpeggiator
{ {
lcd.setCursor(7, 0); lcd.setCursor(7, 0);
lcd.print( seq_chord_names[arp_chord][0]); lcd.print( seq.seq_chord_names[seq.arp_chord][0]);
lcd.print( seq_chord_names[arp_chord][1]); lcd.print( seq.seq_chord_names[seq.arp_chord][1]);
lcd.print( seq_chord_names[arp_chord][2]); lcd.print( seq.seq_chord_names[seq.arp_chord][2]);
lcd.print( seq_chord_names[arp_chord][3]); lcd.print( seq.seq_chord_names[seq.arp_chord][3]);
} }
} }
} }
@ -817,7 +817,7 @@ void loop()
void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity) void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
{ {
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
if (activesample < 6 && seq_running == false && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor) ) // live play pitched sample if (activesample < 6 && seq.seq_running == false && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor) ) // live play pitched sample
{ {
if (drum_counter >= NUM_DRUMS) if (drum_counter >= NUM_DRUMS)
drum_counter = 0; drum_counter = 0;
@ -839,7 +839,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
else else
#endif #endif
//Ignore the note when playing & recording the same note into the sequencer //Ignore the note when playing & recording the same note into the sequencer
if (seq_recording == false || (seq_recording && inNumber != seq_note_in )) if (seq.seq_recording == false || (seq.seq_recording && inNumber != seq.seq_note_in ))
{ {
// Check for MicroDexed // Check for MicroDexed
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
@ -1761,9 +1761,9 @@ void handleStart(void)
midi_bpm_timer = 0; midi_bpm_timer = 0;
midi_bpm_counter = 0; midi_bpm_counter = 0;
_midi_bpm = -1; _midi_bpm = -1;
seq_step = 0; seq.seq_step = 0;
seq_chain_active_step = 0; seq.seq_chain_active_step = 0;
seq_running = true; seq.seq_running = true;
timer1.start(); timer1.start();
} }
@ -1776,11 +1776,11 @@ void handleContinue(void)
void handleStop(void) void handleStop(void)
{ {
timer1.stop(); timer1.stop();
seq_running = false; seq.seq_running = false;
seq_recording = false; seq.seq_recording = false;
seq_note_in = 0; seq.seq_note_in = 0;
seq_step = 0; seq.seq_step = 0;
seq_chain_active_step = 0; seq.seq_chain_active_step = 0;
MicroDexed[0]->panic(); MicroDexed[0]->panic();
#if NUM_DEXED > 1 #if NUM_DEXED > 1
@ -2293,7 +2293,7 @@ void set_fx_params(void)
delay_fx[instance_id]->delay(0, constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10); delay_fx[instance_id]->delay(0, constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10);
if (configuration.fx.delay_sync[instance_id] > 0) if (configuration.fx.delay_sync[instance_id] > 0)
{ {
uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / seq_bpm); uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / seq.seq_bpm);
delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX * 10)); delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX * 10));
} }
// REVERB SEND // REVERB SEND

1046
UI.hpp

File diff suppressed because it is too large Load Diff

@ -33,6 +33,7 @@ using namespace TeensyTimerTool;
#include "dexed_sd.h" #include "dexed_sd.h"
#include "synth_dexed.h" #include "synth_dexed.h"
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
#include "sequencer.h"
#include "drums.h" #include "drums.h"
extern void set_drums_volume(float vol); extern void set_drums_volume(float vol);
extern drum_config_t drum_config[]; extern drum_config_t drum_config[];
@ -43,31 +44,7 @@ extern void check_configuration_dexed(uint8_t instance_id);
extern void check_configuration_performance(void); extern void check_configuration_performance(void);
extern void check_configuration_fx(void); extern void check_configuration_fx(void);
extern void sequencer(); extern void sequencer();
extern float drums_volume; extern sequencer_t seq;
extern uint8_t seq_chain_lenght;
extern uint8_t seq_data[NUM_SEQ_PATTERN][16];
extern uint8_t seq_vel[NUM_SEQ_PATTERN][16];
extern uint8_t seq_patternchain[4][NUM_SEQ_TRACKS];
extern uint8_t seq_content_type[NUM_SEQ_PATTERN];
extern uint8_t seq_track_type[NUM_SEQ_TRACKS];
extern uint8_t seq_chord_key_ammount;
extern uint8_t seq_element_shift;
extern int seq_oct_shift;
extern int seq_transpose;
extern int seq_tempo_ms;
extern int seq_bpm;
extern bool arp_play_basenote;
extern bool seq_running;
extern uint8_t arp_speed;
extern uint8_t arp_lenght;
extern uint8_t arp_style;
extern uint8_t seq_chord_velocity;
extern uint8_t seq_chord_dexed_inst;
extern uint8_t seq_inst_dexed[NUM_SEQ_TRACKS];
extern uint8_t seq_step;
extern uint8_t seq_chain_active_step;
extern char seq_name[FILENAME_LEN];
extern char seq_name_temp[FILENAME_LEN];
extern PeriodicTimer timer1; extern PeriodicTimer timer1;
extern float midi_volume_transform(uint8_t midi_amp); extern float midi_volume_transform(uint8_t midi_amp);
extern void set_sample_note(uint8_t sample, uint8_t note); extern void set_sample_note(uint8_t sample, uint8_t note);
@ -490,8 +467,8 @@ bool load_sd_drumsettings_json(uint8_t number)
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
drums_volume = data_json["drums_volume"]; seq.drums_volume = data_json["drums_volume"];
set_drums_volume(drums_volume); set_drums_volume(seq.drums_volume);
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++)
{ {
uint8_t drumnumber = 0; uint8_t drumnumber = 0;
@ -556,7 +533,7 @@ bool save_sd_drumsettings_json(uint8_t number)
json = SD.open(filename, FILE_WRITE); json = SD.open(filename, FILE_WRITE);
if (json) if (json)
{ {
data_json["drums_volume"] = drums_volume; data_json["drums_volume"] = seq.drums_volume;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++)
{ {
data_json["note"][i] = get_sample_note(i); data_json["note"][i] = get_sample_note(i);
@ -1101,8 +1078,8 @@ bool save_sd_seq_sub_vel_json(uint8_t seq_number)
Serial.print(F(" to ")); Serial.print(F(" to "));
Serial.println(filename); Serial.println(filename);
#endif #endif
int total = sizeof(seq_vel); int total = sizeof(seq.seq_vel);
int columns = sizeof(seq_vel[0]); int columns = sizeof(seq.seq_vel[0]);
int rows = total / columns; int rows = total / columns;
AudioNoInterrupts(); AudioNoInterrupts();
SD.begin(); SD.begin();
@ -1113,7 +1090,7 @@ bool save_sd_seq_sub_vel_json(uint8_t seq_number)
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) { for (uint8_t j = 0; j < columns; j++) {
data_json["seq_velocity"][count] = seq_vel[i][j]; data_json["seq_velocity"][count] = seq.seq_vel[i][j];
count++; count++;
} }
} }
@ -1157,8 +1134,8 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
Serial.print(F(" to ")); Serial.print(F(" to "));
Serial.println(filename); Serial.println(filename);
#endif #endif
int total = sizeof(seq_data); int total = sizeof(seq.seq_data);
int columns = sizeof(seq_data[0]); int columns = sizeof(seq.seq_data[0]);
int rows = total / columns; int rows = total / columns;
AudioNoInterrupts(); AudioNoInterrupts();
SD.begin(); SD.begin();
@ -1169,7 +1146,7 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) { for (uint8_t j = 0; j < columns; j++) {
data_json["seq_data"][count] = seq_data[i][j]; data_json["seq_data"][count] = seq.seq_data[i][j];
count++; count++;
} }
} }
@ -1203,7 +1180,7 @@ bool save_sd_performance_json(uint8_t seq_number)
bool seq_was_running = false; bool seq_was_running = false;
seq_number = constrain(seq_number, VELOCITY_CONFIG_MIN, VELOCITY_CONFIG_MAX); seq_number = constrain(seq_number, VELOCITY_CONFIG_MIN, VELOCITY_CONFIG_MAX);
if (seq_running == true ) { if (seq.seq_running == true ) {
seq_was_running = true; seq_was_running = true;
handleStop(); handleStop();
} }
@ -1240,8 +1217,8 @@ bool save_sd_performance_json(uint8_t seq_number)
Serial.print(F(" to ")); Serial.print(F(" to "));
Serial.println(filename); Serial.println(filename);
#endif #endif
int total = sizeof(seq_patternchain); int total = sizeof(seq.seq_patternchain);
int columns = sizeof(seq_patternchain[0]); int columns = sizeof(seq.seq_patternchain[0]);
int rows = total / columns; int rows = total / columns;
Serial.print(F(" ")); Serial.print(F(" "));
SD.remove(filename); SD.remove(filename);
@ -1257,40 +1234,40 @@ bool save_sd_performance_json(uint8_t seq_number)
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) { for (uint8_t j = 0; j < columns; j++) {
data_json["seq_patternchain"][count] = seq_patternchain[i][j]; data_json["seq_patternchain"][count] = seq.seq_patternchain[i][j];
count++; count++;
} }
} }
count = 0; count = 0;
data_json["seq_tempo_ms"] = seq_tempo_ms ; data_json["seq_tempo_ms"] = seq.seq_tempo_ms ;
data_json["seq_bpm"] = seq_bpm; data_json["seq_bpm"] = seq.seq_bpm;
data_json["arp_play_basenote"] = arp_play_basenote; data_json["arp_play_basenote"] = seq.arp_play_basenote;
data_json["arp_speed"] = arp_speed; data_json["arp_speed"] = seq.arp_speed;
data_json["arp_lenght"] = arp_lenght; data_json["arp_lenght"] = seq.arp_lenght;
data_json["arp_style"] = arp_style; data_json["arp_style"] = seq.arp_style;
data_json["seq_chord_velocity"] = seq_chord_velocity; data_json["seq_chord_velocity"] = seq.seq_chord_velocity;
data_json["seq_chord_dexed_inst"] = seq_chord_dexed_inst; data_json["seq_chord_dexed_inst"] = seq.seq_chord_dexed_inst;
data_json["seq_chain_lenght"] = seq_chain_lenght; data_json["seq_chain_lenght"] = seq.seq_chain_lenght;
data_json["seq_transpose"] = seq_transpose; data_json["seq_transpose"] = seq.seq_transpose;
data_json["chord_key_ammount"] = seq_chord_key_ammount; data_json["chord_key_ammount"] = seq.seq_chord_key_ammount;
data_json["seq_oct_shift"] = seq_oct_shift; data_json["seq_oct_shift"] = seq.seq_oct_shift;
data_json["seq_element_shift"] = seq_element_shift; data_json["seq_element_shift"] = seq.seq_element_shift;
for (uint8_t i = 0; i < MAX_DEXED; i++) for (uint8_t i = 0; i < MAX_DEXED; i++)
{ {
data_json["bank"][i] = configuration.performance.bank[i]; data_json["bank"][i] = configuration.performance.bank[i];
data_json["voice"][i] = configuration.performance.voice[i]; data_json["voice"][i] = configuration.performance.voice[i];
} }
for (uint8_t i = 0; i < sizeof(seq_track_type); i++) { for (uint8_t i = 0; i < sizeof(seq.seq_track_type); i++) {
data_json["track_type"][i] = seq_track_type[i]; data_json["track_type"][i] = seq.seq_track_type[i];
} }
for (uint8_t i = 0; i < sizeof(seq_content_type); i++) { for (uint8_t i = 0; i < sizeof(seq.seq_content_type); i++) {
data_json["content_type"][i] = seq_content_type[i]; data_json["content_type"][i] = seq.seq_content_type[i];
} }
for (uint8_t i = 0; i < sizeof(seq_inst_dexed); i++) { for (uint8_t i = 0; i < sizeof(seq.seq_inst_dexed); i++) {
data_json["seq_inst_dexed"][i] = seq_inst_dexed[i]; data_json["seq_inst_dexed"][i] = seq.seq_inst_dexed[i];
} }
for (uint8_t i = 0; i < FILENAME_LEN; i++) { for (uint8_t i = 0; i < FILENAME_LEN; i++) {
data_json["seq_name"][i] = seq_name[i]; data_json["seq_name"][i] = seq.seq_name[i];
} }
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Write JSON data:")); Serial.println(F("Write JSON data:"));
@ -1363,7 +1340,7 @@ bool check_performance_directory(uint8_t seq_number)
void get_sd_performance_name_json(uint8_t seq_number) void get_sd_performance_name_json(uint8_t seq_number)
{ {
seq_number = constrain(seq_number, 0, 99); seq_number = constrain(seq_number, 0, 99);
memset(seq_name_temp, 0, FILENAME_LEN); memset(seq.seq_name_temp, 0, FILENAME_LEN);
if (sd_card > 0) if (sd_card > 0)
{ {
File json; File json;
@ -1388,7 +1365,7 @@ void get_sd_performance_name_json(uint8_t seq_number)
} }
if (data_json["seq_name"][0] != 0) { if (data_json["seq_name"][0] != 0) {
for (uint8_t i = 0; i < FILENAME_LEN; i++) { for (uint8_t i = 0; i < FILENAME_LEN; i++) {
seq_name_temp[i] = data_json["seq_name"][i]; seq.seq_name_temp[i] = data_json["seq_name"][i];
} }
} }
@ -1432,14 +1409,14 @@ bool load_sd_seq_sub_vel_json(uint8_t seq_number)
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
int total = sizeof(seq_vel); int total = sizeof(seq.seq_vel);
int columns = sizeof(seq_vel[0]); int columns = sizeof(seq.seq_vel[0]);
int rows = total / columns; int rows = total / columns;
int count = 0; int count = 0;
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) { for (uint8_t j = 0; j < columns; j++) {
seq_vel[i][j] = data_json["seq_velocity"][count]; seq.seq_vel[i][j] = data_json["seq_velocity"][count];
count++; count++;
} }
} }
@ -1501,15 +1478,15 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number)
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
int total = sizeof(seq_data); int total = sizeof(seq.seq_data);
int columns = sizeof(seq_data[0]); int columns = sizeof(seq.seq_data[0]);
int rows = total / columns; int rows = total / columns;
int count = 0; int count = 0;
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) { for (uint8_t j = 0; j < columns; j++) {
seq_data[i][j] = data_json["seq_data"][count]; seq.seq_data[i][j] = data_json["seq_data"][count];
count++; count++;
} }
} }
@ -1538,10 +1515,10 @@ bool load_sd_performance_json(uint8_t seq_number)
{ {
bool seq_was_running = false; bool seq_was_running = false;
if (seq_running) if (seq.seq_running)
{ {
seq_was_running = true; seq_was_running = true;
seq_running = false; seq.seq_running = false;
} }
dac_mute(); dac_mute();
handleStop(); handleStop();
@ -1578,52 +1555,52 @@ bool load_sd_performance_json(uint8_t seq_number)
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
int total = sizeof(seq_patternchain); int total = sizeof(seq.seq_patternchain);
int columns = sizeof(seq_patternchain[0]); int columns = sizeof(seq.seq_patternchain[0]);
int rows = total / columns; int rows = total / columns;
int count = 0; int count = 0;
for (uint8_t i = 0; i < rows; i++) for (uint8_t i = 0; i < rows; i++)
{ {
for (uint8_t j = 0; j < columns; j++) for (uint8_t j = 0; j < columns; j++)
{ {
seq_patternchain[i][j] = data_json["seq_patternchain"][count]; seq.seq_patternchain[i][j] = data_json["seq_patternchain"][count];
count++; count++;
} }
} }
for (uint8_t i = 0; i < sizeof(seq_track_type); i++) for (uint8_t i = 0; i < sizeof(seq.seq_track_type); i++)
{ {
seq_track_type[i] = data_json["track_type"][i]; seq.seq_track_type[i] = data_json["track_type"][i];
} }
for (uint8_t i = 0; i < sizeof(seq_content_type); i++) for (uint8_t i = 0; i < sizeof(seq.seq_content_type); i++)
{ {
seq_content_type[i] = data_json["content_type"][i]; seq.seq_content_type[i] = data_json["content_type"][i];
} }
for (uint8_t i = 0; i < sizeof(seq_inst_dexed); i++) for (uint8_t i = 0; i < sizeof(seq.seq_inst_dexed); i++)
{ {
seq_inst_dexed[i] = data_json["seq_inst_dexed"][i]; seq.seq_inst_dexed[i] = data_json["seq_inst_dexed"][i];
} }
if (data_json["seq_name"][0] != 0) if (data_json["seq_name"][0] != 0)
{ {
for (uint8_t i = 0; i < FILENAME_LEN; i++) for (uint8_t i = 0; i < FILENAME_LEN; i++)
{ {
seq_name[i] = data_json["seq_name"][i]; seq.seq_name[i] = data_json["seq_name"][i];
} }
} }
count = 0; count = 0;
seq_tempo_ms = data_json["seq_tempo_ms"] ; seq.seq_tempo_ms = data_json["seq_tempo_ms"] ;
seq_bpm = data_json["seq_bpm"]; seq.seq_bpm = data_json["seq_bpm"];
arp_play_basenote = data_json["arp_play_basenote"]; seq.arp_play_basenote = data_json["arp_play_basenote"];
arp_speed = data_json["arp_speed"] ; seq.arp_speed = data_json["arp_speed"] ;
arp_lenght = data_json["arp_lenght"]; seq.arp_lenght = data_json["arp_lenght"];
arp_style = data_json["arp_style"]; seq.arp_style = data_json["arp_style"];
seq_chord_velocity = data_json["seq_chord_velocity"]; seq.seq_chord_velocity = data_json["seq_chord_velocity"];
seq_chord_dexed_inst = data_json["seq_chord_dexed_inst"] ; seq.seq_chord_dexed_inst = data_json["seq_chord_dexed_inst"] ;
seq_chain_lenght = data_json["seq_chain_lenght"]; seq.seq_chain_lenght = data_json["seq_chain_lenght"];
seq_transpose = data_json["seq_transpose"]; seq.seq_transpose = data_json["seq_transpose"];
seq_chord_key_ammount = data_json["chord_key_ammount"]; seq.seq_chord_key_ammount = data_json["chord_key_ammount"];
seq_oct_shift = data_json["seq_oct_shift"]; seq.seq_oct_shift = data_json["seq_oct_shift"];
seq_element_shift = data_json["seq_element_shift"]; seq.seq_element_shift = data_json["seq_element_shift"];
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
configuration.performance.bank[instance_id] = data_json["bank"][instance_id]; configuration.performance.bank[instance_id] = data_json["bank"][instance_id];
@ -1644,15 +1621,15 @@ bool load_sd_performance_json(uint8_t seq_number)
set_fx_params();*/ set_fx_params();*/
dac_unmute(); dac_unmute();
seq_step = 0; seq.seq_step = 0;
seq_chain_active_step = 0; seq.seq_chain_active_step = 0;
if (seq_was_running) if (seq_was_running)
{ {
timer1.begin(sequencer, seq_tempo_ms / 2); timer1.begin(sequencer, seq.seq_tempo_ms / 2);
seq_running = true; seq.seq_running = true;
} }
else else
timer1.begin(sequencer, seq_tempo_ms / 2, false); timer1.begin(sequencer, seq.seq_tempo_ms / 2, false);
return (true); return (true);
} }
#ifdef DEBUG #ifdef DEBUG

@ -25,10 +25,11 @@
#define MIDI_DEVICES_H #define MIDI_DEVICES_H
#include "config.h" #include "config.h"
#include "sequencer.h"
extern config_t configuration; extern config_t configuration;
extern uint8_t seq_note_in; extern sequencer_t seq;
extern uint8_t seq_note_in_velocity;
/* #if defined(MIDI_DEVICE_USB) /* #if defined(MIDI_DEVICE_USB)
#include <midi_UsbTransport.h> #include <midi_UsbTransport.h>
#endif */ #endif */
@ -83,8 +84,8 @@ void MD_sendControlChange(uint8_t channel, uint8_t cc, uint8_t value);
#ifdef MIDI_DEVICE_DIN #ifdef MIDI_DEVICE_DIN
void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity) void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity)
{ {
seq_note_in=inNumber; seq.seq_note_in=inNumber;
seq_note_in_velocity=inVelocity; seq.seq_note_in_velocity=inVelocity;
handleNoteOn(inChannel, inNumber, inVelocity); handleNoteOn(inChannel, inNumber, inVelocity);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("[MIDI_DIN] NoteOn")); Serial.print(F("[MIDI_DIN] NoteOn"));
@ -584,8 +585,8 @@ void handleSystemReset_MIDI_DEVICE_DIN(void)
#ifdef MIDI_DEVICE_USB_HOST #ifdef MIDI_DEVICE_USB_HOST
void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity) void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity)
{ {
seq_note_in=inNumber; seq.seq_note_in=inNumber;
seq_note_in_velocity=inVelocity; seq.seq_note_in_velocity=inVelocity;
handleNoteOn(inChannel, inNumber, inVelocity); handleNoteOn(inChannel, inNumber, inVelocity);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("[MIDI_USB_HOST] NoteOn")); Serial.print(F("[MIDI_USB_HOST] NoteOn"));

@ -20,167 +20,168 @@ extern float get_sample_vol_max(uint8_t);
extern float get_sample_p_offset(uint8_t); extern float get_sample_p_offset(uint8_t);
boolean interrupt_swapper = false; boolean interrupt_swapper = false;
sequencer_t seq;
void seq_live_recording(void) void seq_live_recording(void)
{ {
//record to sequencer if sequencer menu is active and recording is active //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_seq_pattern_editor)) if (seq.seq_note_in > 0 && seq.seq_recording == true && LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_seq_pattern_editor))
{ {
seq_data[seq_active_track][seq_step] = seq_note_in; seq.seq_data[seq.seq_active_track][seq.seq_step] = seq.seq_note_in;
if ( get_sample_note(activesample) > 209 ) // pitched sample if ( get_sample_note(activesample) > 209 ) // pitched sample
{ {
seq_vel[seq_active_track][seq_step] = get_sample_note(activesample); seq.seq_vel[seq.seq_active_track][seq.seq_step] = get_sample_note(activesample);
} }
else else
seq_vel[seq_active_track][seq_step] = seq_note_in_velocity; seq.seq_vel[seq.seq_active_track][seq.seq_step] = seq.seq_note_in_velocity;
seq_note_in = 0; seq.seq_note_in = 0;
seq_note_in_velocity = 0; seq.seq_note_in_velocity = 0;
} }
} }
void sequencer_part1(void) void sequencer_part1(void)
{ {
//if (seq_note_in > 0 && seq_note_in < 62 && seq_recording == false ) { //if (seq.seq_note_in > 0 && seq.seq_note_in < 62 && seq.seq_recording == false ) {
//handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step] + seq_transpose , 0); //handleNoteOff(configuration.dexed[0].midi_channel, seq.seq_data[3][seq.seq_step] + seq.seq_transpose , 0);
//handleNoteOff(configuration.dexed[0].midi_channel, seq_data[3][seq_step - 1] + seq_transpose , 0); //handleNoteOff(configuration.dexed[0].midi_channel, seq.seq_data[3][seq.seq_step - 1] + seq.seq_transpose , 0);
//if (seq_note_in>65)seq_note_in=seq_note_in-12; //if (seq.seq_note_in>65)seq.seq_note_in=seq.seq_note_in-12;
//seq_transpose = seq_note_in % 12 ; //seq.seq_transpose = seq.seq_note_in % 12 ;
//seq_transpose=seq_transpose-12; //seq.seq_transpose=seq.seq_transpose-12;
//seq_note_in = 0; //seq.seq_note_in = 0;
//} //}
seq_live_recording(); seq_live_recording();
for (uint8_t d = 0; d < NUM_SEQ_TRACKS; d++) for (uint8_t d = 0; d < NUM_SEQ_TRACKS; d++)
{ {
if (seq_patternchain[seq_chain_active_step][d] < NUM_SEQ_PATTERN ) // sequence not empty or muted if (seq.seq_patternchain[seq.seq_chain_active_step][d] < NUM_SEQ_PATTERN ) // sequence not empty or muted
{ {
if ( seq_track_type[d] == 0) if ( seq.seq_track_type[d] == 0)
{ // drum track (drum samples and pitched one-shot samples) { // drum track (drum samples and pitched one-shot samples)
if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 ) if (seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] > 0 )
{ {
if (seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 209) // it is a pitched sample if (seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] > 209) // it is a pitched sample
{ {
// Drum[slot]->setPlaybackRate( pow (2, (inNote - 72) / 12.00) * drum_config[sample].pitch ); get_sample_vol_max(sample) // Drum[slot]->setPlaybackRate( pow (2, (inNote - 72) / 12.00) * drum_config[sample].pitch ); get_sample_vol_max(sample)
set_sample_pitch(seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 , (float)pow (2, (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 72) / 12.00) * get_sample_p_offset( seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 ) ); set_sample_pitch(seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] - 210 , (float)pow (2, (seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] - 72) / 12.00) * get_sample_p_offset( seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] - 210 ) );
handleNoteOn(drum_midi_channel, seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , 90 ); handleNoteOn(drum_midi_channel, seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] , 90 );
} }
else // else play normal drum sample else // else play normal drum sample
handleNoteOn(drum_midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); handleNoteOn(drum_midi_channel, seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] , seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step]);
} }
} }
else { else {
if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] > 0 ) // instrument track if (seq.seq_data[seq.seq_patternchain[seq.seq_chain_active_step][d]][seq.seq_step] > 0 ) // instrument track
{ {
if (seq_track_type[d] == 1 || (seq_track_type[d] == 3 && arp_play_basenote) ) if (seq.seq_track_type[d] == 1 || (seq.seq_track_type[d] == 3 && seq.arp_play_basenote) )
{ {
if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] != 130 ) if (seq.seq_data[seq.seq_patternchain[seq.seq_chain_active_step][d]][seq.seq_step] != 130 )
{ {
handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); handleNoteOn(configuration.dexed[seq.seq_inst_dexed[d]].midi_channel, seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step], seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step]);
seq_prev_note[d] = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; seq.seq_prev_note[d] = seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step];
seq_prev_vel[d] = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; seq.seq_prev_vel[d] = seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step];
} }
} }
else if (seq_track_type[d] == 2 ) //Chords else if (seq.seq_track_type[d] == 2 ) //Chords
{ {
if (seq_vel[ seq_patternchain[seq_chain_active_step][d]][seq_step] > 199) if (seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d]][seq.seq_step] > 199)
{ {
//handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_chord_velocity); // basenote //handleNoteOn(configuration.dexed[seq.seq_inst_dexed[d]].midi_channel, seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step], seq.seq_chord_velocity); // basenote
for (uint8_t x = seq_element_shift; x < seq_element_shift + seq_chord_key_ammount; x++) //play chord notes for (uint8_t x = seq.seq_element_shift; x < seq.seq_element_shift + seq.seq_chord_key_ammount; x++) //play chord notes
{ {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12) + seq_arps[seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200][x], seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] + (seq.seq_oct_shift * 12) + seq.seq_arps[seq.seq_vel[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] - 200][x], seq.seq_chord_velocity);
} }
seq_prev_note[d] = seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] + (seq_oct_shift * 12); seq.seq_prev_note[d] = seq.seq_data[seq.seq_patternchain[seq.seq_chain_active_step][d]][seq.seq_step] + (seq.seq_oct_shift * 12);
seq_prev_vel[d] = seq_vel[seq_patternchain[seq_chain_active_step][d]][seq_step]; seq.seq_prev_vel[d] = seq.seq_vel[seq.seq_patternchain[seq.seq_chain_active_step][d]][seq.seq_step];
} }
} }
if (seq_track_type[d] == 3) { //Arp if (seq.seq_track_type[d] == 3) { //Arp
arp_step = 0; seq.arp_step = 0;
arp_counter = 0; seq.arp_counter = 0;
arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12); seq.arp_note = seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] + (seq.seq_oct_shift * 12);
arp_chord = seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200; seq.arp_chord = seq.seq_vel[seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] - 200;
} }
} }
// after here not triggered by a key input - arp only // after here not triggered by a key input - arp only
if (seq_track_type[d] == 3) if (seq.seq_track_type[d] == 3)
{ //Arp { //Arp
if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) { if (seq.arp_speed == 0 || (seq.arp_speed == 1 && seq.arp_counter == 0) ) {
{ if (arp_style == 0) { //arp up { if (seq.arp_style == 0) { //arp up
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step + seq_element_shift], seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_step + seq.seq_element_shift], seq.seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] ; seq.arp_note_prev = seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_step + seq.seq_element_shift] ;
} }
else if (arp_style == 1) { //arp down else if (seq.arp_style == 1) { //arp down
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift], seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_lenght - seq.arp_step + seq.seq_element_shift], seq.seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift] ; seq.arp_note_prev = seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_lenght - seq.arp_step + seq.seq_element_shift] ;
} }
else if (arp_style == 2) { //arp up & down else if (seq.arp_style == 2) { //arp up & down
if (arp_step <= arp_lenght) { if (seq.arp_step <= seq.arp_lenght) {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step ], seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_step ], seq.seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][arp_step ] ; seq.arp_note_prev = seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_step ] ;
} }
else { else {
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ], seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_lenght * 2 - seq.arp_step ], seq.seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ] ; seq.arp_note_prev = seq.arp_note + seq.seq_arps[seq.arp_chord][seq.arp_lenght * 2 - seq.arp_step ] ;
} }
} }
else if (arp_style == 3) { //arp random else if (seq.arp_style == 3) { //arp random
uint8_t rnd1 = random(arp_lenght); uint8_t rnd1 = random(seq.arp_lenght);
handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12), seq_chord_velocity); handleNoteOn(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note + seq.seq_arps[seq.arp_chord][rnd1 + seq.seq_element_shift] + (seq.seq_oct_shift * 12), seq.seq_chord_velocity);
arp_note_prev = arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12); seq.arp_note_prev = seq.arp_note + seq.seq_arps[seq.arp_chord][rnd1 + seq.seq_element_shift] + (seq.seq_oct_shift * 12);
} }
} }
} }
} }
} }
} }
seq_noteoffsent[d] = false; seq.seq_noteoffsent[d] = false;
} }
arp_counter++; seq.arp_counter++;
seq_step++; seq.seq_step++;
if (arp_speed == 0) // Arp Speed 1/16 if (seq.arp_speed == 0) // Arp Speed 1/16
{ {
arp_step++; seq.arp_step++;
} }
else else
{ {
// Arp Speed 1/8 // Arp Speed 1/8
if (arp_counter > 1) { if (seq.arp_counter > 1) {
arp_counter = 0; seq.arp_counter = 0;
arp_step++; seq.arp_step++;
} }
} }
if (arp_style != 2) { if (seq.arp_style != 2) {
if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght) if ( (seq.arp_step > 1 && seq.seq_arps[seq.arp_chord][seq.arp_step] == 0) || seq.arp_step == seq.arp_lenght)
{ {
arp_step = 0; seq.arp_step = 0;
} }
} }
if (arp_style == 1 || arp_style == 2 ) if (seq.arp_style == 1 || seq.arp_style == 2 )
{ {
if (arp_lenght == 0)arp_lenght = 9; if (seq.arp_lenght == 0)seq.arp_lenght = 9;
} }
if ( arp_style == 2 ) //only for up&down if ( seq.arp_style == 2 ) //only for up&down
{ {
if ( (arp_step > 1 && seq_arps[arp_chord][arp_step] == 0) || arp_step == arp_lenght * 2) if ( (seq.arp_step > 1 && seq.seq_arps[seq.arp_chord][seq.arp_step] == 0) || seq.arp_step == seq.arp_lenght * 2)
{ {
arp_step = 0; seq.arp_step = 0;
} }
} }
if (seq_step > 15) if (seq.seq_step > 15)
{ {
seq_step = 0; seq.seq_step = 0;
if (seq_chain_lenght > 0) { if (seq.seq_chain_lenght > 0) {
seq_chain_active_step++; seq.seq_chain_active_step++;
if (seq_chain_active_step > seq_chain_lenght) if (seq.seq_chain_active_step > seq.seq_chain_lenght)
{ {
seq_chain_active_step = 0; seq.seq_chain_active_step = 0;
} }
} }
} }
@ -191,27 +192,27 @@ void sequencer_part2(void)
seq_live_recording(); seq_live_recording();
for (uint8_t d = 0; d < NUM_SEQ_TRACKS; d++) for (uint8_t d = 0; d < NUM_SEQ_TRACKS; d++)
{ {
if (seq_noteoffsent[d] == false) { if (seq.seq_noteoffsent[d] == false) {
if ( seq_prev_note[d] > 0 && seq_track_type[d] > 0) if ( seq.seq_prev_note[d] > 0 && seq.seq_track_type[d] > 0)
{ {
if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] != 130) if (seq.seq_data[ seq.seq_patternchain[seq.seq_chain_active_step][d] ][seq.seq_step] != 130)
{ {
handleNoteOff(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_prev_note[d] , 0); handleNoteOff(configuration.dexed[seq.seq_inst_dexed[d]].midi_channel, seq.seq_prev_note[d] , 0);
seq_noteoffsent[d] = true; seq.seq_noteoffsent[d] = true;
} }
if (seq_track_type[d] == 2) { //Chords if (seq.seq_track_type[d] == 2) { //Chords
if ( seq_prev_vel[d] > 199) { if ( seq.seq_prev_vel[d] > 199) {
for (uint8_t x = seq_element_shift; x < seq_element_shift + seq_chord_key_ammount; x++) //play chord notes for (uint8_t x = seq.seq_element_shift; x < seq.seq_element_shift + seq.seq_chord_key_ammount; x++) //play chord notes
{ {
handleNoteOff(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_prev_note[d] + seq_arps[seq_prev_vel[d] - 200][x], 0); handleNoteOff(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.seq_prev_note[d] + seq.seq_arps[seq.seq_prev_vel[d] - 200][x], 0);
seq_noteoffsent[d] = true; seq.seq_noteoffsent[d] = true;
} }
} }
} }
else if (seq_track_type[d] == 3) else if (seq.seq_track_type[d] == 3)
{ //Arp { //Arp
handleNoteOff(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note_prev, 0); handleNoteOff(configuration.dexed[seq.seq_chord_dexed_inst].midi_channel, seq.arp_note_prev, 0);
seq_noteoffsent[d] = true; seq.seq_noteoffsent[d] = true;
} }
} }
} }

@ -1,9 +1,11 @@
#ifndef SEQUENCER_H
#define SEQUENCER_H
typedef struct sequencer_s { typedef struct sequencer_s {
float drums_volume; float drums_volume;
uint8_t seq_active_track = 0; uint8_t seq_active_track = 0;
uint8_t seq_menu; uint8_t seq_menu;
bool seq_button_r = false;
#ifdef TEENSY4 #ifdef TEENSY4
bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false, false, false, false, false}; bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false, false, false, false, false};
uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0, 1, 1 , 1, 1 }; uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0, 1, 1 , 1, 1 };
@ -118,168 +120,4 @@ typedef struct sequencer_s {
#endif #endif
} sequencer_t; } sequencer_t;
sequencer_t seq;
float drums_volume;
uint8_t seq_active_track = 0;
uint8_t seq_menu;
bool seq_button_r = false;
#ifdef TEENSY4
bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false, false, false, false, false};
uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0, 1, 1 , 1, 1 };
#else
bool seq_noteoffsent[NUM_SEQ_TRACKS] = {false, false};
uint8_t seq_inst_dexed[NUM_SEQ_TRACKS] = { 0, 0 };
#endif
uint8_t seq_step = 0;
bool seq_running = false;
bool seq_recording = false;
bool smartfilter = true;
uint8_t seq_state_last_loadsave = 200;
char seq_name[FILENAME_LEN];
char seq_name_temp[FILENAME_LEN];
uint8_t seq_note_in;
uint8_t seq_note_in_velocity;
int seq_transpose;
uint8_t seq_chord_dexed_inst = 0;
uint8_t seq_chord_velocity = 60;
uint8_t seq_chord_key_ammount = 4;
uint8_t seq_element_shift = 0;
int seq_oct_shift = 0;
uint8_t arp_style = 0; // up, down, up&down, random
uint8_t seq_arps[6][23] = {
0, 4, 7, 12, 16, 19, 24, 28, 31, 36, 40, 43, 48, 52, 55, 60, 64, 67, 72, 76, 79, 84, 0, //major
0, 3, 7, 12, 15, 19, 24, 27, 31, 36, 39, 43, 48, 51, 55, 60, 63, 67, 72, 75, 79, 84, 0, //minor
0, 4, 7, 10, 12, 16, 19, 22, 24, 28, 31, 34, 36, 40, 43, 46, 48, 52, 55, 58, 60, 64, 0, //seventh
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 0, //augmented
0, 3, 6, 12, 15, 18, 24, 27, 30, 36, 39, 42, 48, 51, 54, 60, 63, 66, 72, 75, 78, 84, 0, //dim
0, 4, 7, 11, 12, 16, 19, 23, 24, 28, 31, 35, 36, 40, 43, 47, 48, 52, 55, 59, 60, 64, 0 //maj7
};
char seq_chord_names[7][4] = { 'M', 'a', 'j', ' ' , //major
'M', 'i', 'n', ' ' ,
's', 'e', 'v', ' ' ,
'a', 'u', 'g', ' ' ,
'd', 'i', 'm', ' ' ,
'M', 'a', 'j', '7' ,
'N', 'o', 'C', 'd' ,
};
char arp_style_names[4][3] = { 'u', 'p', ' ',
'd', 'w', 'n',
'u', '&', 'd',
'R', 'N', 'D',
};
int seq_tempo_ms = 180000;
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_active_step = 0;
uint8_t seq_prev_note[NUM_SEQ_TRACKS]; // note_offs for every (instr.) track
uint8_t seq_prev_vel[NUM_SEQ_TRACKS];
uint8_t arp_step;
uint8_t arp_note;
uint8_t arp_chord = 6;
bool arp_play_basenote = true;
uint8_t arp_note_prev;
uint8_t arp_octave;
uint8_t arp_prev_oct;
uint8_t arp_speed = 0;
uint8_t arp_counter = 0;
uint8_t arp_lenght = 8;
uint8_t seq_data_buffer[16] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
uint8_t seq_data[NUM_SEQ_PATTERN][16] = {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 ,
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[NUM_SEQ_PATTERN][16] = {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,
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_data[10][16] = {69 , 69 , 0 , 69 , 69 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 67 , 67 , 0 , 67 , 67 , 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 ,
// 55 , 0 , 0 , 0 , 0 , 0 , 52 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 57 , 0 , 0 , 0 , 0 , 0 , 53 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 74 , 0 , 0 , 72 , 0 , 0 , 74 , 0 , 0 , 0 , 76 , 0 , 0 , 0 , 0 , 0 ,
// 74 , 0 , 0 , 72 , 0 , 0 , 71 , 0 , 0 , 0 , 67 , 0 , 0 , 0 , 0 , 0 ,
// 69 , 0 , 0 , 76 , 0 , 0 , 69 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
// };
//uint8_t seq_vel[10][16] = {210, 210, 0, 210, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 210, 210, 0, 210, 210, 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,
// 213 , 0 , 0 , 0 , 0 , 0 , 213 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 213 , 0 , 0 , 0 , 0 , 0 , 213 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 211 , 0 , 0 , 211 , 0 , 0 , 211 , 0 , 0 , 0 , 211 , 0 , 0 , 0 , 0 , 0 ,
// 211 , 0 , 0 , 211 , 0 , 0 , 211 , 0 , 0 , 0 , 211 , 0 , 0 , 0 , 0 , 0 ,
// 211 , 0 , 0 , 211 , 0 , 0 , 211 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
// };
//uint8_t seq_data[10][16] = {72 , 0 , 0 , 0 , 72 , 0 , 0 , 0 , 72 , 0 , 0 , 0 , 72 , 0 , 0 , 0 ,
// 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 , 78 ,
// 72 , 0 , 0 , 0 , 72 , 0 , 0 , 0 , 72 , 0 , 0 , 75 , 72 , 0 , 0 , 0 ,
// 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 77 , 0 , 0 ,
// 55 , 0 , 0 , 0 , 0 , 0 , 52 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 57 , 0 , 0 , 0 , 0 , 0 , 53 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
// 74 , 0 , 0 , 72 , 0 , 0 , 74 , 0 , 0 , 0 , 76 , 130 , 130 , 130 , 130 , 0 ,
// 74 , 0 , 0 , 72 , 0 , 0 , 71 , 0 , 0 , 0 , 67 , 130 , 0 , 0 , 0 , 0 ,
// 69 , 0 , 0 , 76 , 0 , 0 , 69 , 130 , 130 , 130 , 0 , 0 , 0 , 0 , 0 , 0
// };
//uint8_t seq_vel[10][16] = {120, 0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0,
// 105, 80, 105, 70, 106, 98, 106, 70, 126, 97, 106, 70, 106, 99, 90, 65,
// 120, 0, 0, 0, 120, 0, 0, 0, 120, 0, 120, 60, 120, 120, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 1, 10, 30, 50, 70, 90, 100, 127, 100, 60, 40, 30, 0, 200,
// 200, 200, 200, 200, 200, 200, 201, 0, 0, 0, 0, 0, 0, 0, 0, 200,
// 201, 200, 200, 200, 200, 200, 200, 200, 0, 0, 0, 0, 0, 0, 0, 0,
// 98, 120, 0, 88, 120, 0, 127, 120, 0, 0, 125, 120, 0, 0, 0, 0,
// 124, 120, 0, 115, 0, 0, 126, 120, 0, 120, 127, 120, 0, 0, 0, 0,
// 123, 120, 0, 110, 120, 0, 90, 120, 0, 0, 0, 0, 0, 0, 0, 0
// };
uint8_t seq_content_type[NUM_SEQ_PATTERN] = { 0, 0, 0, 0 , 0, 0, 0 , 0 , 0 , 0 }; // 0 = track is Drumtrack, 1= Instrumenttrack, 2= Chord or Arpeggio
#ifdef TEENSY4
uint8_t seq_patternchain[4][NUM_SEQ_TRACKS] = { 0 , 2 , 6 , 9 , 99, 99,
1 , 2 , 5 , 8 , 99, 99,
0 , 2 , 6 , 9 , 99, 99,
1 , 2 , 5 , 7 , 99, 99
};
uint8_t seq_track_type[NUM_SEQ_TRACKS] = { 0, 0, 1, 1, 1, 1 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp
#else
uint8_t seq_patternchain[4][NUM_SEQ_TRACKS] = { 0 , 2 ,
1 , 2 ,
0 , 2 ,
1 , 2 ,
};
uint8_t seq_track_type[NUM_SEQ_TRACKS] = { 0, 0 }; // 0 = track is Drumtrack, 1 = Instrumenttrack, 2 = Chord, 3 = Arp
#endif #endif

Loading…
Cancel
Save