From bc5513aaaf3ae6192d93e25e7245ccd5fcb5d978 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Fri, 25 Jun 2021 19:55:12 +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 --- MicroDexed.ino | 7 +++++-- UI.hpp | 38 ++++++++++++++++++++++++++------------ config.h | 3 +++ synth_dexed.cpp | 29 ++++++++++++++++++----------- synth_dexed.h | 5 ++++- 5 files changed, 56 insertions(+), 26 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index a115f7c..e1082ad 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -241,13 +241,16 @@ char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; char receive_bank_filename[FILENAME_LEN]; uint8_t selected_instance_id = 0; -int perform_attack_mod = 0; -int perform_release_mod = 0; + #ifdef TEENSY4 #if NUM_DEXED>1 int8_t midi_decay[NUM_DEXED] = { -1, -1}; +int perform_attack_mod[NUM_DEXED] = { 0, 0}; +int perform_release_mod[NUM_DEXED] = { 0, 0}; #else int8_t midi_decay[NUM_DEXED] = { -1}; +int perform_attack_mod[NUM_DEXED] = { 0 }; +int perform_release_mod[NUM_DEXED] = { 0 }; #endif elapsedMillis midi_decay_timer; #endif diff --git a/UI.hpp b/UI.hpp index c13e298..e8cdd06 100644 --- a/UI.hpp +++ b/UI.hpp @@ -101,8 +101,8 @@ extern AudioAnalyzePeak master_peak_l; extern char sd_string[LCD_cols + 1]; extern char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; extern char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; -extern int perform_attack_mod; -extern int perform_release_mod; +extern int perform_attack_mod[NUM_DEXED]; +extern int perform_release_mod[NUM_DEXED]; /*********************************************************************** GLOBAL ************************************************************************/ @@ -3766,8 +3766,11 @@ void UI_func_voice_select(uint8_t param) int8_t voice_tmp; // Reset Performance Modifiers to 0 after every preset change - perform_attack_mod=0; - perform_release_mod=0; + for (uint8_t count_tmp = 0; count_tmp < NUM_DEXED; count_tmp++) + { + perform_attack_mod[count_tmp] = 0; + perform_release_mod[count_tmp] = 0; + } active_perform_page = 1; if (LCDML.BT_checkUp()) @@ -4045,7 +4048,7 @@ void UI_func_volume(uint8_t param) lcd.setCursor(0, 1); lcd.print("Attack = "); lcd.setCursor(13, 1); - sprintf(tmp, "%03d", perform_attack_mod); + sprintf(tmp, "%03d", perform_attack_mod[selected_instance_id]); lcd.print(tmp); back_from_volume = 0; } @@ -4057,7 +4060,7 @@ void UI_func_volume(uint8_t param) lcd.setCursor(11, 1); lcd.print("Release = "); lcd.setCursor(13, 1); - sprintf(tmp, "%03d", perform_release_mod); + sprintf(tmp, "%03d", perform_release_mod[selected_instance_id]); lcd.print(tmp); back_from_volume = 0; } @@ -4107,11 +4110,16 @@ void UI_func_volume(uint8_t param) if (LCDML.BT_checkDown() ) { - perform_attack_mod = constrain(perform_attack_mod + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + perform_attack_mod[selected_instance_id] = constrain(perform_attack_mod[selected_instance_id] + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + for (uint8_t i = 0; i < 6; i++) + MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, MicroDexed[selected_instance_id]->getRateOP(i, ATTACK) - perform_attack_mod[selected_instance_id] ); } else if (LCDML.BT_checkUp() ) { - perform_attack_mod = constrain(perform_attack_mod - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + perform_attack_mod[selected_instance_id] = constrain(perform_attack_mod[selected_instance_id] - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + for (uint8_t i = 0; i < 6; i++) + MicroDexed[selected_instance_id]->setRateOP(i, ATTACK, MicroDexed[selected_instance_id]->getRateOP(i, ATTACK) - perform_attack_mod[selected_instance_id] ); + } @@ -4121,11 +4129,17 @@ void UI_func_volume(uint8_t param) if (LCDML.BT_checkDown() ) { - perform_release_mod = constrain(perform_release_mod + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + perform_release_mod[selected_instance_id] = constrain(perform_release_mod[selected_instance_id] + ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + for (uint8_t i = 0; i < 6; i++) + MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, MicroDexed[selected_instance_id]->getRateOP(i, RELEASE) - perform_release_mod[selected_instance_id] ); + } else if (LCDML.BT_checkUp() ) { - perform_release_mod = constrain(perform_release_mod - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + perform_release_mod[selected_instance_id] = constrain(perform_release_mod[selected_instance_id] - ENCODER[ENC_L].speed(), -MAX_PERF_MOD, MAX_PERF_MOD); + for (uint8_t i = 0; i < 6; i++) + MicroDexed[selected_instance_id]->setRateOP(i, RELEASE, MicroDexed[selected_instance_id]->getRateOP(i, RELEASE) - perform_release_mod[selected_instance_id] ); + } } } @@ -4146,7 +4160,7 @@ void UI_func_volume(uint8_t param) lcd.setCursor(0, 1); lcd.print("Attack = "); lcd.setCursor(13, 1); - sprintf(tmp, "%03d", perform_attack_mod); + sprintf(tmp, "%03d", perform_attack_mod[selected_instance_id]); lcd.print(tmp); back_from_volume = 0; } @@ -4156,7 +4170,7 @@ void UI_func_volume(uint8_t param) lcd.setCursor(0, 1); lcd.print("Release = "); lcd.setCursor(13, 1); - sprintf(tmp, "%03d", perform_release_mod); + sprintf(tmp, "%03d", perform_release_mod[selected_instance_id]); lcd.print(tmp); back_from_volume = 0; } diff --git a/config.h b/config.h index d4a9c29..e314618 100644 --- a/config.h +++ b/config.h @@ -250,6 +250,9 @@ #define ENC_R_PIN_A 6 #define ENC_R_PIN_B 5 #define BUT_R_PIN 8 +//#define ENC_R_PIN_A 17 +//#define ENC_R_PIN_B 16 +//#define BUT_R_PIN 5 #else // ARDUINO_TEENSY41 #define ENC_R_PIN_A 24 #define ENC_R_PIN_B 5 diff --git a/synth_dexed.cpp b/synth_dexed.cpp index 341232d..68baae8 100644 --- a/synth_dexed.cpp +++ b/synth_dexed.cpp @@ -1114,6 +1114,24 @@ void Dexed::setLevelOP(uint8_t op, uint8_t step, uint8_t level) data[(op * 21) + DEXED_OP_EG_L1 + step] = level; } +uint8_t Dexed::getRateOP(uint8_t op, uint8_t step) +{ + op = constrain(op, 0, 5); + step = constrain(step, 0, 3); + + return (data[(op * 21) + DEXED_OP_EG_R1 + step]); +} + +uint8_t Dexed::getLevelOP(uint8_t op, uint8_t step) +{ + op = constrain(op, 0, 5); + step = constrain(step, 0, 3); + + return (data[(op * 21) + DEXED_OP_EG_L1 + step]); +} + + + /* // https://www.musicdsp.org/en/latest/Effects/169-compressor.html# void compress @@ -1351,17 +1369,6 @@ void Dx7Note::init(const uint8_t patch[156], int midinote, int velocity, int src levels[i] = patch[off + 4 + i]; } - // Live Modifiers for Attack and Release - // So far no sanity checks for <0 or similar since i have not experienced any problems without them. - // The macro itself is still work to do - finding the best working relation for most of the presets. - if (perform_attack_mod != 0 || perform_release_mod != 0) - { - rates[1] = rates[1] - perform_attack_mod; - rates[2] = rates[2] - perform_release_mod * 2; - rates[3] = rates[3] - perform_release_mod; - } - // Modifiers End - int outlevel = patch[off + 16]; outlevel = Env::scaleoutlevel(outlevel); int level_scaling = ScaleLevel(midinote, patch[off + 8], patch[off + 9], diff --git a/synth_dexed.h b/synth_dexed.h index cb35296..d860687 100644 --- a/synth_dexed.h +++ b/synth_dexed.h @@ -1010,7 +1010,7 @@ enum DexedVoiceParameters { enum ADSR { ATTACK, - DECAY; + DECAY, SUSTAIN, RELEASE }; @@ -1097,6 +1097,9 @@ class Dexed void setLevelOPAllModulator(uint8_t step, uint8_t level); void setRateOP(uint8_t op, uint8_t step, uint8_t rate); void setLevelOP(uint8_t op, uint8_t step, uint8_t level); + uint8_t getRateOP(uint8_t op, uint8_t step); + uint8_t getLevelOP(uint8_t op, uint8_t step); + ProcessorVoice voices[MAX_NOTES]; Controllers controllers;