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. 56
      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_l, instance_id);
#endif
#ifdef DEBUG
Serial.print(F("Drum-Instance: "));
Serial.println(instance_id);
Serial.print(F("Dynamic-Connection-Counter="));
Serial.println(nDynamic);
#endif
}
#endif
@ -393,7 +386,10 @@ void setup()
#endif
#ifdef DEBUG
Serial.println(F("-------------------------------------------------------------------------------"));
Serial.println(F("Latest crash report:"));
Serial.println(CrashReport);
Serial.println(F("-------------------------------------------------------------------------------"));
setup_debug_message();
@ -411,11 +407,11 @@ void setup()
Serial.flush();
#endif
// Setup MIDI devices
setup_midi_devices();
// Start audio system
AudioMemory(AUDIO_MEM);
#if defined(TEENSY_AUDIO_BOARD)
sgtl5000.enable();
sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL);
@ -484,7 +480,6 @@ void setup()
#endif
create_audio_dexed_chain(instance_id);
}
#ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
@ -496,6 +491,7 @@ void setup()
}
#endif
//Setup (PROGMEM-) sample drums
#if NUM_DRUMS > 0
// create dynamic Drum instances
for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++)
@ -515,8 +511,8 @@ void setup()
}
#endif
// Setup effects
#if defined(USE_FX)
// Init effects
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
memset(delayline[instance_id], 0, sizeof(delayline[instance_id]));
@ -536,7 +532,7 @@ void setup()
#endif
#endif
// start SD card
// Start SD card
#ifdef DISPLAY_LCD_SPI
change_disp_sd(false);
#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);
// Load initial Performance or the last used one
@ -576,6 +572,7 @@ void setup()
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
// Load voices
#ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
@ -590,7 +587,6 @@ void setup()
Serial.print(F("Polyphony: "));
Serial.println(configuration.dexed[instance_id].polyphony, DEC);
}
Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.print(AUDIO_BLOCK_SAMPLES);
Serial.print(F(" (Time per block="));
@ -602,7 +598,7 @@ void setup()
show_cpu_and_mem_usage();
#endif
// init master_mixer
// Init master_mixer
#if NUM_DEXED > 1
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_l.gain(2, VOL_MAX_FLOAT);
drums_volume = VOL_MAX_FLOAT;
#else
master_mixer_r.gain(2, 0.0);
master_mixer_l.gain(2, 0.0);
#endif
master_mixer_r.gain(3, VOL_MAX_FLOAT);
master_mixer_l.gain(3, VOL_MAX_FLOAT);
#if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU)
audio_thru_mixer_r.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..."));
#endif
init_configuration();
load_sd_seq_json(PERFORMANCE_NUM_MIN);
load_sd_performance_json(PERFORMANCE_NUM_MIN);
}
else
{
@ -1899,7 +1893,7 @@ void initial_values_from_eeprom(bool init)
Serial.println(eeprom_performance, DEC);
#endif
load_sd_seq_json(eeprom_performance);
load_sd_performance_json(eeprom_performance);
}
#ifdef DEBUG
Serial.println(F("OK, loaded!"));
@ -1972,13 +1966,13 @@ void check_configuration_fx(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++)
{
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.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_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++)
{
configuration.performance.bank[instance_id] = SYSEXBANK_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].lowest_note = INSTANCE_LOWEST_NOTE_MIN;
@ -2631,10 +2625,10 @@ void check_and_create_directories(void)
if (!SD.exists(tmp))
SD.mkdir(tmp); // Set Marker so that the Cleanup loops only run once.
}
#ifdef DEBUG
/* #ifdef DEBUG
else
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
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.
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
#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 char seq_name[FILENAME_LEN];
extern char seq_name_temp[FILENAME_LEN];
@ -6214,11 +6214,11 @@ void UI_func_load_performance(uint8_t param)
{
mode = 0xff;
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.");
else
{
load_sd_seq_json(temp_int);
load_sd_performance_json(temp_int);
seq_state_last_loadsave = temp_int;
lcd.print("Done. ");
}
@ -6232,7 +6232,7 @@ void UI_func_load_performance(uint8_t param)
lcd.print(tmp);
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 )
lcd.show(1, 5, 11, seq_name_temp);
else
@ -6279,7 +6279,7 @@ void UI_func_save_performance(uint8_t param)
overwrite = false;
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 )
lcd.show(1, 5, 11, seq_name_temp);
else
@ -6323,7 +6323,7 @@ void UI_func_save_performance(uint8_t param)
sprintf(tmp, "/%s/%d-S.json", PERFORMANCE_CONFIG_PATH, temp_int);
SD.remove(tmp);
}
save_sd_seq_json(temp_int);
save_sd_performance_json(temp_int);
lcd.show(1, 0, 16, "Done.");
seq_state_last_loadsave = temp_int;
delay(MESSAGE_WAIT_TIME);
@ -6357,7 +6357,7 @@ void UI_func_save_performance(uint8_t param)
lcd.print("-- empty --");
} 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 )
lcd.show(1, 5, 11, seq_name_temp); else
lcd.print("-- DATA --");

@ -305,10 +305,6 @@
#define MAX_BANKS 100
#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 VOICE_NAME_LEN 12 // 11 (plus '\0')
#define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN
@ -321,7 +317,7 @@
#define PERFORMANCE_CONFIG_PATH "PERFORMANCE"
#define PERFORMANCE_CONFIG_NAME "performance"
#define DRUMS_CONFIG_NAME "drums"
#define PATTERN_CONFIG_NAME "pattern"
#define PATTERN_CONFIG_NAME "patterns"
#define VELOCITY_CONFIG_NAME "velocity"
#define FX_CONFIG_NAME "fx"
#define VOICE_CONFIG_NAME "voice"
@ -622,20 +618,28 @@
#define VELOCITY_LEVEL_DEFAULT 100
#define PERFORMANCE_NUM_MIN 0
#define PERFORMANCE_NUM_MAX MAX_PERFORMANCE
#define PERFORMANCE_NUM_MAX 99
#define PERFORMANCE_NUM_DEFAULT 0
#define FX_NUM_MIN 0
#define FX_NUM_MAX MAX_FX
#define FX_NUM_DEFAULT 0
#define FX_CONFIG_MIN 0
#define FX_CONFIG_MAX 99
#define FX_CONFIG_DEFAULT 0
#define VELOCITY_NUM_MIN 0
#define VELOCITY_NUM_MAX MAX_VELOCITY
#define VELOCITY_NUM_DEFAULT 0
#define VELOCITY_CONFIG_MIN 0
#define VELOCITY_CONFIG_MAX 99
#define VELOCITY_CONFIG_DEFAULT 0
#define VOICECONFIG_NUM_MIN 0
#define VOICECONFIG_NUM_MAX MAX_VOICECONFIG
#define VOICECONFIG_NUM_DEFAULT -1
#define VOICE_CONFIG_MIN 0
#define VOICE_CONFIG_MAX 99
#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_MAX 250

@ -93,7 +93,6 @@ extern uint8_t find_drum_number_from_note(uint8_t note);
/******************************************************************************
SD BANK/VOICE LOADING
******************************************************************************/
bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id)
{
v = constrain(v, 0, MAX_VOICES - 1);
@ -453,13 +452,12 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data)
/******************************************************************************
SD DRUMSETTINGS
******************************************************************************/
bool load_sd_drumsettings_json(uint8_t number)
{
if (number < 0)
return (false);
number = constrain(number, 0, 99);
number = constrain(number, DRUMS_CONFIG_MIN, DRUMS_CONFIG_MAX);
if (sd_card > 0)
{
@ -496,8 +494,7 @@ bool load_sd_drumsettings_json(uint8_t number)
{
uint8_t drumnumber = 0;
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 ) ||
( i == 0 && (int)data_json["note"][i] == 210) )
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))
{
set_sample_pitch( drumnumber, data_json["pitch"][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];
vc = constrain(vc, 0, MAX_VOICECONFIG);
vc = constrain(vc, VOICE_CONFIG_MIN, VOICE_CONFIG_MAX);
if (sd_card > 0)
{
File 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...
AudioNoInterrupts();
@ -624,8 +621,6 @@ bool load_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
json.close();
AudioInterrupts();
check_configuration_dexed(instance_id);
#ifdef DEBUG
Serial.println(F("Read JSON data:"));
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].midi_channel = data_json["midi_channel"];
check_configuration_dexed(instance_id);
set_voiceconfig_params(instance_id);
return (true);
@ -690,7 +686,7 @@ bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id)
{
char filename[CONFIG_FILENAME_LEN];
vc = constrain(vc, 0, MAX_VOICECONFIG);
vc = constrain(vc, VOICE_CONFIG_MIN, VOICE_CONFIG_MAX);
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)
{
fx = constrain(fx, FX_NUM_MIN, FX_NUM_MAX);
fx = constrain(fx, FX_CONFIG_MIN, FX_CONFIG_MAX);
load_sd_drumsettings_json(fx);
@ -805,8 +801,6 @@ bool load_sd_fx_json(uint8_t fx)
json.close();
AudioInterrupts();
check_configuration_fx();
#ifdef DEBUG
Serial.println(F("Read JSON data:"));
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_7 = data_json["eq_7"];
check_configuration_fx();
set_fx_params();
return (true);
@ -874,7 +869,7 @@ bool save_sd_fx_json(uint8_t fx)
{
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);
if (sd_card > 0)
@ -953,7 +948,7 @@ bool save_sd_seq_sub_vel_json(uint8_t seq_number)
{
char filename[CONFIG_FILENAME_LEN];
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)
{
@ -1009,7 +1004,7 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
{
char filename[CONFIG_FILENAME_LEN];
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)
{
@ -1061,12 +1056,12 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number)
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];
int count = 0;
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 ) {
seq_was_running = true;
@ -1182,7 +1177,7 @@ bool save_sd_seq_json(uint8_t seq_number)
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);
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)
return (false);
seq_number = constrain(seq_number, 0, 99);
seq_number = constrain(seq_number, SEQUENCE_CONFIG_MIN, SEQUENCE_CONFIG_MAX);
if (sd_card > 0)
{
File json;
@ -1356,11 +1351,10 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number)
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;
if (seq_number < 0)
return (false);
if (seq_running)
{
seq_was_running = true;
@ -1385,10 +1379,9 @@ bool load_sd_seq_json(uint8_t seq_number)
{
// ... and if: load
#ifdef DEBUG
Serial.print(F("Found Sequencer configuration ["));
Serial.print(F("Found Performance configuration ["));
Serial.print(filename);
Serial.println(F("]... loading..."));
Serial.println(F(" "));
#endif
json = SD.open(filename);
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]->panic();
#ifdef DEBUG
Serial.print(F(" "));
Serial.print(F("Load Voice-Config for sequencer"));
Serial.print(instance_id);
Serial.print(F(" "));
Serial.print(F("Load Voice-Config "));
Serial.print(instance_id + 1);
Serial.print(F(" for sequencer"));
#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_fx_params();
set_fx_params();*/
dac_unmute();
seq_step = 0;
seq_chain_active_step = 0;

Loading…
Cancel
Save