diff --git a/MicroDexed.ino b/MicroDexed.ino index a9ad0fe..f9d508b 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -383,7 +383,6 @@ void setup() Serial.println(instance_id, DEC); #endif create_audio_engine_chain(instance_id); - } #if defined(USE_FX) @@ -572,15 +571,13 @@ void loop() if (midi_voices[instance_id] > 0 && midi_playing[instance_id] == false) { midi_playing[instance_id] = true; - //lcd.setCursor(14 + instance_id, 1); - lcd.setCursor(12 + instance_id, 0); + lcd.setCursor(14 + instance_id, 1); lcd.write(6 + instance_id); } else if (midi_voices[instance_id] == 0 && !MicroDexed[instance_id]->getSustain()) { midi_playing[instance_id] = false; - //lcd.setCursor(14 + instance_id, 1); - lcd.setCursor(12 + instance_id, 0); + lcd.setCursor(14 + instance_id, 1); lcd.write(20); // blank } #endif diff --git a/UI.hpp b/UI.hpp index 7088777..947fa40 100644 --- a/UI.hpp +++ b/UI.hpp @@ -170,9 +170,8 @@ const uint8_t special_chars[19][8] = { {B00000, B11111, B11111, B11111, B11111, B11111, B11111, B11111}, // [14] Level 7 {B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111}, // [15] Level 8 {B00100, B00110, B00101, B00101, B01101, B11101, B11100, B11000}, // [16] Note - //{B01110, B10001, B10001, B11111, B11011, B11011, B11111, B00000} // [17] Disabled 2nd instance symbol {B01110, B10001, B10001, B01110, B00100, B00100, B00110, B00110}, // [17] Disabled 2nd instance symbol - {B11111, B10001, B10111, B10001, B10111, B10111, B10111, B11111} // [18]Favorites Icon + {B11111, B10001, B10111, B10001, B10111, B10111, B10111, B11111} // [18] Favorites Icon }; enum { SCROLLBAR, BLOCKBAR, METERBAR }; @@ -755,7 +754,7 @@ void lcdml_menu_control(void) Serial.println(F("ENC-L long recognized")); #endif - save_favorite(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); + //save_favorite(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); //for (uint8_t i = 0; i < NUM_DEXED; i++) // MicroDexed[i]->panic(); @@ -5974,7 +5973,6 @@ bool check_favorite(uint8_t b, uint8_t v, uint8_t instance_id) } void draw_favorite_icon(uint8_t b, uint8_t v, uint8_t instance_id) - { b = constrain(b, 0, MAX_BANKS - 1); v = constrain(v, 0, MAX_VOICES - 1); @@ -5987,40 +5985,31 @@ void draw_favorite_icon(uint8_t b, uint8_t v, uint8_t instance_id) if (SD.exists(tmp)) { //is Favorite - - lcd.setCursor(15, 1); - //lcd.print("F"); + lcd.setCursor(12, 0); lcd.write(2); //fav symbol - } else { // it was not a favorite - - lcd.setCursor(15, 1); + lcd.setCursor(12, 0); lcd.print(" "); - } } } bool quick_check_favorites_in_bank(uint8_t b, uint8_t instance_id) - { b = constrain(b, 0, MAX_BANKS - 1); - char tmp[18]; if (sd_card > 0) { sprintf(tmp, "/%s/%d/hasfav", FAV_CONFIG_PATH, b); - #ifdef DEBUG Serial.print("check if there is a Favorite in Bank: "); Serial.print(tmp); Serial.println(); #endif - if (SD.exists(tmp) ) { // this bank HAS at least 1 favorite(s) #ifdef DEBUG @@ -6028,24 +6017,17 @@ bool quick_check_favorites_in_bank(uint8_t b, uint8_t instance_id) #endif return (true); } - else - { // no favorites in bank stored - - return (false); #ifdef DEBUG Serial.println(" - It is no Favorite in current Bank."); #endif } } else return false; - } - void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) - { #ifdef DEBUG Serial.println("Starting saving Favorite."); @@ -6059,9 +6041,7 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) if (sd_card > 0) { - sprintf(tmp, "/%s/%d/%d.fav", FAV_CONFIG_PATH, b, v); - #ifdef DEBUG Serial.println("Save Favorite to SD card..."); Serial.println(tmp); @@ -6085,13 +6065,11 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) } lcd.setCursor(15, 1); lcd.write(2); //fav symbol - #ifdef DEBUG Serial.println("Added to Favorites..."); #endif } else - { // delete the file, is no longer a favorite SD.remove(tmp); #ifdef DEBUG @@ -6109,11 +6087,9 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) Serial.print(countfavs); Serial.println("Removed hasfav file since no voice in bank flagged as favorite any more"); #endif - } lcd.setCursor(15, 1); lcd.print(" "); //remove fav symbol - #ifdef DEBUG Serial.println("Removed from Favorites..."); #endif diff --git a/config.h b/config.h index a582ec0..c9904ad 100644 --- a/config.h +++ b/config.h @@ -58,7 +58,7 @@ // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy4/usb_midi.h //#define USB_MIDI_SYSEX_MAX 4104 -#define VERSION "1.0.15" +#define VERSION "1.0.16" //************************************************************************************************* //* DEVICE SETTINGS @@ -94,7 +94,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -//#define DEBUG 1 +#define DEBUG 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 diff --git a/dexed.cpp b/dexed.cpp index 57c1aa4..b7d888d 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -47,6 +47,9 @@ Dexed::Dexed(int rate) { uint8_t i; + max_notes = MAX_NOTES; + setMaxNotes(max_notes); + Exp2::init(); Tanh::init(); Sin::init(); @@ -62,7 +65,7 @@ Dexed::Dexed(int rate) engineOpl = new EngineOpl; engineMsfa = new FmCore; - for (i = 0; i < MAX_ACTIVE_NOTES; i++) + for (i = 0; i < max_notes; i++) { voices[i].dx7_note = new Dx7Note; voices[i].keydown = false; @@ -71,7 +74,6 @@ Dexed::Dexed(int rate) voices[i].key_pressed_timer = 0; } - max_notes = MAX_NOTES; currentNote = 0; resetControllers(); controllers.masterTune = 0; @@ -93,7 +95,7 @@ Dexed::~Dexed() { currentNote = -1; - for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; note++) + for (uint8_t note = 0; note < max_notes; note++) delete voices[note].dx7_note; delete(engineMsfa); @@ -409,7 +411,8 @@ bool Dexed::getSustain(void) void Dexed::panic(void) { - for (uint8_t i = 0; i < MAX_ACTIVE_NOTES; i++) + //for (uint8_t i = 0; i < max_notes; i++) + for (uint8_t i = 0; i < max_notes; i++) { if (voices[i].live == true) { voices[i].keydown = false; @@ -441,7 +444,7 @@ void Dexed::resetControllers(void) } void Dexed::notesOff(void) { - for (uint8_t i = 0; i < MAX_ACTIVE_NOTES; i++) { + for (uint8_t i = 0; i < max_notes; i++) { if (voices[i].live == true) { voices[i].keydown = false; voices[i].live = false; @@ -449,15 +452,15 @@ void Dexed::notesOff(void) { } } -void Dexed::setMaxNotes(uint8_t n) { - if (n <= MAX_ACTIVE_NOTES) +/*void Dexed::setMaxNotes(uint8_t n) { + if (n <= max_notes) { notesOff(); max_notes = n; //panic(); controllers.refresh(); } -} + }*/ uint8_t Dexed::getMaxNotes(void) { @@ -765,6 +768,36 @@ void Dexed::setPortamentoMode(uint8_t portamento_mode, uint8_t portamento_glissa controllers.refresh(); } +void Dexed::setMaxNotes(uint8_t num_voices) +{ + if (voices) + { + panic(); + for (uint8_t i = 0; i < max_notes; i++) + { + if (voices[i].dx7_note) + delete voices[i].dx7_note; + voices[i].keydown = false; + voices[i].sustained = false; + voices[i].live = false; + voices[i].key_pressed_timer = 0; + } + delete(voices); + } + voices = new ProcessorVoice[num_voices]; + max_notes = num_voices; + + for (uint8_t i = 0; i < max_notes; i++) + { + voices[i].dx7_note = new Dx7Note; + voices[i].keydown = false; + voices[i].sustained = false; + voices[i].live = false; + voices[i].key_pressed_timer = 0; + } + controllers.refresh(); +} + /* // https://www.musicdsp.org/en/latest/Effects/169-compressor.html# void compress diff --git a/dexed.h b/dexed.h index 07ecb4f..47cc9b1 100644 --- a/dexed.h +++ b/dexed.h @@ -175,8 +175,11 @@ class Dexed void setBCController(uint8_t bc_range, uint8_t bc_assign, uint8_t bc_mode); void setATController(uint8_t at_range, uint8_t at_assign, uint8_t at_mode); void setPortamentoMode(uint8_t portamento_mode, uint8_t portamento_glissando, uint8_t portamento_time); + void setMaxVoices(uint8_t num_voices); + + //ProcessorVoice voices[MAX_NOTES]; + ProcessorVoice* voices = NULL; - ProcessorVoice voices[MAX_NOTES]; Controllers controllers; PluginFx fx; @@ -197,8 +200,9 @@ class Dexed int lastKeyDown; protected: - static const uint8_t MAX_ACTIVE_NOTES = MAX_NOTES; - uint8_t max_notes = MAX_ACTIVE_NOTES; + //static const uint8_t MAX_ACTIVE_NOTES = MAX_NOTES; + //uint8_t max_notes = MAX_ACTIVE_NOTES; + uint8_t max_notes = 0; int16_t currentNote; bool sustain; float vuSignal; diff --git a/Disp_Plus.h b/disp_plus.h similarity index 100% rename from Disp_Plus.h rename to disp_plus.h