From 1daf2362764a4164b1b0374f2b6c95aaf8c64b84 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 23 Oct 2019 09:17:54 +0200 Subject: [PATCH] Reworking on the audio chain. --- MicroDexed.ino | 142 ++++++++++++++++++++++--------------------------- UI.hpp | 32 +++++------ config.h | 8 +-- 3 files changed, 85 insertions(+), 97 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 888502a..aa5890b 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -42,85 +42,70 @@ AudioPlayQueue queue1; AudioAnalyzePeak peak1; AudioEffectDelay delay1; -#ifdef USE_REVERB -AudioEffectFreeverbStereo freeverbs1; -#endif AudioEffectModulatedDelay modchorus; -#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT -AudioFilterBiquad modchorus_filter; -#endif AudioSynthWaveform modulator; -AudioMixer4 chorus_mixer; -AudioMixer4 delay_mixer; AudioMixer4 delay_fb_mixer; -AudioMixer4 reverb_mixer_r; -AudioMixer4 reverb_mixer_l; +AudioMixer4 master_mixer_r; +AudioMixer4 master_mixer_l; AudioAmplifier volume_r; AudioAmplifier volume_l; -#ifdef MIDI_DEVICE_USB -AudioOutputUSB usb1; -#endif AudioConnection patchCord0(queue1, peak1); -AudioConnection patchCord1(queue1, 0, chorus_mixer, 0); -AudioConnection patchCord3(queue1, 0, delay_mixer, 0); -AudioConnection patchCord4(queue1, 0, delay_fb_mixer, 0); -#ifdef USE_REVERB -AudioConnection patchCord5(queue1, 0, reverb_mixer_r, 0); -AudioConnection patchCord6(queue1, 0, reverb_mixer_l, 0); -#endif -AudioConnection patchCord7(queue1, 0, modchorus, 0); -AudioConnection patchCord8(modulator, 0, modchorus, 1); +AudioConnection patchCord1(queue1, 0, delay_fb_mixer, 0); +AudioConnection patchCord2(queue1, 0, modchorus, 0); +AudioConnection patchCord3(queue1, 0 , master_mixer_r, 0); +AudioConnection patchCord4(queue1, 0 , master_mixer_l, 0); +AudioConnection patchCord5(modulator, 0, modchorus, 1); #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT -AudioConnection patchCord9(modchorus, modchorus_filter); -AudioConnection patchCord10(modchorus_filter, 0, chorus_mixer, 1); +AudioFilterBiquad modchorus_filter; +AudioConnection patchCord6(modchorus, modchorus_filter); +AudioConnection patchCord7(modchorus_filter, 0, master_mixer_r, 3); +AudioConnection patchCord8(modchorus_filter, 0, master_mixer_l, 3); #else -AudioConnection patchCord9(modchorus, 0, chorus_mixer, 1); +AudioConnection patchCord9(modchorus, 0, master_mixer_r, 3); +AudioConnection patchCord10(modchorus, 0, master_mixer_l, 3); #endif -AudioConnection patchCord11(chorus_mixer, 0, delay_mixer, 1); -AudioConnection patchCord12(delay_fb_mixer, 0, delay_mixer, 1); -AudioConnection patchCord13(delay_mixer, 0, reverb_mixer_r, 0); -AudioConnection patchCord14(delay_mixer, 0, reverb_mixer_l, 0); -AudioConnection patchCord15(delay1, 0, delay_mixer, 2); -AudioConnection patchCord16(delay_fb_mixer, delay1); #ifdef USE_REVERB -AudioConnection patchCord17(delay_mixer, 0, freeverbs1, 0); -AudioConnection patchCord18(delay_mixer, 0, freeverbs1, 1); -AudioConnection patchCord19(freeverbs1, 0, reverb_mixer_r, 1); -AudioConnection patchCord20(freeverbs1, 1, reverb_mixer_l, 1); -AudioConnection patchCord21(reverb_mixer_r, volume_r); -AudioConnection patchCord22(reverb_mixer_l, volume_l); -#else -AudioConnection patchCord17(delay_mixer, volume_r); -AudioConnection patchCord18(delay_mixer, volume_l); +AudioEffectFreeverbStereo freeverbs1; +AudioConnection patchCord11(queue1, 0, freeverbs1, 0); +AudioConnection patchCord12(queue1, 0, freeverbs1, 1); +AudioConnection patchCord13(freeverbs1, 0, master_mixer_r, 1); +AudioConnection patchCord14(freeverbs1, 1, master_mixer_l, 1); #endif +AudioConnection patchCord15(delay_fb_mixer, delay1); +AudioConnection patchCord16(delay1, 0, delay_fb_mixer, 1); +AudioConnection patchCord17(delay1, 0, master_mixer_r, 2); +AudioConnection patchCord18(delay1, 0, master_mixer_l, 2); +AudioConnection patchCord19(master_mixer_r, volume_r); +AudioConnection patchCord20(master_mixer_l, volume_l); #ifdef MIDI_DEVICE_USB -AudioConnection patchCord23(volume_r, 0, usb1, 0); -AudioConnection patchCord24(volume_l, 0, usb1, 1); +AudioOutputUSB usb1; +AudioConnection patchCord21(volume_r, 0, usb1, 0); +AudioConnection patchCord22(volume_l, 0, usb1, 1); #endif #if defined(TEENSY_AUDIO_BOARD) AudioOutputI2S i2s1; -AudioConnection patchCord25(volume_r, 0, i2s1, 0); -AudioConnection patchCord26(volume_l, 0, i2s1, 1); +AudioConnection patchCord23(volume_r, 0, i2s1, 0); +AudioConnection patchCord24(volume_l, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #elif defined(TGA_AUDIO_BOARD) AudioOutputI2S i2s1; -AudioConnection patchCord27(volume_r, 0, i2s1, 0); -AudioConnection patchCord28(volume_l, 0, i2s1, 1); +AudioConnection patchCord25(volume_r, 0, i2s1, 0); +AudioConnection patchCord26(volume_l, 0, i2s1, 1); AudioControlWM8731master wm8731_1; -#elif defined(TEENSY_DAC) -AudioOutputAnalogStereo dacOut; -AudioConnection patchCord11(volume_r, 0, dacOut, 0); -AudioConnection patchCord12(volume_l, 0, dacOut, 1); +#elif defined(PT8211_AUDIO) +AudioOutputPT8211 pt8211_1; +AudioConnection patchCord27(volume_r, 0, pt8211_1, 0); +AudioConnection patchCord28(volume_l, 0, pt8211_1, 1); #elif defined(TEENSY_DAC_SYMMETRIC) AudioOutputAnalogStereo dacOut; AudioMixer4 invMixer; -AudioConnection patchCord11(volume_l, 0, dacOut , 0); -AudioConnection patchCord12(volume_l, 0, invMixer, 0); -AudioConnection patchCord13(invMixer, 0, dacOut , 1); +AudioConnection patchCord29(volume_l, 0, dacOut , 0); +AudioConnection patchCord30(volume_l, 0, invMixer, 0); +AudioConnection patchCord31(invMixer, 0, dacOut , 1); #else -AudioOutputPT8211 pt8211_1; -AudioConnection patchCord29(volume_r, 0, pt8211_1, 0); -AudioConnection patchCord30(volume_l, 0, pt8211_1, 1); +AudioOutputAnalogStereo dacOut; +AudioConnection patchCord32(volume_r, 0, dacOut, 0); +AudioConnection patchCord33(volume_l, 0, dacOut, 1); #endif Dexed* MicroDexed[NUM_DEXED]; @@ -244,7 +229,7 @@ void setup() AudioNoInterrupts(); AudioMemory(AUDIO_MEM); -#ifdef TEENSY_AUDIO_BOARD +#if defined(TEENSY_AUDIO_BOARD) sgtl5000_1.enable(); sgtl5000_1.dacVolumeRamp(); //sgtl5000_1.dacVolumeRampLinear(); @@ -277,13 +262,13 @@ void setup() wm8731_1.enable(); wm8731_1.volume(1.0); Serial.println(F("TGA board enabled.")); -#elif defined(TEENSY_DAC) - Serial.println(F("Internal DAC enabled.")); +#elif defined(PT8211_AUDIO) + Serial.println(F("PT8211 enabled.")); #elif defined(TEENSY_DAC_SYMMETRIC) - invMixer.gain(0,-1.f); + invMixer.gain(0, -1.f); Serial.println(F("Internal DAC using symmetric outputs enabled.")); #else - Serial.println(F("PT8211 enabled.")); + Serial.println(F("Internal DAC enabled.")); #endif // start SD card @@ -338,6 +323,21 @@ void setup() Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); Serial.println(F(" samples")); #endif + master_mixer_r.gain(0, 1.0); + master_mixer_l.gain(0, 1.0); + + freeverbs1.roomsize(configuration.reverb_roomsize / 100.0); + freeverbs1.damping(configuration.reverb_damping / 100.0); + master_mixer_r.gain(1, 0.0); + master_mixer_l.gain(1, 0.0); + + delay1.delay(0, 0.0); + // delay_fb_mixer is the feedback-adding mixer + delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signal + delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0); // amount of feedback + master_mixer_r.gain(2, 0.0); + master_mixer_l.gain(2, 0.0); + modulator.begin(MOD_WAVEFORM); modulator.phase(0); modulator.amplitude(0.5); @@ -356,24 +356,8 @@ void setup() modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54); modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3); #endif - - chorus_mixer.gain(0, 1.0); - chorus_mixer.gain(1, 0.0); - - delay1.delay(0, 0.0); - // delay_fb_mixer is the feedback-adding mixer, delay_mixer_r the whole delay (with/without feedback) mixer - delay_fb_mixer.gain(0, 1.0); // original signal - delay_fb_mixer.gain(1, mapfloat(effect_delay_feedback, 0, ENC_DELAY_FB_STEPS, 0.0, 1.0)); // amount of feedback - delay_mixer.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal - delay_mixer.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback) - delay_mixer.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback) - - reverb_mixer_r.gain(0, 1.0); - reverb_mixer_l.gain(0, 1.0); - reverb_mixer_r.gain(1, 0.0); - reverb_mixer_l.gain(1, 0.0); - - freeverbs1.roomsize(configuration.reverb_roomsize / 100); + master_mixer_r.gain(3, 0.0); + master_mixer_l.gain(3, 0.0); for (uint8_t i = 0; i < NUM_DEXED; i++) { diff --git a/UI.hpp b/UI.hpp index 9ab5168..15e2014 100644 --- a/UI.hpp +++ b/UI.hpp @@ -59,11 +59,9 @@ extern AudioEffectFreeverbStereo freeverbs1; #endif extern AudioEffectModulatedDelay modchorus; extern AudioSynthWaveform modulator; -extern AudioMixer4 chorus_mixer; -extern AudioMixer4 delay_mixer; extern AudioMixer4 delay_fb_mixer; -extern AudioMixer4 reverb_mixer_r; -extern AudioMixer4 reverb_mixer_l; +extern AudioMixer4 master_mixer_r; +extern AudioMixer4 master_mixer_l; extern AudioAmplifier volume_r; extern AudioAmplifier volume_l; @@ -626,9 +624,9 @@ void UI_func_sound(uint8_t param) { // setup function lcd.setCursor(0, 0); - lcd.print(F("Filter Res.")); + lcd.print(F("Sound")); lcd.setCursor(0, 1); - lcd.print(F("")); + lcd.print(F("not implemented")); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -651,7 +649,7 @@ void UI_func_reverb_roomsize(uint8_t param) { // setup function lcd.setCursor(0, 0); - lcd.print(F("Rev. Roomsize")); + lcd.print(F("Reverb Roomsize")); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -692,7 +690,7 @@ void UI_func_reverb_damping(uint8_t param) { // setup function lcd.setCursor(0, 0); - lcd.print(F("Rev. Damping")); + lcd.print(F("Reverb Damping")); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -760,8 +758,8 @@ void UI_func_reverb_level(uint8_t param) lcd.setCursor(0, 1); lcd_display_int(configuration.reverb_level, 3, true, true, false); - reverb_mixer_r.gain(1, configuration.reverb_level / 100.0); - reverb_mixer_l.gain(1, configuration.reverb_level / 100.0); + master_mixer_r.gain(1, configuration.reverb_level / 100.0); + master_mixer_l.gain(1, configuration.reverb_level / 100.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -800,8 +798,9 @@ void UI_func_chorus_frequency(uint8_t param) } } lcd.setCursor(0, 1); - lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, true, true, false); - + lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, false, true, false); + lcd.print(" Hz"); + modulator.frequency(configuration.chorus_frequency / 10.0); } @@ -937,7 +936,9 @@ void UI_func_chorus_level(uint8_t param) lcd.setCursor(0, 1); lcd_display_int(configuration.chorus_level, 3, true, true, false); - chorus_mixer.gain(1, configuration.chorus_level / 100.0); + + master_mixer_r.gain(3, configuration.chorus_level / 100.0); + master_mixer_l.gain(3, configuration.chorus_level / 100.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1020,7 +1021,7 @@ void UI_func_delay_feedback(uint8_t param) lcd_display_int(configuration.delay_feedback, 3, true, true, false); delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback - delay_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signal + delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signal } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1061,7 +1062,8 @@ void UI_func_delay_level(uint8_t param) lcd.setCursor(0, 1); lcd_display_int(configuration.delay_level, 3, true, true, false); - delay_mixer.gain(1, configuration.delay_level / 100.0); + master_mixer_r.gain(2, configuration.delay_level / 100.0); + master_mixer_l.gain(2, configuration.delay_level / 100.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index 25a7636..8434c15 100644 --- a/config.h +++ b/config.h @@ -53,9 +53,11 @@ // AUDIO // If nothing is defined Teensy internal DAC is used as audio output device! // Left and right channel audio signal is presented on pins A21 and A22. -#define TEENSY_DAC -// #define TEENSY_AUDIO_BOARD 1 -// #define TGA_AUDIO_BOARD +//#define TEENSY_DAC +//#define TEENSY_DAC_SYMMETRIC +//#define TEENSY_AUDIO_BOARD +//#define TGA_AUDIO_BOARD +#define PT8211_AUDIO //************************************************************************************************* //* MIDI SETTINGS