|
|
@ -45,11 +45,11 @@ extern void sequencer(); |
|
|
|
extern float drums_volume; |
|
|
|
extern float drums_volume; |
|
|
|
//extern StaticJsonDocument<JSON_BUFFER> data_json;
|
|
|
|
//extern StaticJsonDocument<JSON_BUFFER> data_json;
|
|
|
|
extern uint8_t seq_chain_lenght; |
|
|
|
extern uint8_t seq_chain_lenght; |
|
|
|
extern uint8_t seq_data[10][16]; |
|
|
|
extern uint8_t seq_data[NUM_SEQ_PATTERN][16]; |
|
|
|
extern uint8_t seq_vel[10][16]; |
|
|
|
extern uint8_t seq_vel[NUM_SEQ_PATTERN][16]; |
|
|
|
extern uint8_t seq_patternchain[4][4]; |
|
|
|
extern uint8_t seq_patternchain[NUM_SEQ_TRACKS][4]; |
|
|
|
extern uint8_t seq_content_type[10]; |
|
|
|
extern uint8_t seq_content_type[NUM_SEQ_PATTERN]; |
|
|
|
extern uint8_t seq_track_type[4]; |
|
|
|
extern uint8_t seq_track_type[NUM_SEQ_TRACKS]; |
|
|
|
extern uint8_t seq_chord_key_ammount; |
|
|
|
extern uint8_t seq_chord_key_ammount; |
|
|
|
extern uint8_t seq_element_shift; |
|
|
|
extern uint8_t seq_element_shift; |
|
|
|
extern int seq_oct_shift; |
|
|
|
extern int seq_oct_shift; |
|
|
@ -63,7 +63,7 @@ extern uint8_t arp_lenght; |
|
|
|
extern uint8_t arp_style; |
|
|
|
extern uint8_t arp_style; |
|
|
|
extern uint8_t seq_chord_velocity; |
|
|
|
extern uint8_t seq_chord_velocity; |
|
|
|
extern uint8_t seq_chord_dexed_inst; |
|
|
|
extern uint8_t seq_chord_dexed_inst; |
|
|
|
extern uint8_t seq_inst_dexed[4]; |
|
|
|
extern uint8_t seq_inst_dexed[NUM_SEQ_TRACKS]; |
|
|
|
extern char seq_name[FILENAME_LEN]; |
|
|
|
extern char seq_name[FILENAME_LEN]; |
|
|
|
extern char seq_name_temp[FILENAME_LEN]; |
|
|
|
extern char seq_name_temp[FILENAME_LEN]; |
|
|
|
extern PeriodicTimer timer1; |
|
|
|
extern PeriodicTimer timer1; |
|
|
@ -945,24 +945,132 @@ bool save_sd_fx_json(uint8_t fx, uint8_t target) |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool save_sd_seq_sub_vel_json(uint8_t seq_number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
int count = 0; |
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
File json; |
|
|
|
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-vel.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Saving sequencer velocity ")); |
|
|
|
|
|
|
|
Serial.print(seq_number); |
|
|
|
|
|
|
|
Serial.print(F(" to ")); |
|
|
|
|
|
|
|
Serial.println(filename); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
int total = sizeof(seq_vel); |
|
|
|
|
|
|
|
int columns = sizeof(seq_vel[0]); |
|
|
|
|
|
|
|
int rows = total / columns; |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
SD.begin(); |
|
|
|
|
|
|
|
SD.remove(filename); |
|
|
|
|
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
|
|
|
|
if (json) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < rows; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t j = 0; j < columns; j++) { |
|
|
|
|
|
|
|
data_json["seq_velocity"][count] = seq_vel[i][j]; |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool save_sd_seq_sub_patterns_json(uint8_t seq_number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
int count = 0; |
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
File json; |
|
|
|
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-pat.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Saving sequencer patterns ")); |
|
|
|
|
|
|
|
Serial.print(seq_number); |
|
|
|
|
|
|
|
Serial.print(F(" to ")); |
|
|
|
|
|
|
|
Serial.println(filename); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
int total = sizeof(seq_data); |
|
|
|
|
|
|
|
int columns = sizeof(seq_data[0]); |
|
|
|
|
|
|
|
int rows = total / columns; |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
SD.begin(); |
|
|
|
|
|
|
|
SD.remove(filename); |
|
|
|
|
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
|
|
|
|
if (json) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < rows; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t j = 0; j < columns; j++) { |
|
|
|
|
|
|
|
data_json["seq_data"][count] = seq_data[i][j]; |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
int count = 0; |
|
|
|
int count = 0; |
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
save_sd_seq_sub_vel_json(seq_number); |
|
|
|
|
|
|
|
save_sd_seq_sub_patterns_json(seq_number); |
|
|
|
sprintf(filename, "/%s/%d-fx.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
sprintf(filename, "/%s/%d-fx.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("write SEQ-FX-Config ")); |
|
|
|
Serial.print(F("write SEQ-FX-Config ")); |
|
|
|
Serial.print(seq_number); |
|
|
|
Serial.print(seq_number); |
|
|
|
Serial.print(F(" ")); |
|
|
|
Serial.print(F(" ")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
save_sd_fx_json(seq_number, 1); |
|
|
|
save_sd_fx_json(seq_number, 1); |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < MAX_DEXED; i++) |
|
|
|
for (uint8_t i = 0; i < MAX_DEXED; i++) |
|
|
|
{ sprintf(filename, "/%s/%d-v%d.json", SEQ_CONFIG_PATH, seq_number, i); |
|
|
|
{ sprintf(filename, "/%s/%d-v%d.json", SEQ_CONFIG_PATH, seq_number, i); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Write Voice-Config for sequencer")); |
|
|
|
Serial.print(F("Write Voice-Config for sequencer")); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.print(filename); |
|
|
@ -989,32 +1097,15 @@ bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
Serial.print(" Columns: "); |
|
|
|
Serial.print(" Columns: "); |
|
|
|
Serial.print(columns); |
|
|
|
Serial.print(columns); |
|
|
|
Serial.print(F(" ")); |
|
|
|
Serial.print(F(" ")); |
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
AudioNoInterrupts(); |
|
|
|
SD.begin(); |
|
|
|
SD.begin(); |
|
|
|
SD.remove(filename); |
|
|
|
SD.remove(filename); |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
if (json) |
|
|
|
if (json) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (uint8_t i = 0; i < rows; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t j = 0; j < columns; j++) { |
|
|
|
|
|
|
|
data_json["seq_data"][count] = seq_data[i][j]; |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
count = 0; |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < rows; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint8_t j = 0; j < columns; j++) { |
|
|
|
|
|
|
|
data_json["seq_velocity"][count] = seq_vel[i][j]; |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
total = sizeof(seq_patternchain); |
|
|
|
total = sizeof(seq_patternchain); |
|
|
|
columns = sizeof(seq_patternchain[0]); |
|
|
|
columns = sizeof(seq_patternchain[0]); |
|
|
|
rows = total / columns; |
|
|
|
rows = total / columns; |
|
|
|
|
|
|
|
|
|
|
|
Serial.print(F("Chain Rows: ")); |
|
|
|
Serial.print(F("Chain Rows: ")); |
|
|
|
Serial.print(rows); |
|
|
|
Serial.print(rows); |
|
|
|
Serial.print(" Chain Columns: "); |
|
|
|
Serial.print(" Chain Columns: "); |
|
|
@ -1042,13 +1133,11 @@ bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
data_json["chord_key_ammount"] = seq_chord_key_ammount; |
|
|
|
data_json["chord_key_ammount"] = seq_chord_key_ammount; |
|
|
|
data_json["seq_oct_shift"] = seq_oct_shift; |
|
|
|
data_json["seq_oct_shift"] = seq_oct_shift; |
|
|
|
data_json["seq_element_shift"] = seq_element_shift; |
|
|
|
data_json["seq_element_shift"] = 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_track_type); i++) { |
|
|
|
data_json["track_type"][i] = seq_track_type[i]; |
|
|
|
data_json["track_type"][i] = seq_track_type[i]; |
|
|
|
} |
|
|
|
} |
|
|
@ -1061,8 +1150,6 @@ bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
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_name[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
@ -1074,7 +1161,6 @@ bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
json.close(); |
|
|
|
json.close(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1123,22 +1209,20 @@ void get_sd_seq_name_json(uint8_t seq_number) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
bool load_sd_seq_sub_vel_json(uint8_t seq_number) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (seq_number < 0) |
|
|
|
if (seq_number < 0) |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
|
|
|
|
load_sd_fx_json(seq_number, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
if (sd_card > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
File json; |
|
|
|
File json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-S.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
sprintf(filename, "/%s/%d-vel.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
// first check if file exists...
|
|
|
|
AudioNoInterrupts(); |
|
|
|
AudioNoInterrupts(); |
|
|
@ -1146,7 +1230,7 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// ... and if: load
|
|
|
|
// ... and if: load
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Found Sequencer configuration [")); |
|
|
|
Serial.print(F("Found velocity data [")); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
Serial.println(F(" ")); |
|
|
|
Serial.println(F(" ")); |
|
|
@ -1155,7 +1239,6 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
if (json) |
|
|
|
if (json) |
|
|
|
{ |
|
|
|
{ |
|
|
|
deserializeJson(data_json, json); |
|
|
|
deserializeJson(data_json, json); |
|
|
|
|
|
|
|
|
|
|
|
json.close(); |
|
|
|
json.close(); |
|
|
|
AudioInterrupts(); |
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
@ -1164,30 +1247,158 @@ bool load_sd_seq_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_vel); |
|
|
|
int columns = sizeof(seq_data[0]); |
|
|
|
int columns = sizeof(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_data[i][j] = data_json["seq_data"][count]; |
|
|
|
seq_vel[i][j] = data_json["seq_velocity"][count]; |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
count = 0; |
|
|
|
return (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("No ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" available.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool load_sd_seq_sub_patterns_json(uint8_t seq_number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (seq_number < 0) |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
File json; |
|
|
|
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-pat.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// ... and if: load
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Found pattern data [")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
|
|
|
|
Serial.println(F(" ")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
json = SD.open(filename); |
|
|
|
|
|
|
|
if (json) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deserializeJson(data_json, json); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Read JSON data:")); |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
int total = sizeof(seq_data); |
|
|
|
|
|
|
|
int columns = sizeof(seq_data[0]); |
|
|
|
|
|
|
|
int rows = total / columns; |
|
|
|
|
|
|
|
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_data[i][j] = data_json["seq_data"][count]; |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
total = sizeof(seq_patternchain); |
|
|
|
return (true); |
|
|
|
columns = sizeof(seq_patternchain[0]); |
|
|
|
} |
|
|
|
rows = total / columns; |
|
|
|
#ifdef DEBUG |
|
|
|
count = 0; |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("No ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" available.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (seq_number < 0) |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
load_sd_seq_sub_patterns_json(seq_number); |
|
|
|
|
|
|
|
load_sd_seq_sub_vel_json(seq_number); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
load_sd_fx_json(seq_number, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
File json; |
|
|
|
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-S.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// ... and if: load
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.print(F("Found Sequencer configuration [")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
|
|
|
|
Serial.println(F(" ")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
json = SD.open(filename); |
|
|
|
|
|
|
|
if (json) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deserializeJson(data_json, json); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Read JSON data:")); |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
int total = sizeof(seq_patternchain); |
|
|
|
|
|
|
|
int columns = sizeof(seq_patternchain[0]); |
|
|
|
|
|
|
|
int rows = total / columns; |
|
|
|
|
|
|
|
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++) { |
|
|
@ -1210,7 +1421,6 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
seq_name[i] = data_json["seq_name"][i]; |
|
|
|
seq_name[i] = data_json["seq_name"][i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
count = 0; |
|
|
|
count = 0; |
|
|
|
seq_tempo_ms = data_json["seq_tempo_ms"] ; |
|
|
|
seq_tempo_ms = data_json["seq_tempo_ms"] ; |
|
|
|
seq_bpm = data_json["seq_bpm"]; |
|
|
|
seq_bpm = data_json["seq_bpm"]; |
|
|
@ -1225,17 +1435,12 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
seq_chord_key_ammount = data_json["chord_key_ammount"]; |
|
|
|
seq_chord_key_ammount = data_json["chord_key_ammount"]; |
|
|
|
seq_oct_shift = data_json["seq_oct_shift"]; |
|
|
|
seq_oct_shift = data_json["seq_oct_shift"]; |
|
|
|
seq_element_shift = data_json["seq_element_shift"]; |
|
|
|
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]; |
|
|
|
configuration.performance.voice[instance_id] = data_json["voice"][instance_id]; |
|
|
|
configuration.performance.voice[instance_id] = data_json["voice"][instance_id]; |
|
|
|
load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); |
|
|
|
load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); |
|
|
|
load_sd_voiceconfig_json(seq_number, instance_id, 1); |
|
|
|
load_sd_voiceconfig_json(seq_number, instance_id, 1); |
|
|
|
//check_configuration_dexed(instance_id);
|
|
|
|
|
|
|
|
//set_voiceconfig_params(instance_id);
|
|
|
|
|
|
|
|
//MicroDexed[instance_id]->ControllersRefresh();
|
|
|
|
|
|
|
|
MicroDexed[instance_id]->setGain(midi_volume_transform(map(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0, 127))); |
|
|
|
MicroDexed[instance_id]->setGain(midi_volume_transform(map(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0, 127))); |
|
|
|
MicroDexed[instance_id]->panic(); |
|
|
|
MicroDexed[instance_id]->panic(); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -1245,16 +1450,13 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
Serial.print(F(" ")); |
|
|
|
Serial.print(F(" ")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
set_voiceconfig_params(instance_id); |
|
|
|
set_voiceconfig_params(instance_id); |
|
|
|
set_fx_params(); |
|
|
|
set_fx_params(); |
|
|
|
|
|
|
|
|
|
|
|
if (seq_running) |
|
|
|
if (seq_running) |
|
|
|
timer1.begin(sequencer, seq_tempo_ms / 2); |
|
|
|
timer1.begin(sequencer, seq_tempo_ms / 2); |
|
|
|
else |
|
|
|
else |
|
|
|
timer1.begin(sequencer, seq_tempo_ms / 2, false); |
|
|
|
timer1.begin(sequencer, seq_tempo_ms / 2, false); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|