From 54252dd92d12c6bbb080e75d4ae942561550d565 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 19 Jul 2018 15:32:21 +0200 Subject: [PATCH] Added freeverbs. Fixed panorama placement in stereo output. --- MicroDexed.ino | 34 +++++++++++++++++++++++----------- config.h | 4 +++- dexed.cpp | 20 ++++++++++++++++++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 2639b97..cd7733f 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -51,15 +51,19 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce #endif // GUItool: begin automatically generated code -AudioPlayQueue queue1; //xy=950,406 -AudioAmplifier amp2; //xy=1172,438 -AudioAmplifier amp1; //xy=1173,378 -AudioOutputI2S i2s1; //xy=1321,403 -AudioConnection patchCord1(queue1, amp1); -AudioConnection patchCord2(queue1, amp2); -AudioConnection patchCord3(amp2, 0, i2s1, 1); -AudioConnection patchCord4(amp1, 0, i2s1, 0); -AudioControlSGTL5000 sgtl5000_1; //xy=1323,459 +AudioPlayQueue queue1; //xy=637,396 +AudioEffectFreeverbStereo freeverbs1; //xy=815,506 +AudioMixer4 mixer2; //xy=1014,461 +AudioMixer4 mixer1; //xy=1016,376 +AudioOutputI2S i2s1; //xy=1214,414 +AudioConnection patchCord1(queue1, freeverbs1); +AudioConnection patchCord2(queue1, 0, mixer1, 0); +AudioConnection patchCord3(queue1, 0, mixer2, 0); +AudioConnection patchCord4(freeverbs1, 0, mixer1, 1); +AudioConnection patchCord5(freeverbs1, 1, mixer2, 1); +AudioConnection patchCord6(mixer2, 0, i2s1, 1); +AudioConnection patchCord7(mixer1, 0, i2s1, 0); +AudioControlSGTL5000 sgtl5000_1; //xy=1214,469 // GUItool: end automatically generated code Dexed* dexed = new Dexed(SAMPLE_RATE); @@ -129,8 +133,16 @@ void setup() AudioMemory(AUDIO_MEM); sgtl5000_1.enable(); sgtl5000_1.volume(VOLUME); - amp1.gain(0.5); - amp2.gain(0.5); + + // configure mixer + mixer1.gain(0,1.0); // normal audio + mixer2.gain(0,0.2); // reverb audio + mixer1.gain(0,1.0); // normal audio + mixer2.gain(0,0.2); // reverb audio + + // configure reverb + freeverbs1.roomsize(DEFAULT_REVERB_ROOMSIZE); + freeverbs1.damping(DEFAULT_REVERB_DAMPING); // start SD card SPI.setMOSI(SDCARD_MOSI_PIN); diff --git a/config.h b/config.h index b022ced..1d88804 100644 --- a/config.h +++ b/config.h @@ -32,8 +32,10 @@ #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXSOUND 0 +#define DEFAULT_REVERB_ROOMSIZE 0.5 +#define DEFAULT_REVERB_DAMPING 0.5 //#define DEXED_ENGINE DEXED_ENGINE_MODERN -#define AUDIO_MEM 4 +#define AUDIO_MEM 32 #if !defined(__MK66FX1M0__) // check for Teensy-3.6 #define MAX_NOTES 11 // No? diff --git a/dexed.cpp b/dexed.cpp index 5dcb875..b3b3a3f 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -44,6 +44,9 @@ extern bool load_sysex(uint8_t bank, uint8_t voice_number); extern AudioControlSGTL5000 sgtl5000_1; extern AudioAmplifier amp1; extern AudioAmplifier amp2; +extern AudioEffectFreeverbStereo freeverbs1; +extern AudioMixer4 mixer2; +extern AudioMixer4 mixer1; Dexed::Dexed(int rate) { @@ -235,8 +238,21 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) sgtl5000_1.volume(float(value) / 0x7f); break; case 10: // Pan - amp1.gain(float(0x7f-value)/0x7f); - amp2.gain(float(value) / 0x7f); + if (value < 64) + { + mixer1.gain(0, 1.0); + mixer2.gain(0, float(value) / 0x40); + } + else if (value > 64) + { + mixer1.gain(0, float(0x7f - value) / 0x40); + mixer2.gain(0, 1.0); + } + else + { + mixer1.gain(0, 1.0); + mixer2.gain(0, 1.0); + } break; case 32: // BankSelect LSB bank = data2;