From 5706e0f59df9f2362f06af46eba2ddd0664a26cf Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sat, 13 Mar 2021 11:36:09 +0100 Subject: [PATCH] Dynamic polyphony allocation now allows to distribute the voices dynamically with bitimbral engine. --- MicroDexed.ino | 2 +- UI.hpp | 23 ++++++++++++++++++++--- config.h | 24 +----------------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index f9d508b..e778cd8 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1585,7 +1585,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); - configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX); + configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony, POLYPHONY_MIN, POLYPHONY_MAX/instance_id); 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); diff --git a/UI.hpp b/UI.hpp index 947fa40..579a2af 100644 --- a/UI.hpp +++ b/UI.hpp @@ -2083,8 +2083,11 @@ void UI_func_polyphony(uint8_t param) encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 2, false, false, true); - +#if NUM_DEXED>1 + lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX - configuration.dexed[(selected_instance_id + 1) % NUM_DEXED].polyphony, 2, false, false, true); +#else + lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX].polyphony, 2, false, false, true); +#endif lcd_active_instance_number(selected_instance_id); UI_update_instance_icons(); } @@ -2095,14 +2098,25 @@ void UI_func_polyphony(uint8_t param) { if (LCDML.BT_checkDown()) { +#if NUM_DEXED>1 + if (configuration.dexed[selected_instance_id].polyphony < POLYPHONY_MAX - configuration.dexed[selected_instance_id + 1 % NUM_DEXED].polyphony) + configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony + 1, POLYPHONY_MIN, POLYPHONY_MAX - configuration.dexed[(selected_instance_id + 1) % NUM_DEXED].polyphony); +#else configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony + 1, POLYPHONY_MIN, POLYPHONY_MAX); +#endif } else if (LCDML.BT_checkUp()) { if (configuration.dexed[selected_instance_id].polyphony - 1 < 0) configuration.dexed[selected_instance_id].polyphony = 0; else + { +#if NUM_DEXED>1 + configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony - 1, POLYPHONY_MIN, POLYPHONY_MAX - configuration.dexed[(selected_instance_id + 1) % NUM_DEXED].polyphony); +#else configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony - 1, POLYPHONY_MIN, POLYPHONY_MAX); +#endif + } } #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) @@ -2115,8 +2129,11 @@ void UI_func_polyphony(uint8_t param) #endif } +#if NUM_DEXED>1 + lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX - configuration.dexed[selected_instance_id + 1 % NUM_DEXED].polyphony, 2, false, false, false); +#else lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 2, false, false, false); - +#endif MicroDexed[selected_instance_id]->setMaxNotes(configuration.dexed[selected_instance_id].polyphony); } diff --git a/config.h b/config.h index c9904ad..e4ef53e 100644 --- a/config.h +++ b/config.h @@ -306,13 +306,12 @@ // Teensy-4.x settings #ifdef TEENSY4 -#define MAX_NOTES 32 +#define MAX_NOTES 64 #endif // Teensy-3.6 settings #if defined(TEENSY3_6) # if defined(USE_FX) -# if NUM_DEXED == 1 # if F_CPU == 256000000 # define MAX_NOTES 20 # elif F_CPU == 240000000 @@ -323,19 +322,7 @@ # warning >>> You should consider to use 216MHz overclocking to get polyphony of 16 instead 12 voices <<< # define MAX_NOTES 12 # endif -# else -# if F_CPU == 256000000 -# define MAX_NOTES 8 -# elif F_CPU == 240000000 -# define MAX_NOTES 7 -# elif F_CPU == 216000000 -# define MAX_NOTES 6 -# else -# define MAX_NOTES 5 -# endif -# endif # else -# if NUM_DEXED == 1 # if F_CPU == 256000000 # define MAX_NOTES 20 # elif F_CPU == 216000000 @@ -343,15 +330,6 @@ # 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 # endif #endif