Dateien hochladen nach „“

pull/90/head
positionhigh 3 years ago
parent 477445e0d0
commit f1d67892b0
  1. 20
      MicroDexed.ino
  2. 273
      dexed_sd.cpp

@ -1877,7 +1877,8 @@ void check_configuration_fx(void)
configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id], CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX);
configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id], CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX);
configuration.fx.chorus_level[instance_id] = constrain(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX);
configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX);
if (configuration.fx.delay_sync[instance_id] == 0)
configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX);
configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX);
configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX);
configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX);
@ -2165,9 +2166,13 @@ void set_fx_params(void)
delay_fb_mixer[instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)));
if (configuration.fx.delay_level[selected_instance_id] <= DELAY_LEVEL_MIN)
delay_fx[instance_id]->disable(0);
else
else if (configuration.fx.delay_sync[instance_id] == 0)
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)
{
uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / seq_bpm);
delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX * 10));
}
// REVERB SEND
reverb_mixer_r.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0)));
reverb_mixer_l.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0)));
@ -2473,6 +2478,15 @@ void check_and_create_directories(void)
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}
sprintf(tmp, "/%s", DRUM_CONFIG_PATH);
if (!SD.exists(tmp))
{
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}

@ -437,6 +437,139 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data)
return (true);
}
/******************************************************************************
SD DRUMSETTINGS
******************************************************************************/
bool load_sd_drumsettings_json(uint8_t number, uint8_t target)
{
if (number < 0)
return (false);
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
char filename[FILENAME_LEN];
if (target == 0)
sprintf(filename, "/%s/%s%d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number);
else
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number);
// first check if file exists...
AudioNoInterrupts();
if (SD.exists(filename))
{
// ... and if: load
#ifdef DEBUG
Serial.print(F("Found drums configuration ["));
Serial.print(filename);
Serial.println(F("]... loading..."));
#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
drums_volume = data_json["drums_volume"];
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
{
drum_config[i].pan = data_json["pan"][i] ;
drum_config[i].vol_max = data_json["vol_max"][i] ;
drum_config[i].vol_min = data_json["vol_min"][i] ;
drum_config[i].reverb_send = data_json["reverb_send"][i];
}
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 save_sd_drumsettings_json(uint8_t number, uint8_t target)
{
char filename[FILENAME_LEN];
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
if (target == 0)
sprintf(filename, "/%s/%s%d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number);
else
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number);
#ifdef DEBUG
Serial.print(F("Saving drums config "));
Serial.print(number);
Serial.print(F(" to "));
Serial.println(filename);
#endif
AudioNoInterrupts();
if (SD.exists(filename)) {
Serial.println("remove old drumsettings file");
SD.remove(filename);
}
json = SD.open(filename, FILE_WRITE);
if (json)
{
data_json["drums_volume"] = drums_volume;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
{
data_json["pan"][i] = drum_config[i].pan;
data_json["vol_max"][i] = drum_config[i].vol_max;
data_json["vol_min"][i] = drum_config[i].vol_min;
data_json["reverb_send"][i] = drum_config[i].reverb_send;
}
#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();
AudioInterrupts();
}
else
{
#ifdef DEBUG
Serial.print(F("E : Cannot open "));
Serial.print(filename);
Serial.println(F(" on SD."));
#endif
}
return (false);
}
/******************************************************************************
SD VOICECONFIG
******************************************************************************/
@ -626,7 +759,7 @@ bool load_sd_fx_json(uint8_t fx, uint8_t target)
{
if (fx < 0)
return (false);
load_sd_drumsettings_json(fx, target);
fx = constrain(fx, 0, MAX_FX);
if (sd_card > 0)
@ -676,6 +809,8 @@ bool load_sd_fx_json(uint8_t fx, uint8_t target)
configuration.fx.delay_level[i] = data_json["delay_level"][i];
configuration.fx.delay_sync[i] = data_json["delay_sync"][i];
configuration.fx.reverb_send[i] = data_json["reverb_send"][i];
if (configuration.fx.delay_sync[i] > 0)
configuration.fx.delay_time[i] = 0;
}
configuration.fx.reverb_roomsize = data_json["reverb_roomsize"];
configuration.fx.reverb_damping = data_json["reverb_damping"];
@ -722,7 +857,7 @@ bool save_sd_fx_json(uint8_t fx, uint8_t target)
char filename[FILENAME_LEN];
fx = constrain(fx, 0, MAX_FX);
save_sd_drumsettings_json(fx, target);
if (sd_card > 0)
{
File json;
@ -795,145 +930,12 @@ bool save_sd_fx_json(uint8_t fx, uint8_t target)
return (false);
}
bool load_sd_drumsettings_json(uint8_t number, uint8_t target)
{
if (number < 0)
return (false);
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
char filename[FILENAME_LEN];
if (target == 0)
sprintf(filename, "/%s/%s%d.json", SEQ_CONFIG_PATH, DRUM_CONFIG_NAME, number); //change to DRUM
else
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number);
// first check if file exists...
AudioNoInterrupts();
if (SD.exists(filename))
{
// ... and if: load
#ifdef DEBUG
Serial.print(F("Found drums configuration ["));
Serial.print(filename);
Serial.println(F("]... loading..."));
#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
drums_volume = data_json["drums_volume"];
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
{
drum_config[i].pan = data_json["pan"][i] ;
drum_config[i].vol_max = data_json["vol_max"][i] ;
drum_config[i].vol_min = data_json["vol_min"][i] ;
drum_config[i].reverb_send = data_json["reverb_send"][i];
}
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 save_sd_drumsettings_json(uint8_t number, uint8_t target)
{
char filename[FILENAME_LEN];
number = constrain(number, 0, 99);
if (sd_card > 0)
{
File json;
StaticJsonDocument<JSON_BUFFER_SIZE> data_json;
if (target == 0)
sprintf(filename, "/%s/%s%d-d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number);
else
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number);
#ifdef DEBUG
Serial.print(F("Saving drums config "));
Serial.print(number);
Serial.print(F(" to "));
Serial.println(filename);
#endif
AudioNoInterrupts();
if (SD.exists(filename)) {
Serial.println("remove old drumsettings file");
SD.remove(filename);
}
json = SD.open(filename, FILE_WRITE);
if (json)
{
data_json["drums_volume"] = drums_volume;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
{
data_json["pan"][i] = drum_config[i].pan;
data_json["vol_max"][i] = drum_config[i].vol_max;
data_json["vol_min"][i] = drum_config[i].vol_min;
data_json["reverb_send"][i] = drum_config[i].reverb_send;
}
#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();
AudioInterrupts();
}
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)
{
char filename[FILENAME_LEN];
int count = 0;
seq_number = constrain(seq_number, 0, 99);
save_sd_drumsettings_json(seq_number, 1); // Destination (1) = sequencer path
sprintf(filename, "/%s/%d-fx.json", SEQ_CONFIG_PATH, seq_number);
#ifdef DEBUG
@ -1072,7 +1074,6 @@ bool load_sd_seq_json(uint8_t seq_number)
seq_number = constrain(seq_number, 0, 99);
load_sd_drumsettings_json(seq_number, 1);
load_sd_fx_json(seq_number, 1);
if (sd_card > 0)

Loading…
Cancel
Save