From c0b79bfc9aeb05f54c4523cef23e3131dec78a14 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sun, 12 Sep 2021 11:29:57 +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 --- config.h | 2 +- dexed_sd.cpp | 37 +++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/config.h b/config.h index d754a59..3a78e7c 100644 --- a/config.h +++ b/config.h @@ -90,7 +90,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -//#define DEBUG 1 +#define DEBUG 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 9533467..32bd4ae 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -68,18 +68,21 @@ extern char seq_name[FILENAME_LEN]; extern char seq_name_temp[FILENAME_LEN]; extern PeriodicTimer timer1; extern float midi_volume_transform(uint8_t midi_amp); +extern void set_sample_note(uint8_t sample, uint8_t note); extern void set_sample_pitch(uint8_t sample, float playbackspeed); extern void set_sample_p_offset(uint8_t sample, float s_offset); extern void set_sample_pan(uint8_t sample, float s_pan); extern void set_sample_vol_max(uint8_t sample, float s_max); extern void set_sample_vol_min(uint8_t sample, float s_min); extern void set_sample_reverb_send(uint8_t sample, float s_reverb); +extern uint8_t get_sample_note(uint8_t sample); extern float get_sample_pitch(uint8_t sample); extern float get_sample_p_offset(uint8_t sample); extern float get_sample_pan(uint8_t sample); extern float get_sample_vol_max(uint8_t sample); extern float get_sample_vol_min(uint8_t sample); extern float get_sample_reverb_send(uint8_t sample); +extern uint8_t find_drum_number_from_note(uint8_t note); /****************************************************************************** SD BANK/VOICE LOADING @@ -484,14 +487,27 @@ bool load_sd_drumsettings_json(uint8_t number, uint8_t target) #endif drums_volume = data_json["drums_volume"]; set_drums_volume(drums_volume); - for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) + for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { - set_sample_pitch( i, data_json["pitch"][i] ); - set_sample_p_offset ( i, data_json["p_offset"][i] ); - set_sample_pan( i, data_json["pan"][i]) ; - set_sample_vol_max( i, data_json["vol_max"][i]) ; - set_sample_vol_min( i, data_json["vol_min"][i] ); - set_sample_reverb_send( i, data_json["reverb_send"][i]); + 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) ) + { + set_sample_pitch( drumnumber, data_json["pitch"][i] ); + set_sample_p_offset ( drumnumber, data_json["p_offset"][i] ); + set_sample_pan( drumnumber, data_json["pan"][i]) ; + set_sample_vol_max( drumnumber, data_json["vol_max"][i]) ; + set_sample_vol_min( drumnumber, data_json["vol_min"][i] ); + set_sample_reverb_send( drumnumber, data_json["reverb_send"][i]); + //Serial.print(" drumnumber: "); + //Serial.print(drumnumber); + //Serial.print(" notenumber: "); + //Serial.print(find_drum_number_from_note( data_json["note"][i] )); + //Serial.print(" note: "); + //Serial.print( (int)data_json["note"][i] ); + //Serial.println(F(" ")); + } } return (true); } @@ -518,7 +534,6 @@ 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; @@ -533,9 +548,7 @@ bool save_sd_drumsettings_json(uint8_t number, uint8_t target) Serial.print(F(" to ")); Serial.println(filename); #endif - AudioNoInterrupts(); - if (SD.exists(filename)) { Serial.println("remove old drumsettings file"); SD.begin(); @@ -545,9 +558,9 @@ bool save_sd_drumsettings_json(uint8_t number, uint8_t target) if (json) { data_json["drums_volume"] = drums_volume; - - for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) + for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { + data_json["note"][i] = get_sample_note(i); data_json["pitch"][i] = get_sample_pitch(i); data_json["p_offset"][i] = get_sample_p_offset(i); data_json["pan"][i] = get_sample_pan(i);