From 57fd9a222933779f9ba58d038bcae3aeefc697ca Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 21 Nov 2019 09:17:27 +0100 Subject: [PATCH] Fixing bank and voice boundaries. Adding possibility to fine tune +/- 99 cent (with automatic transpose reconfiguration when tuning down). --- MicroDexed.ino | 12 ++++++------ UI.hpp | 24 ++++++++++++++++++------ config.h | 6 +++--- dexed.cpp | 2 ++ dexed_sysex.cpp | 10 +++++----- dx7note.cpp | 2 +- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index db10acf..9bc4b97 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -319,7 +319,7 @@ void setup() Serial.print(F("/")); Serial.print(bank_name[instance_id]); Serial.println(F("]")); - for (uint8_t n = 0; n < MAX_VOICES; n++) + for (uint8_t n = 0; n < MAX_VOICES - 1; n++) { if (n < 10) Serial.print(F(" ")); @@ -584,7 +584,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) switch (inCtrl) { case 0: - if (inValue < MAX_BANKS) + if (inValue < MAX_BANKS - 1) { configuration.dexed[instance_id].bank = inValue; } @@ -618,7 +618,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) #ifdef DEBUG Serial.println(F("VOLUME CC")); #endif - configuration.dexed[instance_id].loudness = map(inValue, 0, 0x7f,LOUDNESS_MIN, LOUDNESS_MAX); + configuration.dexed[instance_id].loudness = map(inValue, 0, 0x7f, LOUDNESS_MIN, LOUDNESS_MAX); MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].loudness, LOUDNESS_MIN, LOUDNESS_MAX, 0.0, 1.0); break; case 10: // Pan @@ -722,7 +722,7 @@ void handleProgramChange(byte inChannel, byte inProgram) { if (checkMidiChannel(inChannel, instance_id)) { - if (inProgram < MAX_VOICES) + if (inProgram < MAX_VOICES - 1) { #ifdef DISPLAY_LCD_SPI change_disp_sd(false); @@ -1181,8 +1181,8 @@ void check_configuration(void) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel, MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); - configuration.dexed[instance_id].bank = constrain(configuration.dexed[instance_id].bank, 0, MAX_BANKS); - configuration.dexed[instance_id].voice = constrain(configuration.dexed[instance_id].voice, 0, MAX_VOICES); + configuration.dexed[instance_id].bank = constrain(configuration.dexed[instance_id].bank, 0, MAX_BANKS - 1); + configuration.dexed[instance_id].voice = constrain(configuration.dexed[instance_id].voice, 0, MAX_VOICES - 1); configuration.dexed[instance_id].reverb_send = constrain(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX); configuration.dexed[instance_id].chorus_send = constrain(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX); configuration.dexed[instance_id].delay_send = constrain(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX); diff --git a/UI.hpp b/UI.hpp index cf9a4b3..b9a5a10 100644 --- a/UI.hpp +++ b/UI.hpp @@ -577,7 +577,7 @@ void encoder_right_up(void) switch (menu_voice) { case MENU_VOICE_BANK: - if (configuration.dexed[instance_id].bank < MAX_BANKS) + if (configuration.dexed[instance_id].bank < MAX_BANKS - 1) { configuration.dexed[instance_id].bank++; #ifdef DISPLAY_LCD_SPI @@ -596,7 +596,7 @@ void encoder_right_up(void) configuration.dexed[instance_id].voice++; else { - if (configuration.dexed[instance_id].bank < MAX_BANKS) + if (configuration.dexed[instance_id].bank < MAX_BANKS - 1) { configuration.dexed[instance_id].bank++; configuration.dexed[instance_id].voice = 0; @@ -1619,6 +1619,8 @@ void UI_func_tune(uint8_t param) // setup function lcd.setCursor(0, 0); lcd.print(F("Tune")); + lcd.setCursor(6, 1); + lcd.print(F("cent")); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -1633,6 +1635,11 @@ void UI_func_tune(uint8_t param) { if (configuration.dexed[instance_id].tune < TUNE_MAX) { + if (configuration.dexed[instance_id].tune == 99) + { + MicroDexed[instance_id]->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_TRANSPOSE]++; + configuration.dexed[instance_id].transpose++; + } configuration.dexed[instance_id].tune++; } } @@ -1640,17 +1647,22 @@ void UI_func_tune(uint8_t param) { if (configuration.dexed[instance_id].tune > TUNE_MIN) { + if (configuration.dexed[instance_id].tune == 100) + { + MicroDexed[instance_id]->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_TRANSPOSE]--; + configuration.dexed[instance_id].transpose--; + } configuration.dexed[instance_id].tune--; } } MicroDexed[instance_id]->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] = configuration.dexed[instance_id].tune; - MicroDexed[instance_id]->controllers.masterTune = (MicroDexed[instance_id]->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] / 10 * 0x4000 << 11) * (1.0 / 12); + MicroDexed[instance_id]->controllers.masterTune = (int(MicroDexed[instance_id]->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] % 100 / 100.0 * 0x4000) << 11) * (1.0 / 12); MicroDexed[instance_id]->doRefreshVoice(); } lcd.setCursor(0, 1); - lcd_display_int(configuration.dexed[instance_id].tune, 2, true, true, false); + lcd_display_int(configuration.dexed[instance_id].tune - 100, 1, false, true, true); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2719,10 +2731,10 @@ void UI_func_portamento_mode(uint8_t param) switch (configuration.dexed[instance_id].portamento_mode) { case 0: - lcd.print(F("[RETAIN ]")); + lcd.print(F("[RETAIN]")); break; case 1: - lcd.print(F("[FOLLOW ]")); + lcd.print(F("[FOLLOW]")); break; } } diff --git a/config.h b/config.h index c0308be..90977ec 100644 --- a/config.h +++ b/config.h @@ -336,9 +336,9 @@ enum { DEXED, REVERB, DELAY, CHORUS }; #define TRANSPOSE_MAX 48 #define TRANSPOSE_DEFAULT 12 -#define TUNE_MIN 0 -#define TUNE_MAX 10 -#define TUNE_DEFAULT 0 +#define TUNE_MIN 1 +#define TUNE_MAX 199 +#define TUNE_DEFAULT 100 #define LOUDNESS_MIN 0 #define LOUDNESS_MAX 100 diff --git a/dexed.cpp b/dexed.cpp index 23f025e..d3706dc 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -331,6 +331,8 @@ void Dexed::setMonoMode(bool mode) { if (monoMode == mode) return; + //panic(); + notesOff(); monoMode = mode; } diff --git a/dexed_sysex.cpp b/dexed_sysex.cpp index 3beff96..78f6cb4 100644 --- a/dexed_sysex.cpp +++ b/dexed_sysex.cpp @@ -72,7 +72,7 @@ bool get_voice_names_from_bank(uint8_t b, uint8_t instance_id) int32_t bulk_checksum_calc = 0; int8_t bulk_checksum; - b %= MAX_BANKS; + b = constrain(b, 0, MAX_BANKS - 1); // erase all data for voice names memset(voice_names[instance_id], 0, MAX_VOICES * VOICE_NAME_LEN); @@ -223,8 +223,8 @@ bool load_sysex(uint8_t b, uint8_t v, uint8_t instance_id) #if DEBUG bool found = false; #endif - v = constrain(v, 0, MAX_VOICES); - b = constrain(b, 0, MAX_BANKS); + v = constrain(v, 0, MAX_VOICES - 1); + b = constrain(b, 0, MAX_BANKS - 1); if (sd_card_available) { @@ -459,8 +459,8 @@ bool load_sysex_setup(uint8_t b, uint8_t v, uint8_t instance_id) #if DEBUG bool found = false; #endif - v %= MAX_VOICES; - b %= MAX_BANKS; + v = constrain(v, 0, MAX_VOICES - 1); + b = constrain(b, 0, MAX_BANKS - 1); if (sd_card_available) { diff --git a/dx7note.cpp b/dx7note.cpp index 0124ee5..03eab83 100644 --- a/dx7note.cpp +++ b/dx7note.cpp @@ -340,7 +340,7 @@ void Dx7Note::peekVoiceStatus(VoiceStatus &status) { } /** - Used in monophonic mode to transfert voice state from different notes + Used in monophonic mode to transfer voice state from different notes */ void Dx7Note::transferState(Dx7Note &src) { for (int i = 0; i < 6; i++) {