Renaming files from *chorus to *delay.

Fixing and optimizing code for modulated delay calculation.
master
Holger Wirtz 6 years ago
parent e901694c8a
commit f9d971252d
  1. 14
      MicroMDAEPiano.ino
  2. 2
      config.h
  3. 37
      effect_modulated_delay.cpp
  4. 0
      effect_modulated_delay.h

@ -28,7 +28,7 @@
#include <EEPROM.h>
#include "EEPROMAnything.h"
#include "mdaEPiano.h"
#include "effect_modulated_chorus.h"
#include "effect_modulated_delay.h"
#ifdef USE_XFADE_DATA
#include "mdaEPianoDataXfade.h"
#else
@ -243,12 +243,12 @@ void setup()
modulator.offset(0.0);
// internal mixing of original signal(0), reverb(1) and chorus(2)
mixer_r.gain(0, 1.0);
mixer_l.gain(0, 1.0);
mixer_r.gain(1, 0.5);
mixer_l.gain(1, 0.5);
mixer_r.gain(2, 0.5);
mixer_l.gain(2, 0.5);
mixer_r.gain(0, 0.0);
mixer_l.gain(0, 0.0);
mixer_r.gain(1, 0.0);
mixer_l.gain(1, 0.0);
mixer_r.gain(2, 1.0);
mixer_l.gain(2, 1.0);
// set master volume
set_master_volume(master_volume);

@ -63,7 +63,7 @@
// CHORUS parameters
#define INTERPOLATION_WINDOW_SIZE 7 // For chorus, only odd numbers,please!
#define INTERPOLATE QUADRATIC // LINEAR QUADRATIC COSINE CUBIC LAGRANGE
#define CHORUS_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE WAVEFORM_SQUARE WAVEFORM_TRIANGLE
#define CHORUS_WAVEFORM WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE WAVEFORM_SQUARE WAVEFORM_TRIANGLE
#define CHORUS_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES)
//*************************************************************************************************

@ -23,7 +23,7 @@
#include <Arduino.h>
#include "limits.h"
#include "effect_modulated_chorus.h"
#include "effect_modulated_delay.h"
#include "interpolation.h"
#include "config.h"
@ -33,7 +33,7 @@
// Written by Pete (El Supremo) Jan 2014
// 140529 - change to handle mono stream - change modify() to voices()
// 140219 - correct storage class (not static)
// 190527 - added modulation input handling (by Holger Wirtz)
// 190527 - added modulation input (by Holger Wirtz)
boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
{
@ -90,9 +90,6 @@ void AudioEffectModulatedDelay::update(void)
modulation_interpolate.valuelenXY(INTERPOLATION_WINDOW_SIZE);
modulation_interpolate.valueX(x);
modulation_interpolate.valueY(y);
for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++)
x[j] = float(j);
#endif
bp = block->data;
@ -108,24 +105,24 @@ void AudioEffectModulatedDelay::update(void)
_delayline[_circ_idx] = *bp;
// calculate modulation index
mod_idx = float(*mp) / SHRT_MAX * _delay_length_half + _circ_idx; // calculate index with modulation as a float(!!!)
if (mod_idx > float(_delay_length - 1))
mod_idx = mod_idx - float(_delay_length - 1);
else if (mod_idx < 0.0)
mod_idx = float(_delay_length - 1) + mod_idx;
mod_idx = float(*mp) / SHRT_MAX * _delay_length_half; // calculate index with modulation as a float(!!!)
#ifdef INTERPOLATE
// get x/y values around mod_idx
uint8_t c = 0;
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
for (j = INTERPOLATION_WINDOW_SIZE / -2; j <= INTERPOLATION_WINDOW_SIZE / 2; j++)
{
y[c] = float(_delayline[(int(mod_idx + 0.5) + _circ_idx + j) % _delay_length]);
if (y[c] < 0)
y[c] = _delay_length + y[c];
int16_t jc_mod_idx = (c_mod_idx + j) % _delay_length;
if (jc_mod_idx < 0)
y[c] = float(_delayline[_delay_length + jc_mod_idx]);
else
y[c] = float(_delayline[jc_mod_idx]);
x[c] = float(c);
c++; // because 42 is the answer! ;-)
}
modulation_interpolate.valueI(mod_idx);
modulation_interpolate.valueI(mod_idx - int(mod_idx + 0.5));
#if INTERPOLATE == CUBIC
*bp = int(modulation_interpolate.CubicInterpolate() + 0.5);
@ -139,11 +136,19 @@ void AudioEffectModulatedDelay::update(void)
*bp = int(modulation_interpolate.QuadraticInterpolate() + 0.5);
#else
// No interpolation - should sound really bad...
*bp = _delayline[int(mod_idx + 0.5)];
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
else
*bp = _delayline[c_mod_idx];
#endif
#else
// No interpolation - should sound really bad...
*bp = _delayline[int(mod_idx + 0.5)];
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
else
*bp = _delayline[c_mod_idx];
#endif
bp++;
Loading…
Cancel
Save