Several fixes for loading a performance.

pull/111/head
Holger Wirtz 3 years ago
parent 9d81ffe334
commit 87f1a072f9
  1. 42
      MicroDexed.ino
  2. 16
      UI.hpp
  3. 34
      config.h
  4. 98
      dexed_sd.cpp

@ -289,13 +289,6 @@ void create_audio_drum_chain(uint8_t instance_id)
dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(*Drum[instance_id], 0, drum_reverb_send_mixer_l, instance_id);
#endif #endif
#ifdef DEBUG
Serial.print(F("Drum-Instance: "));
Serial.println(instance_id);
Serial.print(F("Dynamic-Connection-Counter="));
Serial.println(nDynamic);
#endif
} }
#endif #endif
@ -393,7 +386,10 @@ void setup()
#endif #endif
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("-------------------------------------------------------------------------------"));
Serial.println(F("Latest crash report:"));
Serial.println(CrashReport); Serial.println(CrashReport);
Serial.println(F("-------------------------------------------------------------------------------"));
setup_debug_message(); setup_debug_message();
@ -411,11 +407,11 @@ void setup()
Serial.flush(); Serial.flush();
#endif #endif
// Setup MIDI devices
setup_midi_devices(); setup_midi_devices();
// Start audio system // Start audio system
AudioMemory(AUDIO_MEM); AudioMemory(AUDIO_MEM);
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
sgtl5000.enable(); sgtl5000.enable();
sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL); sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL);
@ -484,7 +480,6 @@ void setup()
#endif #endif
create_audio_dexed_chain(instance_id); create_audio_dexed_chain(instance_id);
} }
#ifdef DEBUG #ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -496,6 +491,7 @@ void setup()
} }
#endif #endif
//Setup (PROGMEM-) sample drums
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
// create dynamic Drum instances // create dynamic Drum instances
for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++)
@ -515,8 +511,8 @@ void setup()
} }
#endif #endif
// Setup effects
#if defined(USE_FX) #if defined(USE_FX)
// Init effects
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
memset(delayline[instance_id], 0, sizeof(delayline[instance_id])); memset(delayline[instance_id], 0, sizeof(delayline[instance_id]));
@ -536,7 +532,7 @@ void setup()
#endif #endif
#endif #endif
// start SD card // Start SD card
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(false); change_disp_sd(false);
#endif #endif
@ -562,7 +558,7 @@ void setup()
} }
} }
// Start timer (to avoid a crash when loading the performance) // Start timer (to avoid a crash when loading the performance data)
timer1.begin(sequencer, seq_tempo_ms / 2, false); timer1.begin(sequencer, seq_tempo_ms / 2, false);
// Load initial Performance or the last used one // Load initial Performance or the last used one
@ -576,6 +572,7 @@ void setup()
AudioProcessorUsageMaxReset(); AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset(); AudioMemoryUsageMaxReset();
// Load voices
#ifdef DEBUG #ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -590,7 +587,6 @@ void setup()
Serial.print(F("Polyphony: ")); Serial.print(F("Polyphony: "));
Serial.println(configuration.dexed[instance_id].polyphony, DEC); Serial.println(configuration.dexed[instance_id].polyphony, DEC);
} }
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.print(AUDIO_BLOCK_SAMPLES); Serial.print(AUDIO_BLOCK_SAMPLES);
Serial.print(F(" (Time per block=")); Serial.print(F(" (Time per block="));
@ -602,7 +598,7 @@ void setup()
show_cpu_and_mem_usage(); show_cpu_and_mem_usage();
#endif #endif
// init master_mixer // Init master_mixer
#if NUM_DEXED > 1 #if NUM_DEXED > 1
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -619,14 +615,12 @@ void setup()
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; 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);
#endif #endif
master_mixer_r.gain(3, VOL_MAX_FLOAT); master_mixer_r.gain(3, VOL_MAX_FLOAT);
master_mixer_l.gain(3, VOL_MAX_FLOAT); master_mixer_l.gain(3, VOL_MAX_FLOAT);
#if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU)
audio_thru_mixer_r.gain(0, VOL_MAX_FLOAT); // MD signal sum audio_thru_mixer_r.gain(0, VOL_MAX_FLOAT); // MD signal sum
audio_thru_mixer_l.gain(0, VOL_MAX_FLOAT); // MD signal sum audio_thru_mixer_l.gain(0, VOL_MAX_FLOAT); // MD signal sum
@ -1888,7 +1882,7 @@ void initial_values_from_eeprom(bool init)
Serial.println(F("Found wrong EEPROM marker, initializing EEPROM...")); Serial.println(F("Found wrong EEPROM marker, initializing EEPROM..."));
#endif #endif
init_configuration(); init_configuration();
load_sd_seq_json(PERFORMANCE_NUM_MIN); load_sd_performance_json(PERFORMANCE_NUM_MIN);
} }
else else
{ {
@ -1899,7 +1893,7 @@ void initial_values_from_eeprom(bool init)
Serial.println(eeprom_performance, DEC); Serial.println(eeprom_performance, DEC);
#endif #endif
load_sd_seq_json(eeprom_performance); load_sd_performance_json(eeprom_performance);
} }
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("OK, loaded!")); Serial.println(F("OK, loaded!"));
@ -1972,13 +1966,13 @@ void check_configuration_fx(void)
void check_configuration_performance(void) void check_configuration_performance(void)
{ {
configuration.performance.fx_number = constrain(configuration.performance.fx_number, FX_NUM_MIN, FX_NUM_MAX); configuration.performance.fx_number = constrain(configuration.performance.fx_number, FX_CONFIG_MIN, FX_CONFIG_MAX);
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] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1); configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1);
configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id], 0, MAX_VOICES - 1); configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id], 0, MAX_VOICES - 1);
configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id], VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id], VOICE_CONFIG_MIN, VOICE_CONFIG_MAX);
} }
} }
@ -2039,13 +2033,13 @@ void init_configuration(void)
configuration.fx.reverb_roomsize = REVERB_ROOMSIZE_DEFAULT; configuration.fx.reverb_roomsize = REVERB_ROOMSIZE_DEFAULT;
configuration.fx.reverb_level = REVERB_LEVEL_DEFAULT; configuration.fx.reverb_level = REVERB_LEVEL_DEFAULT;
configuration.performance.fx_number = FX_NUM_DEFAULT; configuration.performance.fx_number = FX_CONFIG_DEFAULT;
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] = SYSEXBANK_DEFAULT; configuration.performance.bank[instance_id] = SYSEXBANK_DEFAULT;
configuration.performance.voice[instance_id] = SYSEXSOUND_DEFAULT; configuration.performance.voice[instance_id] = SYSEXSOUND_DEFAULT;
configuration.performance.voiceconfig_number[instance_id] = VOICECONFIG_NUM_DEFAULT; configuration.performance.voiceconfig_number[instance_id] = VOICE_CONFIG_DEFAULT;
configuration.dexed[instance_id].midi_channel = DEFAULT_MIDI_CHANNEL; configuration.dexed[instance_id].midi_channel = DEFAULT_MIDI_CHANNEL;
configuration.dexed[instance_id].lowest_note = INSTANCE_LOWEST_NOTE_MIN; configuration.dexed[instance_id].lowest_note = INSTANCE_LOWEST_NOTE_MIN;
@ -2631,10 +2625,10 @@ void check_and_create_directories(void)
if (!SD.exists(tmp)) if (!SD.exists(tmp))
SD.mkdir(tmp); // Set Marker so that the Cleanup loops only run once. SD.mkdir(tmp); // Set Marker so that the Cleanup loops only run once.
} }
#ifdef DEBUG /* #ifdef DEBUG
else else
Serial.println(F("No SD card for directory check available.")); Serial.println(F("No SD card for directory check available."));
#endif #endif */
} }
} }

