@ -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 ;
@ -1531,8 +1525,8 @@ bool check_sd_performance_exists(uint8_t number)
SD PERFORMANCE
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
bool load_sd_performance_json ( uint8_t p )
{
bool load_sd_performance_json ( uint8_t p )
{
if ( p < 0 )
return ( false ) ;
@ -1548,11 +1542,11 @@ bool check_sd_performance_exists(uint8_t number)
if ( SD . exists ( filename ) )
{
// ... and if: load
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " Found performance configuration [ " ) ) ;
Serial . print ( filename ) ;
Serial . println ( F ( " ]... loading... " ) ) ;
# endif
# endif
json = SD . open ( filename ) ;
if ( json )
{
@ -1562,11 +1556,11 @@ bool check_sd_performance_exists(uint8_t number)
check_configuration_performance ( ) ;
# ifdef DEBUG
# ifdef DEBUG
Serial . println ( F ( " Read JSON data: " ) ) ;
serializeJsonPretty ( data_json , Serial ) ;
Serial . println ( ) ;
# endif
# endif
for ( uint8_t i = 0 ; i < MAX_DEXED ; i + + )
{
configuration . performance . bank [ i ] = data_json [ " bank " ] [ i ] ;
@ -1586,7 +1580,7 @@ bool check_sd_performance_exists(uint8_t number)
return ( true ) ;
}
# ifdef DEBUG
# ifdef DEBUG
else
{
Serial . print ( F ( " E : Cannot open " ) ) ;
@ -1599,16 +1593,16 @@ bool check_sd_performance_exists(uint8_t number)
Serial . print ( F ( " No " ) ) ;
Serial . print ( filename ) ;
Serial . println ( F ( " available. " ) ) ;
# endif
# endif
}
}
AudioInterrupts ( ) ;
return ( false ) ;
}
}
bool save_sd_performance_json ( uint8_t p )
{
bool save_sd_performance_json ( uint8_t p )
{
char filename [ CONFIG_FILENAME_LEN ] ;
p = constrain ( p , 0 , MAX_PERFORMANCE ) ;
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 ;
StaticJsonDocument < JSON_BUFFER_SIZE > data_json ;
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " Saving performance config as JSON " ) ) ;
Serial . print ( p ) ;
Serial . print ( F ( " to " ) ) ;
Serial . println ( filename ) ;
# endif
# endif
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 ) ;
if ( ! SD . exists ( filename ) )
{
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " FX-Config " ) ) ;
Serial . print ( configuration . performance . fx_number ) ;
Serial . println ( F ( " does not exists, creating one. " ) ) ;
# endif
# endif
save_sd_fx_json ( configuration . performance . fx_number , 0 ) ;
}
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 ] ) ;
if ( ! SD . exists ( filename ) )
{
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " Voice-Config " ) ) ;
Serial . print ( configuration . performance . voiceconfig_number [ i ] ) ;
Serial . println ( F ( " does not exists, creating one. " ) ) ;
# endif
# endif
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 ;
# ifdef DEBUG
# ifdef DEBUG
Serial . println ( F ( " Write JSON data: " ) ) ;
serializeJsonPretty ( data_json , Serial ) ;
Serial . println ( ) ;
# endif
# endif
serializeJsonPretty ( data_json , json ) ;
json . close ( ) ;
AudioInterrupts ( ) ;
@ -1674,16 +1668,16 @@ bool save_sd_performance_json(uint8_t p)
}
else
{
# ifdef DEBUG
# ifdef DEBUG
Serial . print ( F ( " E : Cannot open " ) ) ;
Serial . print ( filename ) ;
Serial . println ( F ( " on SD. " ) ) ;
# endif
# endif
}
AudioInterrupts ( ) ;
return ( false ) ;
}
}
*/
/******************************************************************************