Removing most stereo fx chain handling.

Small fixes.
pull/3/head
Holger Wirtz 5 years ago
parent 0581978f70
commit 41b91692ee
  1. 159
      MicroDexed.ino
  2. 1
      config.h
  3. 6
      dexed.cpp

@ -40,23 +40,18 @@
AudioPlayQueue dexed1;
AudioAnalyzePeak peak1;
AudioEffectDelay delay_r;
AudioEffectDelay delay_l;
AudioEffectDelay delay1;
#ifdef USE_REVERB
AudioEffectFreeverbStereo freeverbs1;
AudioEffectModulatedDelay modchorus_r;
AudioEffectModulatedDelay modchorus_l;
#endif
AudioEffectModulatedDelay modchorus;
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter_r;
AudioFilterBiquad modchorus_filter_l;
AudioFilterBiquad modchorus_filter;
#endif
AudioSynthWaveform modulator;
AudioAmplifier inverter;
AudioMixer4 chorus_mixer_r;
AudioMixer4 chorus_mixer_l;
AudioMixer4 delay_mixer_r;
AudioMixer4 delay_mixer_l;
AudioMixer4 delay_fb_mixer_r;
AudioMixer4 delay_fb_mixer_l;
AudioMixer4 chorus_mixer;
AudioMixer4 delay_mixer;
AudioMixer4 delay_fb_mixer;
AudioMixer4 reverb_mixer_r;
AudioMixer4 reverb_mixer_l;
AudioAmplifier volume_r;
@ -65,62 +60,56 @@ AudioAmplifier volume_l;
AudioOutputUSB usb1;
#endif
AudioConnection patchCord0(dexed1, peak1);
AudioConnection patchCord1(dexed1, 0, chorus_mixer_r, 0);
AudioConnection patchCord2(dexed1, 0, chorus_mixer_l, 0);
AudioConnection patchCord3(dexed1, 0, delay_mixer_r, 0);
AudioConnection patchCord4(dexed1, 0, delay_mixer_l, 0);
AudioConnection patchCord5(dexed1, 0, delay_fb_mixer_r, 0);
AudioConnection patchCord6(dexed1, 0, delay_fb_mixer_l, 0);
AudioConnection patchCord7(dexed1, 0, reverb_mixer_r, 0);
AudioConnection patchCord8(dexed1, 0, reverb_mixer_l, 0);
AudioConnection patchCord9(dexed1, 0, modchorus_r, 0);
AudioConnection patchCord10(dexed1, 0, modchorus_l, 0);
AudioConnection patchCord11(modulator, 0, modchorus_r, 1);
AudioConnection patchCord12(modulator, inverter);
AudioConnection patchCord13(inverter, 0, modchorus_l, 1);
AudioConnection patchCord1(dexed1, 0, chorus_mixer, 0);
AudioConnection patchCord3(dexed1, 0, delay_mixer, 0);
AudioConnection patchCord4(dexed1, 0, delay_fb_mixer, 0);
#ifdef USE_REVERB
AudioConnection patchCord5(dexed1, 0, reverb_mixer_r, 0);
AudioConnection patchCord6(dexed1, 0, reverb_mixer_l, 0);
#endif
AudioConnection patchCord7(dexed1, 0, modchorus, 0);
AudioConnection patchCord8(modulator, 0, modchorus, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioConnection patchCord14(modchorus_r, modchorus_filter_r);
AudioConnection patchCord15(modchorus_l, modchorus_filter_l);
AudioConnection patchCord16(modchorus_filter_r, 0, chorus_mixer_r, 1);
AudioConnection patchCord17(modchorus_filter_l, 0, chorus_mixer_l, 1);
AudioConnection patchCord9(modchorus, modchorus_filter);
AudioConnection patchCord10(modchorus_filter, 0, chorus_mixer, 1);
#else
AudioConnection patchCord9(modchorus, 0, chorus_mixer, 1);
#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 patchCord14(modchorus_r, 0, chorus_mixer_r, 1);
AudioConnection patchCord15(modchorus_l, 0, chorus_mixer_l, 1);
AudioConnection patchCord17(delay_mixer, volume_r);
AudioConnection patchCord18(delay_mixer, volume_l);
#endif
AudioConnection patchCord18(chorus_mixer_r, 0, delay_mixer_r, 1);
AudioConnection patchCord19(chorus_mixer_l, 0, delay_mixer_l, 1);
AudioConnection patchCord20(delay_fb_mixer_r, 0, delay_mixer_r, 1);
AudioConnection patchCord21(delay_fb_mixer_l, 0, delay_mixer_l, 1);
AudioConnection patchCord22(delay_mixer_r, 0, reverb_mixer_r, 1);
AudioConnection patchCord23(delay_mixer_l, 0, reverb_mixer_l, 1);
AudioConnection patchCord24(delay_r, 0, delay_mixer_r, 2);
AudioConnection patchCord25(delay_l, 0, delay_mixer_l, 2);
AudioConnection patchCord26(delay_fb_mixer_r, delay_r);
AudioConnection patchCord27(delay_fb_mixer_l, delay_l);
AudioConnection patchCord28(delay_mixer_r, 0, freeverbs1, 1);
AudioConnection patchCord29(delay_mixer_l, 0, freeverbs1, 1);
AudioConnection patchCord30(freeverbs1, 0, reverb_mixer_r, 1);
AudioConnection patchCord31(freeverbs1, 1, reverb_mixer_l, 1);
AudioConnection patchCord32(reverb_mixer_r, volume_r);
AudioConnection patchCord33(reverb_mixer_l, volume_l);
#ifdef MIDI_DEVICE_USB
AudioConnection patchCord34(volume_r, 0, usb1, 0);
AudioConnection patchCord35(volume_l, 0, usb1, 1);
AudioConnection patchCord23(volume_r, 0, usb1, 0);
AudioConnection patchCord24(volume_l, 0, usb1, 1);
#endif
#if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1;
AudioConnection patchCord36(volume_r, 0, i2s1, 0);
AudioConnection patchCord37(volume_l, 0, i2s1, 1);
AudioConnection patchCord25(volume_r, 0, i2s1, 0);
AudioConnection patchCord26(volume_l, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1;
#elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1;
AudioConnection patchCord36(volume_r, 0, i2s1, 0);
AudioConnection patchCord37(volume_l, 0, i2s1, 1);
AudioConnection patchCord27(volume_r, 0, i2s1, 0);
AudioConnection patchCord28(volume_l, 0, i2s1, 1);
AudioControlWM8731master wm8731_1;
#else
AudioOutputPT8211 pt8211_1;
AudioConnection patchCord36(volume_r, 0, pt8211_1, 0);
AudioConnection patchCord37(volume_l, 0, pt8211_1, 1);
AudioConnection patchCord29(volume_r, 0, pt8211_1, 0);
AudioConnection patchCord30(volume_l, 0, pt8211_1, 1);
#endif
Dexed* dexed = new Dexed(SAMPLE_RATE);
@ -158,8 +147,7 @@ value_change_t soften_filter_res = {0.0, 0};
value_change_t soften_filter_cut = {0.0, 0};
// Allocate the delay lines for left and right channels
short l_delayline[MOD_DELAY_SAMPLE_BUFFER];
short r_delayline[MOD_DELAY_SAMPLE_BUFFER];
short delayline[MOD_DELAY_SAMPLE_BUFFER];
#ifdef ENABLE_LCD_UI
/***********************************************************************
@ -302,14 +290,10 @@ void setup()
}
// Init effects
if (!modchorus_r.begin(r_delayline, MOD_DELAY_SAMPLE_BUFFER)) {
if (!modchorus.begin(delayline, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1);
}
if (!modchorus_l.begin(l_delayline, MOD_DELAY_SAMPLE_BUFFER)) {
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed"));
while (1);
}
#ifdef DEBUG
Serial.print(F("MOD_DELAY_SAMPLE_BUFFER="));
Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC);
@ -321,38 +305,29 @@ void setup()
modulator.offset(0.0);
#if MOD_FILTER_OUTPUT == MOD_BUTTERWORTH_FILTER_OUTPUT
// Butterworth filter, 12 db/octave
modchorus_filter_r.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707);
modchorus_filter_l.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707);
modchorus_filter.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.707);
#elif MOD_FILTER_OUTPUT == MOD_LINKWITZ_RILEY_FILTER_OUTPUT
// Linkwitz-Riley filter, 48 dB/octave
modchorus_filter_r.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_r.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter_r.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_r.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter_l.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_l.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter_l.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter_l.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter.setLowpass(0, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(1, MOD_FILTER_CUTOFF_HZ, 1.3);
modchorus_filter.setLowpass(2, MOD_FILTER_CUTOFF_HZ, 0.54);
modchorus_filter.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
#endif
chorus_mixer_r.gain(0, 1.0);
chorus_mixer_l.gain(0, 1.0);
chorus_mixer_r.gain(1, 0.0);
chorus_mixer_l.gain(1, 0.0);
delay_r.delay(0, mapfloat(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
delay_l.delay(0, mapfloat(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
// delay_fb_mixer_r is the feedback-adding mixer, delay_mixer_r the whole delay (with/without feedback) mixer
delay_fb_mixer_r.gain(0, 1.0); // original signal
delay_fb_mixer_l.gain(0, 1.0); // original signal
delay_fb_mixer_r.gain(1, mapfloat(effect_delay_feedback, 0, ENC_DELAY_FB_STEPS, 0.0, 1.0)); // amount of feedback
delay_fb_mixer_l.gain(1, mapfloat(effect_delay_feedback, 0, ENC_DELAY_FB_STEPS, 0.0, 1.0)); // amount of feedback
delay_mixer_r.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal
delay_mixer_l.gain(0, 1.0 - mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // original signal
delay_mixer_r.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback)
delay_mixer_l.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delayed signal (including feedback)
delay_mixer_r.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback)
delay_mixer_l.gain(2, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // only delayed signal (without feedback)
chorus_mixer.gain(0, 1.0);
chorus_mixer.gain(1, 0.0);
delay1.delay(0, mapfloat(effect_delay_feedback, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
// 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);
@ -593,7 +568,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break;
case 105: // CC 105: delay time
effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS);
////delay_r.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
////delay.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
break;
case 106: // CC 106: delay feedback
effect_delay_feedback = map(inValue, 0, 127, 0, ENC_DELAY_FB_STEPS);

@ -76,6 +76,7 @@
#define MOD_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define MOD_FILTER_OUTPUT MOD_LINKWITZ_RILEY_FILTER_OUTPUT // MOD_LINKWITZ_RILEY_FILTER_OUTPUT MOD_BUTTERWORTH_FILTER_OUTPUT MOD_NO_FILTER_OUTPUT
#define MOD_FILTER_CUTOFF_HZ 3000
//#define USE_REVERB 1
//*************************************************************************************************
//* AUDIO SETTINGS

@ -136,7 +136,7 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
int32_t lfovalue = lfo.getsample();
int32_t lfodelay = lfo.getdelay();
for (uint8_t note = 0; note < max_notes; ++note)
for (uint8_t note = 0; note < max_notes; note++)
{
if (voices[note].live)
{
@ -182,7 +182,7 @@ void Dexed::keydown(uint8_t pitch, uint8_t velo) {
return;
}
pitch += data[144] - 24;
pitch += data[144] - TRANSPOSE_FIX;
uint8_t note = currentNote;
uint8_t keydown_counter = 0;
@ -233,7 +233,7 @@ void Dexed::keyup(uint8_t pitch) {
pitch += data[144] - TRANSPOSE_FIX;
uint8_t note;
for (note = 0; note < max_notes; ++note) {
for (note = 0; note < max_notes; note++) {
if ( voices[note].midi_note == pitch && voices[note].keydown ) {
voices[note].keydown = false;
break;

Loading…
Cancel
Save