Code cleanup and small fixes.

master
Holger Wirtz 5 years ago
parent b48aa7bb9a
commit 78aac5e8a9
  1. 12
      MicroMDAEPiano.ino
  2. 17
      effect_modulated_delay.cpp

@ -58,8 +58,6 @@ AudioEffectModulatedDelay modchorus_r;
AudioEffectModulatedDelay modchorus_l;
AudioSynthWaveform modulator;
AudioFilterBiquad modulator_filter;
AudioFilterBiquad chorus_filter_r;
AudioFilterBiquad chorus_filter_l;
AudioConnection patchCord0(queue_r, peak_r);
AudioConnection patchCord1(queue_l, peak_l);
AudioConnection patchCord2(queue_r, freeverb_r);
@ -72,12 +70,8 @@ AudioConnection patchCord8(modulator_filter, inverter);
AudioConnection patchCord9(inverter, 0, modchorus_l, 1);
AudioConnection patchCord10(queue_r, 0, mixer_r, 0);
AudioConnection patchCord11(queue_l, 0, mixer_l, 0);
AudioConnection patchCord12(modchorus_r, chorus_filter_r);
AudioConnection patchCord13(modchorus_l, chorus_filter_l);
AudioConnection patchCord14(chorus_filter_r, 0, mixer_r, 2);
AudioConnection patchCord15(chorus_filter_l, 0, mixer_l, 2);
AudioConnection patchCord16(modchorus_r, 0, mixer_r, 2);
AudioConnection patchCord17(modchorus_l, 0, mixer_l, 2);
AudioConnection patchCord12(modchorus_r, 0, mixer_r, 2);
AudioConnection patchCord13(modchorus_l, 0, mixer_l, 2);
AudioConnection patchCord18(freeverb_r, 0, mixer_r, 1);
AudioConnection patchCord19(freeverb_l, 0, mixer_l, 1);
AudioConnection patchCord20(mixer_r, volume_r);
@ -244,10 +238,8 @@ void setup()
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
modchorus_r.offset(15.0);
modchorus_r.intensity(1.0);
chorus_filter_r.setLowpass(0, 10000.0, CHORUS_MODULATOR_FILTER_Q);
modchorus_l.offset(15.0);
modchorus_l.intensity(1.0);
chorus_filter_l.setLowpass(0, 10000.0, CHORUS_MODULATOR_FILTER_Q);
// internal mixing of original signal(0), reverb(1) and chorus(2)
mixer_r.gain(VOL_MAIN, 0.5);

@ -59,12 +59,6 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delayline = delayline;
_delay_length = d_length;
#ifdef CHORUS_INTERPOLATION_MODE
spline = new Spline;
spline->setPoints(x, y, int(CHORUS_INTERPOLATION_WINDOW_SIZE));
spline->setDegree(CHORUS_INTERPOLATION_MODE);
#endif
return (true);
}
@ -97,16 +91,13 @@ void AudioEffectModulatedDelay::update(void)
_circ_idx = 0;
_delayline[_circ_idx] = *bp;
// Calculate the modulation index as a float in the interval [-1.0,1.0] for interpolation later.
// The index is located around the half of the delay length multiplied by the current amount of the modulator
// Calculate the modulation-index as a floating point number fo later interpolation
mod_idx = _delay_offset + ((float(*mp) / SHRT_MAX) * _modulation_intensity);
mod_fraction = modff(mod_idx, &mod_number);
// linear interpolation
c_mod_idx = _circ_idx - round(mod_idx);
if (mod_idx < 0.0) // c_mod_idx is the pointer to the value in the circular buffer at the current modulation index
c_mod_idx--;
c_mod_idx %= _delay_length; // The modulation index pointer plus the value of the current window pointer
c_mod_idx %= _delay_length;
if (c_mod_idx < 0) // check for negative offsets and correct them
c_mod_idx += _delay_length;
if (c_mod_idx - 1 < 0)
@ -124,7 +115,7 @@ void AudioEffectModulatedDelay::update(void)
idx[0] = c_mod_idx;
idx[1] = c_mod_idx + 1;
}
*bp = round(float(_delayline[idx[0]]) * (1.0 - mod_fraction) + float(_delayline[idx[1]]) * mod_fraction);
*bp = round(float(_delayline[idx[0]]) * mod_fraction + float(_delayline[idx[1]]) * (1.0 - mod_fraction));
bp++; // next audio data
mp++; // next modulation data

Loading…
Cancel
Save