From 5377d12336f77684dc32318f349c92c25cece481 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 5 Jun 2020 10:35:39 +0200 Subject: [PATCH] Fixes for resetting sustain mode when fire up panic(). Fixes for preprocessor code for selecting the right number of voices dependent on USE_FX, CPU speed and processor. --- MicroDexed.ino | 33 +++++++---------------- UI.hpp | 3 --- config.h | 71 +++++++++++++++++++++++++++++--------------------- dexed.cpp | 1 + 4 files changed, 53 insertions(+), 55 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 407574e..3e43b22 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -236,7 +236,7 @@ extern void getNoteName(char* noteName, uint8_t noteNumber); void setup() { // Start audio system - AudioNoInterrupts(); + //AudioNoInterrupts(); AudioMemory(AUDIO_MEM); #ifdef DISPLAY_LCD_SPI @@ -259,6 +259,7 @@ void setup() #endif #endif + #ifdef DEBUG generate_version_string(version_string, sizeof(version_string)); @@ -269,7 +270,11 @@ void setup() Serial.println(version_string); Serial.print(F("CPU-Speed: ")); Serial.print(F_CPU / 1000000.0, 1); - Serial.println(F(" MHz")); + Serial.print(F(" MHz / ")); + Serial.print(NUM_DEXED, DEC); + Serial.print(F(" Instances with ")); + Serial.print(MAX_NOTES); + Serial.println(F(" notes for each instance")); Serial.println(F("")); Serial.flush(); #endif @@ -473,7 +478,7 @@ void setup() master_mixer_r.gain(3, 0.0); master_mixer_l.gain(3, 0.0); - AudioInterrupts(); + //AudioInterrupts(); #ifdef DEBUG Serial.println(F("")); @@ -1504,11 +1509,7 @@ void check_configuration(void) configuration.dexed[instance_id].pan = constrain(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX); configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose, TRANSPOSE_MIN, TRANSPOSE_MAX); configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune, TUNE_MIN, TUNE_MAX); -#if NUM_DEXED > 1 - configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony + ((POLYPHONY_MAX % 2) - instance_id) , POLYPHONY_MIN, POLYPHONY_MAX / 2); -#else configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX); -#endif configuration.dexed[instance_id].velocity_level = constrain(configuration.dexed[instance_id].velocity_level, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX); configuration.dexed[instance_id].engine = constrain(configuration.dexed[instance_id].engine, ENGINE_MIN, ENGINE_MAX); configuration.dexed[instance_id].monopoly = constrain(configuration.dexed[instance_id].monopoly, MONOPOLY_MIN, MONOPOLY_MAX); @@ -1576,11 +1577,7 @@ void init_configuration(void) configuration.dexed[instance_id].pan = PANORAMA_DEFAULT; configuration.dexed[instance_id].transpose = TRANSPOSE_DEFAULT; configuration.dexed[instance_id].tune = TUNE_DEFAULT; -#if NUM_DEXED > 1 - configuration.dexed[instance_id].polyphony = (POLYPHONY_DEFAULT / 2) + (POLYPHONY_DEFAULT % 2) - instance_id; -#else configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT; -#endif configuration.dexed[instance_id].velocity_level = VELOCITY_LEVEL_DEFAULT; configuration.dexed[instance_id].engine = ENGINE_DEFAULT; configuration.dexed[instance_id].monopoly = MONOPOLY_DEFAULT; @@ -1616,18 +1613,8 @@ void init_configuration(void) configuration.performance.bank[instance_id] = SYSEXBANK_DEFAULT; configuration.performance.voice[instance_id] = SYSEXSOUND_DEFAULT; -#if NUM_DEXED > 1 - configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT / 2; -#else - if (instance_id == 0) - { - configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT; - } - else - { - configuration.dexed[instance_id].polyphony = 0; - } -#endif + configuration.dexed[instance_id].polyphony = POLYPHONY_DEFAULT; + #if NUM_DEXED > 1 MicroDexed[instance_id]->controllers.refresh(); diff --git a/UI.hpp b/UI.hpp index 0208a02..c97b446 100644 --- a/UI.hpp +++ b/UI.hpp @@ -2041,9 +2041,6 @@ void UI_func_polyphony(uint8_t param) { if (LCDML.BT_checkDown()) { -#if NUM_DEXED > 1 - if (configuration.dexed[0].polyphony + configuration.dexed[1].polyphony + 1 <= POLYPHONY_MAX) -#endif configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony + 1, POLYPHONY_MIN, POLYPHONY_MAX); } else if (LCDML.BT_checkUp()) diff --git a/config.h b/config.h index 53ef93f..8c55f73 100644 --- a/config.h +++ b/config.h @@ -56,7 +56,7 @@ // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy-1.8.12/hardware/teensy/avr/cores/teensy3/usb_midi.h //#define USB_MIDI_SYSEX_MAX 4104 -#define VERSION "0.9.9o" +#define VERSION "0.9.9p" //************************************************************************************************* //* DEVICE SETTINGS @@ -273,40 +273,53 @@ #define USBCON 1 #endif -#if defined(__IMXRT1062__) //Teensy-4.0 -#undef MIDI_DEVICE_USB +// Teensy-4.x settings +#if defined(__IMXRT1062__) //Teensy-4.x #define MAX_NOTES 16 #define TEENSY4 #endif -#if defined(__MK66FX1M0__) // Teensy-3.6 // Teensy-3.6 settings -#define MIDI_DEVICE_USB_HOST 1 -#if defined(USE_FX) -#if NUM_DEXED == 1 -#if F_CPU >= 256 -#define MAX_NOTES 20 -#elif F_CPU >= 216 -#define MAX_NOTES 16 -#else -#define MAX_NOTES 12 -#endif // F_CPU >= 256 -#else // NUM_DEXED != 1 -#define MAX_NOTES 10 // Due to problems with lack of RAM (12 for 180MHz, 16 for 216 MHz) -#endif -#else -#if NUM_DEXED == 1 -#define MAX_NOTES 16 -#else -#if F_CPU >= 216 -#define MAX_NOTES 16 -#else -#define MAX_NOTES 13 +#if defined(__MK66FX1M0__) // Teensy-3.6 +# if defined(USE_FX) +# if NUM_DEXED == 1 +# if F_CPU == 256000000 +# define MAX_NOTES 20 +# elif F_CPU == 216000000 +# define MAX_NOTES 16 +# else +# define MAX_NOTES 12 +# endif +# else +# if F_CPU == 256000000 +# define MAX_NOTES 9 +# elif F_CPU == 216000000 +# define MAX_NOTES 7 +# else +# define MAX_NOTES 5 +# endif +# endif +# else +# if NUM_DEXED == 1 +# if F_CPU == 256000000 +# define MAX_NOTES 20 +# elif F_CPU == 216000000 +# define MAX_NOTES 20 +# else +# define MAX_NOTES 16 +# endif +# else +# if F_CPU == 256000000 +# define MAX_NOTES 20 +# elif F_CPU == 216000000 +# define MAX_NOTES 16 +# else +# define MAX_NOTES 8 +# endif +# endif +# define TEENSY3_6 +# endif #endif -#endif // NUM_DEXED == 1 -#endif // defined(USE_FX) -#define TEENSY3_6 -#endif // defined(__MK66FX1M0__) #if defined (__MK64FX512__) // Teensy-3.5 settings diff --git a/dexed.cpp b/dexed.cpp index f6f3bd6..8ab5b85 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -421,6 +421,7 @@ void Dexed::panic(void) } } } + setSustain(0); } void Dexed::resetControllers(void)