Fixes for chorus intensity and loading values at startup.

master
Holger Wirtz 6 years ago
parent 81de0af5b7
commit 5ea21e53b7
  1. 16
      MicroMDAEPiano.ino
  2. 2
      UI.hpp
  3. 4
      config.h
  4. 31
      effect_modulated_delay.cpp
  5. 5
      effect_modulated_delay.h

@ -239,19 +239,17 @@ void setup()
// chorus modulation fixed
modulator.begin(CHORUS_WAVEFORM);
modulator.amplitude(1.0);
modulator.frequency(1.0);
modulator.phase(0);
modulator.offset(0.0);
inverter.gain(-1.0); // change phase for second moduleated delay
// 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.5);
mixer_l.gain(0, 0.5);
mixer_r.gain(1, 0.2);
mixer_l.gain(1, 0.2);
mixer_r.gain(2, 0.3);
mixer_l.gain(2, 0.3);
// set master volume
set_master_volume(master_volume);
@ -558,9 +556,9 @@ void config_from_eeprom(void)
#ifdef SHOW_DEBUG
Serial.println(F(" - mismatch -> loading initial configuration."));
#endif
set_complete_configuration();
EEPROM.update(EEPROM_SOUND, sound);
}
set_complete_configuration();
#ifdef SHOW_DEBUG
show_sound();

@ -2057,7 +2057,7 @@ void set_chorus_intensity(uint8_t value)
Serial.print(F("Set CHORUS_INTENSITY "));
Serial.println(value);
#endif
modulator.amplitude(float(value) / 100);
modulator.amplitude(mapfloat(float(value), ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX, 0.0, 0.5));
configuration.chorus_intensity = value;
}

@ -61,8 +61,8 @@
#define REDUCE_LOUDNESS 0
#define USE_XFADE_DATA 1
// CHORUS parameters
#define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
#define INTERPOLATE QUADRATIC // LINEAR QUADRATIC COSINE CUBIC LAGRANGE
#define INTERPOLATION_WINDOW_SIZE 13 // use only odd numbers!!!
//#define INTERPOLATE QUADRATIC // LINEAR QUADRATIC COSINE CUBIC LAGRANGE
#define CHORUS_WAVEFORM WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE WAVEFORM_SQUARE WAVEFORM_TRIANGLE
#define CHORUS_DELAY_LENGTH_SAMPLES (14*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms; you need doubled length, e.g. delay point is 20ms, so you need up to 40ms delay!

@ -41,7 +41,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
#if 0
Serial.print(F("AudioEffectModulatedDelay.begin(Chorus delay line length = "));
Serial.print(d_length);
Serial.println(F(")");
Serial.println(F(")"));
#endif
_delayline = NULL;
@ -60,6 +60,9 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delay_length_half = _delay_length / 2;
memset(_delayline, 0, sizeof(int16_t)*_delay_length);
#ifdef INTERPOLATE
modulation_interpolate = new interpolation();
#endif
return (true);
}
@ -76,10 +79,6 @@ void AudioEffectModulatedDelay::update(void)
if (_delayline == NULL)
return;
#ifdef INTERPOLATE
interpolation modulation_interpolate;
#endif
block = receiveWritable(0);
modulation = receiveReadOnly(1);
@ -87,9 +86,9 @@ void AudioEffectModulatedDelay::update(void)
int8_t j;
float x[INTERPOLATION_WINDOW_SIZE];
float y[INTERPOLATION_WINDOW_SIZE];
modulation_interpolate.valuelenXY(INTERPOLATION_WINDOW_SIZE);
modulation_interpolate.valueX(x);
modulation_interpolate.valueY(y);
modulation_interpolate->valuelenXY(INTERPOLATION_WINDOW_SIZE);
modulation_interpolate->valueX(x);
modulation_interpolate->valueY(y);
#endif
bp = block->data;
@ -122,23 +121,23 @@ void AudioEffectModulatedDelay::update(void)
c++; // because 42 is the answer! ;-)
}
modulation_interpolate.valueI(mod_idx - int(mod_idx + 0.5));
modulation_interpolate->valueI(mod_idx - int(mod_idx + 0.5));
#if INTERPOLATE == LINEAR
*bp = int(modulation_interpolate.LinearInterpolate() + 0.5);
*bp = int(modulation_interpolate->LinearInterpolate() + 0.5);
#elif INTERPOLATE == QUDRATIC
*bp = int(modulation_interpolate.QuadraticInterpolate() + 0.5);
*bp = int(modulation_interpolate->QuadraticInterpolate() + 0.5);
#elif INTERPOLATE == COSINE
*bp = int(modulation_interpolate.CosineInterpolate() + 0.5);
*bp = int(modulation_interpolate->CosineInterpolate() + 0.5);
#elif INTERPOLATE == CUBIC
*bp = int(modulation_interpolate.CubicInterpolate() + 0.5);
*bp = int(modulation_interpolate->CubicInterpolate() + 0.5);
#elif INTERPOLATE == LAGRANGE
*bp = int(modulation_interpolate.LagrangeInterpolate() + 0.5);
*bp = int(modulation_interpolate->LagrangeInterpolate() + 0.5);
#else
// No interpolation - should sound really bad...
int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % _delay_length;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
*bp = _delayline[_delay_length - 1 + c_mod_idx];
else
*bp = _delayline[c_mod_idx];
#endif
@ -146,7 +145,7 @@ void AudioEffectModulatedDelay::update(void)
// No interpolation - should sound really bad...
int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % _delay_length;
if (c_mod_idx < 0)
*bp = _delayline[_delay_length + c_mod_idx];
*bp = _delayline[_delay_length - 1 + c_mod_idx];
else
*bp = _delayline[c_mod_idx];
#endif

@ -26,6 +26,7 @@
#include "Arduino.h"
#include "AudioStream.h"
#include "config.h"
/*************************************************************************/
@ -51,6 +52,10 @@ class AudioEffectModulatedDelay :
private:
audio_block_t *inputQueueArray[2];
#ifdef INTERPOLATE
class interpolation *modulation_interpolate;
#endif
int16_t *_delayline;
int16_t _circ_idx;
uint16_t _max_delay_length;

Loading…
Cancel
Save