From a10e504da04fddc9d217025f3992e51553513351 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Wed, 18 Aug 2021 23:04:51 +0200 Subject: [PATCH] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI.hpp | 2 +- config.h | 2 ++ dexed_sd.cpp | 52 ++++++++++++++++++++++++++++++++++++---------------- drums.h | 1 - 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/UI.hpp b/UI.hpp index 2379480..7a9cd75 100644 --- a/UI.hpp +++ b/UI.hpp @@ -75,7 +75,7 @@ extern uint8_t seq_data[10][16]; extern uint8_t seq_vel[10][16]; extern uint8_t seq_patternchain[4][4]; extern uint8_t seq_content_type[10]; -extern uint8_t seq_track_type[4]; +extern uint8_t seq_track_type[]; extern uint8_t seq_step; extern uint8_t seq_chord_key_ammount; extern int seq_tempo_ms; diff --git a/config.h b/config.h index 3d3dc33..4d934b1 100644 --- a/config.h +++ b/config.h @@ -111,6 +111,8 @@ // NUMBER OF PARALLEL SAMPLEDRUMS #define NUM_DRUMS 8 +// NUMBER OF SAMPLES IN DRUMSET +#define NUM_DRUMSET_CONFIG 20 // CHORUS parameters #define MOD_DELAY_SAMPLE_BUFFER int32_t(TIME_MS2SAMPLES(20.0)) // 20.0 ms delay buffer. diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 87cca51..a51cf99 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -38,6 +38,7 @@ extern void check_configuration_dexed(uint8_t instance_id); extern void check_configuration_performance(void); extern void check_configuration_fx(void); extern void sequencer(); +extern float drums_volume; //extern StaticJsonDocument data_json; extern uint8_t seq_chain_lenght; extern uint8_t seq_data[10][16]; @@ -61,6 +62,19 @@ extern uint8_t seq_chord_dexed_inst; extern uint8_t seq_inst_dexed[4]; extern PeriodicTimer timer1; +typedef struct drum_config_s { + uint8_t drum_class; // Type of drum + uint8_t midinote; // Triggered by note + char name[DRUM_NAME_LEN]; + const unsigned int* drum_data; + char shortname[2]; // 1 char name for sequencer + float32_t pan; // Panorama (-1.0 - +1.0) + float32_t vol_max; // max. Volume (0.0 - 1.0) + float32_t vol_min; // min. Volume (0.0 - 1.0, should be <= vol_max) + float32_t reverb_send; // how much signal to send to the reverb (0.0 - 1.0) +} drum_config_t; + +extern drum_config_t drum_config[NUM_DRUMSET_CONFIG]; /****************************************************************************** SD BANK/VOICE LOADING @@ -774,7 +788,7 @@ bool save_sd_fx_json(uint8_t fx) } bool load_sd_seq_drumsettings_json(uint8_t number) -{ +{ // test function , to save drumsettings for use in sequencer, so storing in the SEQ_Path for now if (number < 0) return (false); @@ -809,17 +823,15 @@ bool load_sd_seq_drumsettings_json(uint8_t number) serializeJsonPretty(data_json, Serial); Serial.println(); #endif + drums_volume = data_json["drums_volume"]; - // drums_volume = data_json["drums_volume"]; - - for (uint8_t i = 0; i < 20; i++) // needs to replaced by NUM_DRUMSET_CONFIG but does not work + 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]; + 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]; } - //set_fx_params(); return (true); } @@ -845,7 +857,7 @@ bool load_sd_seq_drumsettings_json(uint8_t number) } bool save_sd_seq_drumsettings_json(uint8_t number) -{ +{ // test function , to save drumsettings for use in sequencer, since storing in the SEQ_Path for now char filename[FILENAME_LEN]; number = constrain(number, 0, 99); @@ -863,17 +875,22 @@ bool save_sd_seq_drumsettings_json(uint8_t number) #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; + data_json["drums_volume"] = drums_volume; - for (uint8_t i = 0; i < 20; i++) // needs to be replaced by NUM_DRUMSET_CONFIG + 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; + 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:")); @@ -905,6 +922,8 @@ bool save_sd_seq_json(uint8_t seq_number) int count = 0; seq_number = constrain(seq_number, 0, 99); + save_sd_seq_drumsettings_json(seq_number); + if (sd_card > 0) { File json; @@ -1024,6 +1043,7 @@ bool load_sd_seq_json(uint8_t seq_number) seq_number = constrain(seq_number, 0, 99); + load_sd_seq_drumsettings_json(seq_number); if (sd_card > 0) { File json; diff --git a/drums.h b/drums.h index f5a893a..35517a5 100644 --- a/drums.h +++ b/drums.h @@ -49,7 +49,6 @@ enum {DRUM_NONE, DRUM_BASS, DRUM_SNARE, DRUM_HIHAT, DRUM_HANDCLAP, DRUM_RIDE, DR // DEFAULT MIDI CHANNEL FOR SAMPLEDRUMS uint8_t drum_midi_channel=10; -#define NUM_DRUMSET_CONFIG 20 drum_config_t drum_config[NUM_DRUMSET_CONFIG] = { {