From b8015f455f01de8d2e17ac7cc656a2e2348b371a Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 20 Jul 2018 13:14:31 +0200 Subject: [PATCH] Fix reading voice/bank data from EEPROM. Simple loudness reduction changed. Added MIDI CC 121 (reset controllers) and 126/127 (set mono on/off). --- MicroDexed.ino | 5 ++++- config.h | 8 +++++--- dexed.cpp | 32 +++++++++++++++++++++++++------- dexed.h | 1 + 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 3b90e59..8eec052 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -159,8 +159,11 @@ void setup() // load default SYSEX data load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); - #ifdef DEBUG + Serial.print(F("Bank/Voice from EEPROM: ")); + Serial.print(EEPROM.read(EEPROM_BANK_ADDR), DEC); + Serial.print(F("/")); + Serial.println(EEPROM.read(EEPROM_VOICE_ADDR), DEC); show_patch(); #endif diff --git a/config.h b/config.h index ae33304..6ec4520 100644 --- a/config.h +++ b/config.h @@ -2,7 +2,8 @@ MicroDexed MicroDexed is a port of the Dexed sound engine - (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield. Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield. + Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android (c)2018 H. Wirtz @@ -55,7 +56,7 @@ // Some optimizations #define USE_TEENSY_DSP 1 #define SUM_UP_AS_INT 1 -#define REDUCE_LOUDNESS 2 +#define REDUCE_LOUDNESS 1 // Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard //#define TEST_NOTE MIDI_E2 @@ -78,5 +79,6 @@ #define INITIAL_ENC1_VALUE 0 // EEPROM address -#define EEPROM_VOICE_ADDR 0 #define EEPROM_BANK_ADDR 0 +#define EEPROM_VOICE_ADDR 1 + diff --git a/dexed.cpp b/dexed.cpp index 54a4782..7559376 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -65,13 +65,7 @@ Dexed::Dexed(int rate) max_notes = 16; currentNote = 0; - controllers.values_[kControllerPitch] = 0x2000; - controllers.values_[kControllerPitchRange] = 0; - controllers.values_[kControllerPitchStep] = 0; - controllers.modwheel_cc = 0; - controllers.foot_cc = 0; - controllers.breath_cc = 0; - controllers.aftertouch_cc = 0; + resetControllers(); controllers.masterTune = 0; controllers.opSwitch = 0x3f; // enable all operators //controllers.opSwitch=0x00; @@ -263,10 +257,22 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) panic(); return (true); break; + case 121: + resetControllers(); + return (true); + break; case 123: notesOff(); return (true); break; + case 126: + setMonoMode(true); + return (true); + break; + case 127: + setMonoMode(false); + return (true); + break; } break; } @@ -533,6 +539,18 @@ void Dexed::panic(void) { } } +void Dexed::resetControllers(void) +{ + controllers.values_[kControllerPitch] = 0x2000; + controllers.values_[kControllerPitchRange] = 0; + controllers.values_[kControllerPitchStep] = 0; + controllers.modwheel_cc = 0; + controllers.foot_cc = 0; + controllers.breath_cc = 0; + controllers.aftertouch_cc = 0; + controllers.refresh(); +} + void Dexed::notesOff(void) { for (uint8_t i = 0; i < MAX_ACTIVE_NOTES; i++) { if (voices[i].live == true && voices[i].keydown == true) { diff --git a/dexed.h b/dexed.h index 914e80c..015c5ad 100644 --- a/dexed.h +++ b/dexed.h @@ -147,6 +147,7 @@ class Dexed bool processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2); void panic(void); void notesOff(void); + void resetControllers(void); void setMaxNotes(uint8_t n); void doRefreshVoice(void); void setOPs(uint8_t ops);