@ -9,7 +9,6 @@
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
@ -68,7 +67,8 @@ extern char receive_bank_filename[FILENAME_LEN];
#if NUM_DRUMS > 0 #if NUM_DRUMS > 0
#include "drums.h" #include "drums.h"
extern void get_sd_seq_name_json(uint8_t number); extern void get_sd_performance_name_json(uint8_t number);
extern bool save_sd_performance_json(uint8_t p);
extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; extern drum_config_t drum_config[NUM_DRUMSET_CONFIG];
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];
@ -6214,11 +6214,11 @@ void UI_func_load_performance(uint8_t param)
{ {
mode = 0xff; mode = 0xff;
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
if (load_sd_seq_json(temp_int) == false) if (load_sd_performance_json(temp_int) == false)
lcd.print("Does not exist."); lcd.print("Does not exist.");
else else
{ {
load_sd_seq_json(temp_int); load_sd_performance_json(temp_int);
seq_state_last_loadsave = temp_int; seq_state_last_loadsave = temp_int;
lcd.print("Done. "); lcd.print("Done. ");
} }
@ -6232,7 +6232,7 @@ void UI_func_load_performance(uint8_t param)
lcd.print(tmp); lcd.print(tmp);
if (check_sd_performance_exists(temp_int)) if (check_sd_performance_exists(temp_int))
{ {
get_sd_seq_name_json(temp_int); get_sd_performance_name_json(temp_int);
if ( seq_name_temp[0] != 0 ) if ( seq_name_temp[0] != 0 )
lcd.show(1, 5, 11, seq_name_temp); lcd.show(1, 5, 11, seq_name_temp);
else else
@ -6279,7 +6279,7 @@ void UI_func_save_performance(uint8_t param)
overwrite = false; overwrite = false;
if (check_sd_performance_exists(temp_int)) if (check_sd_performance_exists(temp_int))
{ {
get_sd_seq_name_json(temp_int); get_sd_performance_name_json(temp_int);
if ( seq_name_temp[0] != 0 ) if ( seq_name_temp[0] != 0 )
lcd.show(1, 5, 11, seq_name_temp); lcd.show(1, 5, 11, seq_name_temp);
else else
@ -6323,7 +6323,7 @@ void UI_func_save_performance(uint8_t param)
sprintf(tmp, "/%s/%d-S.json", PERFORMANCE_CONFIG_PATH, temp_int); sprintf(tmp, "/%s/%d-S.json", PERFORMANCE_CONFIG_PATH, temp_int);
SD.remove(tmp); SD.remove(tmp);
} }
save_sd_seq_json(temp_int); save_sd_performance_json(temp_int);
lcd.show(1, 0, 16, "Done."); lcd.show(1, 0, 16, "Done.");
seq_state_last_loadsave = temp_int; seq_state_last_loadsave = temp_int;
delay(MESSAGE_WAIT_TIME); delay(MESSAGE_WAIT_TIME);
@ -6357,7 +6357,7 @@ void UI_func_save_performance(uint8_t param)
lcd.print("-- empty --"); lcd.print("-- empty --");
} else if (check_sd_performance_exists(temp_int)) } else if (check_sd_performance_exists(temp_int))
{ {
get_sd_seq_name_json(temp_int); get_sd_performance_name_json(temp_int);
if ( seq_name_temp[0] != 0 ) if ( seq_name_temp[0] != 0 )
lcd.show(1, 5, 11, seq_name_temp); else lcd.show(1, 5, 11, seq_name_temp); else
lcd.print("-- DATA --"); lcd.print("-- DATA --");

@ -305,10 +305,6 @@
#define MAX_BANKS 100 #define MAX_BANKS 100
#define MAX_VOICES 32 // voices per bank #define MAX_VOICES 32 // voices per bank
#define MAX_FX 99
#define MAX_PERFORMANCE 99
#define MAX_VOICECONFIG 99
#define MAX_VELOCITY 99
#define BANK_NAME_LEN 11 // 10 (plus '\0') #define BANK_NAME_LEN 11 // 10 (plus '\0')
#define VOICE_NAME_LEN 12 // 11 (plus '\0') #define VOICE_NAME_LEN 12 // 11 (plus '\0')
#define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN
@ -321,7 +317,7 @@
#define PERFORMANCE_CONFIG_PATH "PERFORMANCE" #define PERFORMANCE_CONFIG_PATH "PERFORMANCE"
#define PERFORMANCE_CONFIG_NAME "performance" #define PERFORMANCE_CONFIG_NAME "performance"
#define DRUMS_CONFIG_NAME "drums" #define DRUMS_CONFIG_NAME "drums"
#define PATTERN_CONFIG_NAME "pattern" #define PATTERN_CONFIG_NAME "patterns"
#define VELOCITY_CONFIG_NAME "velocity" #define VELOCITY_CONFIG_NAME "velocity"
#define FX_CONFIG_NAME "fx" #define FX_CONFIG_NAME "fx"
#define VOICE_CONFIG_NAME "voice" #define VOICE_CONFIG_NAME "voice"
@ -622,20 +618,28 @@
#define VELOCITY_LEVEL_DEFAULT 100 #define VELOCITY_LEVEL_DEFAULT 100
#define PERFORMANCE_NUM_MIN 0 #define PERFORMANCE_NUM_MIN 0
#define PERFORMANCE_NUM_MAX MAX_PERFORMANCE #define PERFORMANCE_NUM_MAX 99
#define PERFORMANCE_NUM_DEFAULT 0 #define PERFORMANCE_NUM_DEFAULT 0
#define FX_NUM_MIN 0 #define FX_CONFIG_MIN 0
#define FX_NUM_MAX MAX_FX #define FX_CONFIG_MAX 99
#define FX_NUM_DEFAULT 0 #define FX_CONFIG_DEFAULT 0
#define VELOCITY_NUM_MIN 0 #define VELOCITY_CONFIG_MIN 0
#define VELOCITY_NUM_MAX MAX_VELOCITY #define VELOCITY_CONFIG_MAX 99
#define VELOCITY_NUM_DEFAULT 0 #define VELOCITY_CONFIG_DEFAULT 0
#define VOICECONFIG_NUM_MIN 0 #define VOICE_CONFIG_MIN 0
#define VOICECONFIG_NUM_MAX MAX_VOICECONFIG #define VOICE_CONFIG_MAX 99
#define VOICECONFIG_NUM_DEFAULT -1 #define VOICE_CONFIG_DEFAULT -1
#define DRUMS_CONFIG_MIN 0
#define DRUMS_CONFIG_MAX 99
#define DRUMS_CONFIG_DEFAULT 0
#define SEQUENCE_CONFIG_MIN 0
#define SEQUENCE_CONFIG_MAX 99
#define SEQUENCE_CONFIG_DEFAULT 0
#define EQ_1_MIN 15 #define EQ_1_MIN 15
#define EQ_1_MAX 250 #define EQ_1_MAX 250

@ -93,7 +93,6 @@ extern uint8_t find_drum_number_from_note(uint8_t note);
/****************************************************************************** /******************************************************************************
SD BANK/VOICE LOADING SD BANK/VOICE LOADING
******************************************************************************/ ******************************************************************************/
bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id)
{ {
v = constrain(v, 0, MAX_VOICES - 1); v = constrain(v, 0, MAX_VOICES - 1);
@ -453,13 +452,12 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data)
/****************************************************************************** /******************************************************************************
SD DRUMSETTINGS SD DRUMSETTINGS
******************************************************************************/ ******************************************************************************/
bool load_sd_drumsettings_json(uint8_t number) bool load_sd_drumsettings_json(uint8_t number)
{ {
if (number < 0) if (number < 0)
return (false); return (false);
number = constrain(number, 0, 99); number = constrain(number, DRUMS_CONFIG_MIN, DRUMS_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
@ -496,8 +494,7 @@ bool load_sd_drumsettings_json(uint8_t number)
{ {
uint8_t drumnumber = 0; uint8_t drumnumber = 0;
drumnumber = find_drum_number_from_note( data_json["note"][i] ); drumnumber = find_drum_number_from_note( data_json["note"][i] );
if ( ( (int)data_json["note"][i] > 0 && find_drum_number_from_note( data_json["note"][i] ) > 0 ) || if (((int)data_json["note"][i] > 0 && find_drum_number_from_note(data_json["note"][i]) > 0) || (i == 0 && (int)data_json["note"][i] == 210))
( i == 0 && (int)data_json["note"][i] == 210) )
{ {
set_sample_pitch( drumnumber, data_json["pitch"][i] ); set_sample_pitch( drumnumber, data_json["pitch"][i] );
set_sample_p_offset ( drumnumber, data_json["p_offset"][i] ); set_sample_p_offset ( drumnumber, data_json["p_offset"][i] );
@ -597,14 +594,14 @@ bool load_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
vc = constrain(vc, 0, MAX_VOICECONFIG); vc = constrain(vc, VOICE_CONFIG_MIN, VOICE_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
File json; File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, vc, VOICE_CONFIG_NAME, instance_id); sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, vc, VOICE_CONFIG_NAME, instance_id + 1);
// first check if file exists... // first check if file exists...
AudioNoInterrupts(); AudioNoInterrupts();
@ -624,8 +621,6 @@ bool load_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
json.close(); json.close();
AudioInterrupts(); AudioInterrupts();
check_configuration_dexed(instance_id);
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Read JSON data:")); Serial.println(F("Read JSON data:"));
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
@ -661,6 +656,7 @@ bool load_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
configuration.dexed[instance_id].op_enabled = data_json["op_enabled"]; configuration.dexed[instance_id].op_enabled = data_json["op_enabled"];
configuration.dexed[instance_id].midi_channel = data_json["midi_channel"]; configuration.dexed[instance_id].midi_channel = data_json["midi_channel"];
check_configuration_dexed(instance_id);
set_voiceconfig_params(instance_id); set_voiceconfig_params(instance_id);
return (true); return (true);
@ -690,7 +686,7 @@ bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
vc = constrain(vc, 0, MAX_VOICECONFIG); vc = constrain(vc, VOICE_CONFIG_MIN, VOICE_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
@ -776,7 +772,7 @@ bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
******************************************************************************/ ******************************************************************************/
bool load_sd_fx_json(uint8_t fx) bool load_sd_fx_json(uint8_t fx)
{ {
fx = constrain(fx, FX_NUM_MIN, FX_NUM_MAX); fx = constrain(fx, FX_CONFIG_MIN, FX_CONFIG_MAX);
load_sd_drumsettings_json(fx); load_sd_drumsettings_json(fx);
@ -805,8 +801,6 @@ bool load_sd_fx_json(uint8_t fx)
json.close(); json.close();
AudioInterrupts(); AudioInterrupts();
check_configuration_fx();
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Read JSON data:")); Serial.println(F("Read JSON data:"));
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
@ -845,6 +839,7 @@ bool load_sd_fx_json(uint8_t fx)
configuration.fx.eq_6 = data_json["eq_6"]; configuration.fx.eq_6 = data_json["eq_6"];
configuration.fx.eq_7 = data_json["eq_7"]; configuration.fx.eq_7 = data_json["eq_7"];
check_configuration_fx();
set_fx_params(); set_fx_params();
return (true); return (true);
@ -874,7 +869,7 @@ bool save_sd_fx_json(uint8_t fx)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
fx = constrain(fx, FX_NUM_MIN, FX_NUM_MAX); fx = constrain(fx, FX_CONFIG_MIN, FX_CONFIG_MAX);
save_sd_drumsettings_json(fx); save_sd_drumsettings_json(fx);
if (sd_card > 0) if (sd_card > 0)
@ -953,7 +948,7 @@ bool save_sd_seq_sub_vel_json(uint8_t seq_number)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
int count = 0; int count = 0;
seq_number = constrain(seq_number, VELOCITY_NUM_MIN, VELOCITY_NUM_MAX); seq_number = constrain(seq_number, VELOCITY_CONFIG_MIN, VELOCITY_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
@ -1009,7 +1004,7 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
int count = 0; int count = 0;
seq_number = constrain(seq_number, VELOCITY_NUM_MIN, VELOCITY_NUM_MAX); seq_number = constrain(seq_number, VELOCITY_CONFIG_MIN, VELOCITY_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
@ -1061,12 +1056,12 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
return (false); return (false);
} }
bool save_sd_seq_json(uint8_t seq_number) bool save_sd_performance_json(uint8_t seq_number)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
int count = 0; int count = 0;
bool seq_was_running = false; bool seq_was_running = false;
seq_number = constrain(seq_number, VELOCITY_NUM_MIN, VELOCITY_NUM_MAX); seq_number = constrain(seq_number, VELOCITY_CONFIG_MIN, VELOCITY_CONFIG_MAX);
if (seq_running == true ) { if (seq_running == true ) {
seq_was_running = true; seq_was_running = true;
@ -1182,7 +1177,7 @@ bool save_sd_seq_json(uint8_t seq_number)
return (false); return (false);
} }
void get_sd_seq_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_name_temp, 0, FILENAME_LEN);
@ -1222,7 +1217,7 @@ 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, SEQUENCE_CONFIG_MIN, SEQUENCE_CONFIG_MAX);
if (sd_card > 0) if (sd_card > 0)
{ {
File json; File json;
@ -1356,11 +1351,10 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number)
return (false); return (false);
} }
bool load_sd_seq_json(uint8_t seq_number) bool load_sd_performance_json(uint8_t seq_number)
{ {
bool seq_was_running = false; bool seq_was_running = false;
if (seq_number < 0)
return (false);
if (seq_running) if (seq_running)
{ {
seq_was_running = true; seq_was_running = true;
@ -1385,10 +1379,9 @@ 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 Performance configuration ["));
Serial.print(filename); Serial.print(filename);
Serial.println(F("]... loading...")); Serial.println(F("]... loading..."));
Serial.println(F(" "));
#endif #endif
json = SD.open(filename); json = SD.open(filename);
if (json) if (json)
@ -1456,15 +1449,16 @@ bool load_sd_seq_json(uint8_t seq_number)
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
Serial.print(F(" ")); Serial.print(F("Load Voice-Config "));
Serial.print(F("Load Voice-Config for sequencer")); Serial.print(instance_id + 1);
Serial.print(instance_id); Serial.print(F(" for sequencer"));
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();*/
dac_unmute(); dac_unmute();
seq_step = 0; seq_step = 0;
seq_chain_active_step = 0; seq_chain_active_step = 0;
@ -1532,7 +1526,7 @@ bool check_sd_performance_exists(uint8_t number)
******************************************************************************/ ******************************************************************************/
/* /*
bool load_sd_performance_json(uint8_t p) bool load_sd_performance_json(uint8_t p)
{ {
if (p < 0) if (p < 0)
return (false); return (false);
@ -1548,11 +1542,11 @@ bool check_sd_performance_exists(uint8_t number)
if (SD.exists(filename)) if (SD.exists(filename))
{ {
// ... and if: load // ... and if: load
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Found performance configuration [")); Serial.print(F("Found performance configuration ["));
Serial.print(filename); Serial.print(filename);
Serial.println(F("]... loading...")); Serial.println(F("]... loading..."));
#endif #endif
json = SD.open(filename); json = SD.open(filename);
if (json) if (json)
{ {
@ -1562,11 +1556,11 @@ bool check_sd_performance_exists(uint8_t number)
check_configuration_performance(); check_configuration_performance();
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Read JSON data:")); Serial.println(F("Read JSON data:"));
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
for (uint8_t i = 0; i < MAX_DEXED; i++) for (uint8_t i = 0; i < MAX_DEXED; i++)
{ {
configuration.performance.bank[i] = data_json["bank"][i]; configuration.performance.bank[i] = data_json["bank"][i];
@ -1586,7 +1580,7 @@ bool check_sd_performance_exists(uint8_t number)
return (true); return (true);
} }
#ifdef DEBUG #ifdef DEBUG
else else
{ {
Serial.print(F("E : Cannot open ")); Serial.print(F("E : Cannot open "));
@ -1599,16 +1593,16 @@ bool check_sd_performance_exists(uint8_t number)
Serial.print(F("No ")); Serial.print(F("No "));
Serial.print(filename); Serial.print(filename);
Serial.println(F(" available.")); Serial.println(F(" available."));
#endif #endif
} }
} }
AudioInterrupts(); AudioInterrupts();
return (false); return (false);
} }
bool save_sd_performance_json(uint8_t p) bool save_sd_performance_json(uint8_t p)
{ {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
p = constrain(p, 0, MAX_PERFORMANCE); p = constrain(p, 0, MAX_PERFORMANCE);
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, p, PERFORMANCE_CONFIG_NAME); sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, p, PERFORMANCE_CONFIG_NAME);
@ -1616,12 +1610,12 @@ bool save_sd_performance_json(uint8_t p)
{ {
File json; File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Saving performance config as JSON")); Serial.print(F("Saving performance config as JSON"));
Serial.print(p); Serial.print(p);
Serial.print(F(" to ")); Serial.print(F(" to "));
Serial.println(filename); Serial.println(filename);
#endif #endif
AudioNoInterrupts(); AudioNoInterrupts();
@ -1629,22 +1623,22 @@ bool save_sd_performance_json(uint8_t p)
sprintf(filename, "/%s/%s%d.json", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number); sprintf(filename, "/%s/%s%d.json", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number);
if (!SD.exists(filename)) if (!SD.exists(filename))
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("FX-Config ")); Serial.print(F("FX-Config "));
Serial.print(configuration.performance.fx_number); Serial.print(configuration.performance.fx_number);
Serial.println(F(" does not exists, creating one.")); Serial.println(F(" does not exists, creating one."));
#endif #endif
save_sd_fx_json(configuration.performance.fx_number, 0); save_sd_fx_json(configuration.performance.fx_number, 0);
} }
for (uint8_t i = 0; i < MAX_DEXED; i++) for (uint8_t i = 0; i < MAX_DEXED; i++)
{ sprintf(filename, "/%s/%s%d.json", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[i]); { sprintf(filename, "/%s/%s%d.json", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[i]);
if (!SD.exists(filename)) if (!SD.exists(filename))
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Voice-Config ")); Serial.print(F("Voice-Config "));
Serial.print(configuration.performance.voiceconfig_number[i]); Serial.print(configuration.performance.voiceconfig_number[i]);
Serial.println(F(" does not exists, creating one.")); Serial.println(F(" does not exists, creating one."));
#endif #endif
save_sd_voiceconfig_json(configuration.performance.voiceconfig_number[i], i, 0); save_sd_voiceconfig_json(configuration.performance.voiceconfig_number[i], i, 0);
} }
} }
@ -1660,11 +1654,11 @@ bool save_sd_performance_json(uint8_t p)
} }
data_json["fx_number"] = configuration.performance.fx_number; data_json["fx_number"] = configuration.performance.fx_number;
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Write JSON data:")); Serial.println(F("Write JSON data:"));
serializeJsonPretty(data_json, Serial); serializeJsonPretty(data_json, Serial);
Serial.println(); Serial.println();
#endif #endif
serializeJsonPretty(data_json, json); serializeJsonPretty(data_json, json);
json.close(); json.close();
AudioInterrupts(); AudioInterrupts();
@ -1674,16 +1668,16 @@ bool save_sd_performance_json(uint8_t p)
} }
else else
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("E : Cannot open ")); Serial.print(F("E : Cannot open "));
Serial.print(filename); Serial.print(filename);
Serial.println(F(" on SD.")); Serial.println(F(" on SD."));
#endif #endif
} }
AudioInterrupts(); AudioInterrupts();
return (false); return (false);
} }
*/ */
/****************************************************************************** /******************************************************************************

Loading…
Cancel
Save