From 54270ec9804304c685af10369d6d55ad52ad7ede Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sat, 18 Sep 2021 18:33:06 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.h | 2 +- dexed_sd.cpp | 50 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/config.h b/config.h index 3a78e7c..b5e9e5d 100644 --- a/config.h +++ b/config.h @@ -666,7 +666,7 @@ // Buffer-size define for load/save configuration as JSON -#define JSON_BUFFER_SIZE 7168 +#define JSON_BUFFER_SIZE 8192 // Internal configuration structure typedef struct dexed_s { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 32bd4ae..8161d22 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -54,7 +54,7 @@ extern uint8_t seq_chord_key_ammount; extern uint8_t seq_element_shift; extern int seq_oct_shift; extern int seq_transpose; -extern int seq_tempo_ms ; +extern int seq_tempo_ms; extern int seq_bpm; extern bool arp_play_basenote; extern bool seq_running; @@ -64,6 +64,8 @@ extern uint8_t arp_style; extern uint8_t seq_chord_velocity; extern uint8_t seq_chord_dexed_inst; extern uint8_t seq_inst_dexed[NUM_SEQ_TRACKS]; +extern uint8_t seq_step; +extern uint8_t seq_chain_active_step; extern char seq_name[FILENAME_LEN]; extern char seq_name_temp[FILENAME_LEN]; extern PeriodicTimer timer1; @@ -75,6 +77,10 @@ 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 void handleStop(void); +extern void handleStart(void); +extern void dac_mute(void); +extern void dac_unmute(void); 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); @@ -492,7 +498,7 @@ bool load_sd_drumsettings_json(uint8_t number, uint8_t target) 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) ) + ( 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] ); @@ -1072,7 +1078,14 @@ bool save_sd_seq_json(uint8_t seq_number) { char filename[FILENAME_LEN]; int count = 0; + bool seq_was_running = false; seq_number = constrain(seq_number, 0, 99); + if (seq_running == true ) { + seq_was_running = true; + handleStop(); + } + dac_mute(); + AudioNoInterrupts(); save_sd_seq_sub_vel_json(seq_number); save_sd_seq_sub_patterns_json(seq_number); sprintf(filename, "/%s/%d-fx.json", SEQ_CONFIG_PATH, seq_number); @@ -1106,7 +1119,6 @@ bool save_sd_seq_json(uint8_t seq_number) int columns = sizeof(seq_patternchain[0]); int rows = total / columns; Serial.print(F(" ")); - AudioNoInterrupts(); SD.begin(); SD.remove(filename); json = SD.open(filename, FILE_WRITE); @@ -1164,6 +1176,9 @@ bool save_sd_seq_json(uint8_t seq_number) serializeJsonPretty(data_json, json); json.close(); AudioInterrupts(); + dac_unmute(); + if (seq_was_running == true ) + handleStart(); return (true); } json.close(); @@ -1219,9 +1234,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); - if (sd_card > 0) { File json; @@ -1289,9 +1302,7 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number) { if (seq_number < 0) return (false); - seq_number = constrain(seq_number, 0, 99); - if (sd_card > 0) { File json; @@ -1359,14 +1370,20 @@ bool load_sd_seq_sub_patterns_json(uint8_t seq_number) bool load_sd_seq_json(uint8_t seq_number) { + bool seq_was_running = false; if (seq_number < 0) return (false); - + if (seq_running) + { + seq_was_running = true; + seq_running = false; + } + dac_mute(); + handleStop(); + AudioNoInterrupts(); seq_number = constrain(seq_number, 0, 99); - load_sd_seq_sub_patterns_json(seq_number); load_sd_seq_sub_vel_json(seq_number); - load_sd_fx_json(seq_number, 1); if (sd_card > 0) @@ -1374,11 +1391,8 @@ bool load_sd_seq_json(uint8_t seq_number) File json; StaticJsonDocument data_json; char filename[FILENAME_LEN]; - sprintf(filename, "/%s/%d-S.json", SEQ_CONFIG_PATH, seq_number); - // first check if file exists... - AudioNoInterrupts(); if (SD.exists(filename)) { // ... and if: load @@ -1392,10 +1406,8 @@ bool load_sd_seq_json(uint8_t seq_number) if (json) { deserializeJson(data_json, json); - json.close(); AudioInterrupts(); - #ifdef DEBUG Serial.println(F("Read JSON data:")); serializeJsonPretty(data_json, Serial); @@ -1465,8 +1477,14 @@ bool load_sd_seq_json(uint8_t seq_number) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) set_voiceconfig_params(instance_id); set_fx_params(); - if (seq_running) + dac_unmute(); + seq_step = 0; + seq_chain_active_step = 0; + if (seq_was_running) + { timer1.begin(sequencer, seq_tempo_ms / 2); + seq_running = true; + } else timer1.begin(sequencer, seq_tempo_ms / 2, false); return (true); From 0d922669bc0d01112b3517ab353bdbe1ceeba4ee Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sat, 18 Sep 2021 18:33:31 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI.hpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/UI.hpp b/UI.hpp index 0c97bff..3949d11 100644 --- a/UI.hpp +++ b/UI.hpp @@ -5217,8 +5217,7 @@ void UI_func_seq_pattern_editor(uint8_t param) { if (seq_running == false && seq_recording == false) { - seq_running = true; - timer1.start(); + handleStart(); } else if (seq_running == true && seq_recording == false) { seq_running = true; @@ -5226,13 +5225,7 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_note_in = 0; } else if (seq_running == true && seq_recording == true) { - seq_running = false; - seq_recording = false; - seq_note_in = 0; - seq_step = 0; - seq_chain_active_step = 0; - timer1.stop(); - MicroDexed[0]->panic(); + handleStop(); } } else if ( seq_menu == 2 && seq_active_function != 40) { @@ -5716,11 +5709,7 @@ void UI_func_arpeggio(uint8_t param) if (seq_running) { seq_running = !seq_running; - timer1.stop(); - MicroDexed[0]->panic(); -#if NUM_DEXED > 1 - MicroDexed[1]->panic(); -#endif + handleStop(); arp_refresh_display_play_status(); seq_step = 0; arp_octave = 0; @@ -5730,7 +5719,7 @@ void UI_func_arpeggio(uint8_t param) { seq_running = !seq_running; arp_refresh_display_play_status(); - timer1.start(); + handleStart(); } } else if ( seq_temp_select_menu == 3 && seq_temp_active_menu == 0 ) From 0fbadbac92533f97c76e37cf18be30fdfb33a676 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sat, 18 Sep 2021 18:33:50 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MicroDexed.ino | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index f7cd558..cf28bcb 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1676,11 +1676,29 @@ void handleClock(void) midi_bpm_counter++; } +void dac_mute(void) +{ + sgtl5000.lineOutLevel(0.0); + sgtl5000.dacVolume(0.0); + sgtl5000.volume(0.0, 0.0); // Headphone volume +} + +void dac_unmute(void) +{ + sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL); + sgtl5000.dacVolume(1.0); + sgtl5000.volume(SGTL5000_HEADPHONE_VOLUME, SGTL5000_HEADPHONE_VOLUME); // Headphone volume +} void handleStart(void) { midi_bpm_timer = 0; midi_bpm_counter = 0; _midi_bpm = -1; + seq_step = 0; + seq_chain_active_step = 0; + seq_running = true; + timer1.start(); + } void handleContinue(void) @@ -1690,7 +1708,17 @@ void handleContinue(void) void handleStop(void) { - ; + timer1.stop(); + seq_running = false; + seq_recording = false; + seq_note_in = 0; + seq_step = 0; + seq_chain_active_step = 0; + + MicroDexed[0]->panic(); +#if NUM_DEXED > 1 + MicroDexed[1]->panic(); +#endif } void handleActiveSensing(void) From ad95a78c97f51dc61741ca2ce64e18b5baeca149 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Sat, 18 Sep 2021 18:36:02 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI.hpp | 4 ++-- config.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/UI.hpp b/UI.hpp index 3949d11..efa94f9 100644 --- a/UI.hpp +++ b/UI.hpp @@ -5225,7 +5225,7 @@ void UI_func_seq_pattern_editor(uint8_t param) seq_note_in = 0; } else if (seq_running == true && seq_recording == true) { - handleStop(); + handleStop(); } } else if ( seq_menu == 2 && seq_active_function != 40) { @@ -5709,7 +5709,7 @@ void UI_func_arpeggio(uint8_t param) if (seq_running) { seq_running = !seq_running; - handleStop(); + handleStop(); arp_refresh_display_play_status(); seq_step = 0; arp_octave = 0; diff --git a/config.h b/config.h index b5e9e5d..f77b5b4 100644 --- a/config.h +++ b/config.h @@ -119,15 +119,15 @@ #define DRUM_MIDI_CHANNEL 10 // NUMBER OF SAMPLES IN DRUMSET -#if defined(ARDUINO_TEENSY41) +#if defined(ARDUINO_TEENSY41) #define NUM_DRUMSET_CONFIG 71 #elif defined(TEENSY4) -#define NUM_DRUMSET_CONFIG 47 +#define NUM_DRUMSET_CONFIG 47 #else -#define NUM_DRUMSET_CONFIG 22 +#define NUM_DRUMSET_CONFIG 22 #endif -// SEQUENCER +// SEQUENCER #ifdef TEENSY4 #define NUM_SEQ_PATTERN 24