Reworking on the audio chain.

pull/3/head
Holger Wirtz 5 years ago
parent d9219bd74d
commit 1daf236276
  1. 140
      MicroDexed.ino
  2. 30
      UI.hpp
  3. 6
      config.h

@ -42,85 +42,70 @@
AudioPlayQueue queue1; AudioPlayQueue queue1;
AudioAnalyzePeak peak1; AudioAnalyzePeak peak1;
AudioEffectDelay delay1; AudioEffectDelay delay1;
#ifdef USE_REVERB
AudioEffectFreeverbStereo freeverbs1;
#endif
AudioEffectModulatedDelay modchorus; AudioEffectModulatedDelay modchorus;
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter;
#endif
AudioSynthWaveform modulator; AudioSynthWaveform modulator;
AudioMixer4 chorus_mixer;
AudioMixer4 delay_mixer;
AudioMixer4 delay_fb_mixer; AudioMixer4 delay_fb_mixer;
AudioMixer4 reverb_mixer_r; AudioMixer4 master_mixer_r;
AudioMixer4 reverb_mixer_l; AudioMixer4 master_mixer_l;
AudioAmplifier volume_r; AudioAmplifier volume_r;
AudioAmplifier volume_l; AudioAmplifier volume_l;
#ifdef MIDI_DEVICE_USB
AudioOutputUSB usb1;
#endif
AudioConnection patchCord0(queue1, peak1); AudioConnection patchCord0(queue1, peak1);
AudioConnection patchCord1(queue1, 0, chorus_mixer, 0); AudioConnection patchCord1(queue1, 0, delay_fb_mixer, 0);
AudioConnection patchCord3(queue1, 0, delay_mixer, 0); AudioConnection patchCord2(queue1, 0, modchorus, 0);
AudioConnection patchCord4(queue1, 0, delay_fb_mixer, 0); AudioConnection patchCord3(queue1, 0 , master_mixer_r, 0);
#ifdef USE_REVERB AudioConnection patchCord4(queue1, 0 , master_mixer_l, 0);
AudioConnection patchCord5(queue1, 0, reverb_mixer_r, 0); AudioConnection patchCord5(modulator, 0, modchorus, 1);
AudioConnection patchCord6(queue1, 0, reverb_mixer_l, 0);
#endif
AudioConnection patchCord7(queue1, 0, modchorus, 0);
AudioConnection patchCord8(modulator, 0, modchorus, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioConnection patchCord9(modchorus, modchorus_filter); AudioFilterBiquad modchorus_filter;
AudioConnection patchCord10(modchorus_filter, 0, chorus_mixer, 1); AudioConnection patchCord6(modchorus, modchorus_filter);
AudioConnection patchCord7(modchorus_filter, 0, master_mixer_r, 3);
AudioConnection patchCord8(modchorus_filter, 0, master_mixer_l, 3);
#else #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 #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 #ifdef USE_REVERB
AudioConnection patchCord17(delay_mixer, 0, freeverbs1, 0); AudioEffectFreeverbStereo freeverbs1;
AudioConnection patchCord18(delay_mixer, 0, freeverbs1, 1); AudioConnection patchCord11(queue1, 0, freeverbs1, 0);
AudioConnection patchCord19(freeverbs1, 0, reverb_mixer_r, 1); AudioConnection patchCord12(queue1, 0, freeverbs1, 1);
AudioConnection patchCord20(freeverbs1, 1, reverb_mixer_l, 1); AudioConnection patchCord13(freeverbs1, 0, master_mixer_r, 1);
AudioConnection patchCord21(reverb_mixer_r, volume_r); AudioConnection patchCord14(freeverbs1, 1, master_mixer_l, 1);
AudioConnection patchCord22(reverb_mixer_l, volume_l);
#else
AudioConnection patchCord17(delay_mixer, volume_r);
AudioConnection patchCord18(delay_mixer, volume_l);
#endif #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 #ifdef MIDI_DEVICE_USB
AudioConnection patchCord23(volume_r, 0, usb1, 0); AudioOutputUSB usb1;
AudioConnection patchCord24(volume_l, 0, usb1, 1); AudioConnection patchCord21(volume_r, 0, usb1, 0);
AudioConnection patchCord22(volume_l, 0, usb1, 1);
#endif #endif
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord25(volume_r, 0, i2s1, 0); AudioConnection patchCord23(volume_r, 0, i2s1, 0);
AudioConnection patchCord26(volume_l, 0, i2s1, 1); AudioConnection patchCord24(volume_l, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; AudioControlSGTL5000 sgtl5000_1;
#elif defined(TGA_AUDIO_BOARD) #elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord27(volume_r, 0, i2s1, 0); AudioConnection patchCord25(volume_r, 0, i2s1, 0);
AudioConnection patchCord28(volume_l, 0, i2s1, 1); AudioConnection patchCord26(volume_l, 0, i2s1, 1);
AudioControlWM8731master wm8731_1; AudioControlWM8731master wm8731_1;
#elif defined(TEENSY_DAC) #elif defined(PT8211_AUDIO)
AudioOutputAnalogStereo dacOut; AudioOutputPT8211 pt8211_1;
AudioConnection patchCord11(volume_r, 0, dacOut, 0); AudioConnection patchCord27(volume_r, 0, pt8211_1, 0);
AudioConnection patchCord12(volume_l, 0, dacOut, 1); AudioConnection patchCord28(volume_l, 0, pt8211_1, 1);
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioMixer4 invMixer; AudioMixer4 invMixer;
AudioConnection patchCord11(volume_l, 0, dacOut , 0); AudioConnection patchCord29(volume_l, 0, dacOut , 0);
AudioConnection patchCord12(volume_l, 0, invMixer, 0); AudioConnection patchCord30(volume_l, 0, invMixer, 0);
AudioConnection patchCord13(invMixer, 0, dacOut , 1); AudioConnection patchCord31(invMixer, 0, dacOut , 1);
#else #else
AudioOutputPT8211 pt8211_1; AudioOutputAnalogStereo dacOut;
AudioConnection patchCord29(volume_r, 0, pt8211_1, 0); AudioConnection patchCord32(volume_r, 0, dacOut, 0);
AudioConnection patchCord30(volume_l, 0, pt8211_1, 1); AudioConnection patchCord33(volume_l, 0, dacOut, 1);
#endif #endif
Dexed* MicroDexed[NUM_DEXED]; Dexed* MicroDexed[NUM_DEXED];
@ -244,7 +229,7 @@ void setup()
AudioNoInterrupts(); AudioNoInterrupts();
AudioMemory(AUDIO_MEM); AudioMemory(AUDIO_MEM);
#ifdef TEENSY_AUDIO_BOARD #if defined(TEENSY_AUDIO_BOARD)
sgtl5000_1.enable(); sgtl5000_1.enable();
sgtl5000_1.dacVolumeRamp(); sgtl5000_1.dacVolumeRamp();
//sgtl5000_1.dacVolumeRampLinear(); //sgtl5000_1.dacVolumeRampLinear();
@ -277,13 +262,13 @@ void setup()
wm8731_1.enable(); wm8731_1.enable();
wm8731_1.volume(1.0); wm8731_1.volume(1.0);
Serial.println(F("TGA board enabled.")); Serial.println(F("TGA board enabled."));
#elif defined(TEENSY_DAC) #elif defined(PT8211_AUDIO)
Serial.println(F("Internal DAC enabled.")); Serial.println(F("PT8211 enabled."));
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
invMixer.gain(0, -1.f); invMixer.gain(0, -1.f);
Serial.println(F("Internal DAC using symmetric outputs enabled.")); Serial.println(F("Internal DAC using symmetric outputs enabled."));
#else #else
Serial.println(F("PT8211 enabled.")); Serial.println(F("Internal DAC enabled."));
#endif #endif
// start SD card // start SD card
@ -338,6 +323,21 @@ void setup()
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC);
Serial.println(F(" samples")); Serial.println(F(" samples"));
#endif #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.begin(MOD_WAVEFORM);
modulator.phase(0); modulator.phase(0);
modulator.amplitude(0.5); modulator.amplitude(0.5);
@ -356,24 +356,8 @@ void setup()
modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54); modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3); modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
#endif #endif
master_mixer_r.gain(3, 0.0);
chorus_mixer.gain(0, 1.0); master_mixer_l.gain(3, 0.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);
for (uint8_t i = 0; i < NUM_DEXED; i++) for (uint8_t i = 0; i < NUM_DEXED; i++)
{ {

@ -59,11 +59,9 @@ extern AudioEffectFreeverbStereo freeverbs1;
#endif #endif
extern AudioEffectModulatedDelay modchorus; extern AudioEffectModulatedDelay modchorus;
extern AudioSynthWaveform modulator; extern AudioSynthWaveform modulator;
extern AudioMixer4 chorus_mixer;
extern AudioMixer4 delay_mixer;
extern AudioMixer4 delay_fb_mixer; extern AudioMixer4 delay_fb_mixer;
extern AudioMixer4 reverb_mixer_r; extern AudioMixer4 master_mixer_r;
extern AudioMixer4 reverb_mixer_l; extern AudioMixer4 master_mixer_l;
extern AudioAmplifier volume_r; extern AudioAmplifier volume_r;
extern AudioAmplifier volume_l; extern AudioAmplifier volume_l;
@ -626,9 +624,9 @@ void UI_func_sound(uint8_t param)
{ {
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Filter Res.")); lcd.print(F("Sound"));
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print(F("<value>")); lcd.print(F("not implemented"));
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -651,7 +649,7 @@ void UI_func_reverb_roomsize(uint8_t param)
{ {
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Rev. Roomsize")); lcd.print(F("Reverb Roomsize"));
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -692,7 +690,7 @@ void UI_func_reverb_damping(uint8_t param)
{ {
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Rev. Damping")); lcd.print(F("Reverb Damping"));
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -760,8 +758,8 @@ void UI_func_reverb_level(uint8_t param)
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.reverb_level, 3, true, true, false); lcd_display_int(configuration.reverb_level, 3, true, true, false);
reverb_mixer_r.gain(1, configuration.reverb_level / 100.0); master_mixer_r.gain(1, configuration.reverb_level / 100.0);
reverb_mixer_l.gain(1, configuration.reverb_level / 100.0); master_mixer_l.gain(1, configuration.reverb_level / 100.0);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -800,7 +798,8 @@ void UI_func_chorus_frequency(uint8_t param)
} }
} }
lcd.setCursor(0, 1); 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); modulator.frequency(configuration.chorus_frequency / 10.0);
} }
@ -937,7 +936,9 @@ void UI_func_chorus_level(uint8_t param)
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.chorus_level, 3, true, true, false); 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 ********* 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); lcd_display_int(configuration.delay_feedback, 3, true, true, false);
delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback 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 ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -1061,7 +1062,8 @@ void UI_func_delay_level(uint8_t param)
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.delay_level, 3, true, true, false); 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 ********* if (LCDML.FUNC_close()) // ****** STABLE END *********

@ -53,9 +53,11 @@
// AUDIO // AUDIO
// If nothing is defined Teensy internal DAC is used as audio output device! // 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. // Left and right channel audio signal is presented on pins A21 and A22.
#define TEENSY_DAC //#define TEENSY_DAC
// #define TEENSY_AUDIO_BOARD 1 //#define TEENSY_DAC_SYMMETRIC
//#define TEENSY_AUDIO_BOARD
//#define TGA_AUDIO_BOARD //#define TGA_AUDIO_BOARD
#define PT8211_AUDIO
//************************************************************************************************* //*************************************************************************************************
//* MIDI SETTINGS //* MIDI SETTINGS

Loading…
Cancel
Save