SMaller fixes and tests.

master
Holger Wirtz 6 years ago
parent 9c353f0e09
commit e9f689d5f6
  1. 13
      MicroMDAEPiano.ino
  2. 8
      config.h
  3. 15
      effect_modulated_delay.cpp
  4. 4
      effect_modulated_delay.h
  5. 2
      mdaEPiano.cpp

@ -158,6 +158,7 @@ elapsedMillis cpu_mem_millis;
short l_delayline[CHORUS_DELAY_LENGTH_SAMPLES]; short l_delayline[CHORUS_DELAY_LENGTH_SAMPLES];
short r_delayline[CHORUS_DELAY_LENGTH_SAMPLES]; short r_delayline[CHORUS_DELAY_LENGTH_SAMPLES];
enum { VOL_MAIN, VOL_REVERB, VOL_CHORUS };
//************************************************************************************************* //*************************************************************************************************
//* SETUP FUNCTION //* SETUP FUNCTION
//************************************************************************************************* //*************************************************************************************************
@ -244,12 +245,12 @@ void setup()
inverter.gain(-1.0); // change phase for second moduleated delay inverter.gain(-1.0); // change phase for second moduleated delay
// internal mixing of original signal(0), reverb(1) and chorus(2) // internal mixing of original signal(0), reverb(1) and chorus(2)
mixer_r.gain(0, 0.5); mixer_r.gain(VOL_MAIN, 0.4);
mixer_l.gain(0, 0.5); mixer_l.gain(VOL_MAIN, 0.4);
mixer_r.gain(1, 0.2); mixer_r.gain(VOL_REVERB, 0.2);
mixer_l.gain(1, 0.2); mixer_l.gain(VOL_REVERB, 0.2);
mixer_r.gain(2, 0.3); mixer_r.gain(VOL_CHORUS, 0.2);
mixer_l.gain(2, 0.3); mixer_l.gain(VOL_CHORUS, 0.2);
// set master volume // set master volume
set_master_volume(master_volume); set_master_volume(master_volume);

@ -62,9 +62,9 @@
#define USE_XFADE_DATA 1 #define USE_XFADE_DATA 1
// CHORUS parameters // CHORUS parameters
#define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!! #define INTERPOLATION_WINDOW_SIZE 7 // use only odd numbers!!!
#define INTERPOLATE Catmull #define INTERPOLATE_MODE 11
#define CHORUS_WAVEFORM WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE #define CHORUS_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#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! #define CHORUS_DELAY_LENGTH_SAMPLES (15*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!
//************************************************************************************************* //*************************************************************************************************
//* DEBUG OUTPUT SETTINGS //* DEBUG OUTPUT SETTINGS
@ -101,7 +101,7 @@
30: 1.22 Volts p-p 30: 1.22 Volts p-p
31: 1.16 Volts p-p 31: 1.16 Volts p-p
*/ */
#define SGTL5000_LINEOUT_LEVEL 29 #define SGTL5000_LINEOUT_LEVEL 26
//#define SDCARD_CS_PIN 10 //#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7 //#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14 //#define SDCARD_SCK_PIN 14

@ -78,11 +78,11 @@ void AudioEffectModulatedDelay::update(void)
block = receiveWritable(0); block = receiveWritable(0);
modulation = receiveReadOnly(1); modulation = receiveReadOnly(1);
#ifdef INTERPOLATE #ifdef INTERPOLATE_MODE
int8_t j; int8_t j;
float x[INTERPOLATION_WINDOW_SIZE]; float x[INTERPOLATION_WINDOW_SIZE];
float y[INTERPOLATION_WINDOW_SIZE]; float y[INTERPOLATION_WINDOW_SIZE];
Spline s(x, y, INTERPOLATION_WINDOW_SIZE, INTERPOLATE); Spline s(x, y, INTERPOLATION_WINDOW_SIZE, INTERPOLATE_MODE);
#endif #endif
bp = block->data; bp = block->data;
@ -100,28 +100,25 @@ void AudioEffectModulatedDelay::update(void)
// calculate modulation index // calculate modulation index
mod_idx = float(*mp) / SHRT_MAX * float(_delay_length / 2); // calculate an index with modulation as a float(!!!) mod_idx = float(*mp) / SHRT_MAX * float(_delay_length / 2); // calculate an index with modulation as a float(!!!)
#ifdef INTERPOLATE #ifdef INTERPOLATE_MODE
// get x/y values around mod_idx // get x/y values around mod_idx
uint8_t c = 0; uint8_t c = 0;
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx; int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx;
int32_t avg=0;
for (j = INTERPOLATION_WINDOW_SIZE / -2; j <= INTERPOLATION_WINDOW_SIZE / 2; j++) for (j = INTERPOLATION_WINDOW_SIZE / -2; j <= INTERPOLATION_WINDOW_SIZE / 2; j++)
{ {
int16_t jc_mod_idx = (c_mod_idx + j) % _delay_length - 1; int16_t jc_mod_idx = (c_mod_idx + j) % (_delay_length - 1);
if (jc_mod_idx < 0) if (jc_mod_idx < 0)
y[c] = float(_delayline[_delay_length - 1 + jc_mod_idx]); y[c] = float(_delayline[_delay_length - 1 + jc_mod_idx]);
else else
y[c] = float(_delayline[jc_mod_idx]); y[c] = float(_delayline[jc_mod_idx]);
x[c] = float(c); x[c] = float(c);
avg += y[c];
c++; // because 42 is the answer! ;-) c++; // because 42 is the answer! ;-)
} }
//*bp = int(s.value(mod_idx - int(mod_idx + 0.5)) + 0.5); *bp = int(s.value(mod_idx - int(mod_idx + 0.5)) + 0.5);
*bp = avg / INTERPOLATION_WINDOW_SIZE;
#else #else
// No interpolation - should sound really bad... // No interpolation - should sound really bad...
int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % _delay_length - 1; int16_t c_mod_idx = (int(mod_idx + 0.5) + _circ_idx) % (_delay_length - 1);
if (c_mod_idx < 0) if (c_mod_idx < 0)
*bp = _delayline[_delay_length - 1 + c_mod_idx]; *bp = _delayline[_delay_length - 1 + c_mod_idx];
else else

@ -35,8 +35,6 @@
// 140219 - correct storage class (not static) // 140219 - correct storage class (not static)
// 190527 - added modulation input handling (by Holger Wirtz) // 190527 - added modulation input handling (by Holger Wirtz)
#define CHORUS_DELAY_PASSTHRU -1
class AudioEffectModulatedDelay : class AudioEffectModulatedDelay :
public AudioStream public AudioStream
{ {
@ -50,8 +48,6 @@ class AudioEffectModulatedDelay :
virtual void setDelay(float milliseconds); virtual void setDelay(float milliseconds);
private: private:
void _spline_interpolation(float* x, float* a, uint8_t n);
int16_t interpolate(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
audio_block_t *inputQueueArray[2]; audio_block_t *inputQueueArray[2];
int16_t *_delayline; int16_t *_delayline;
int16_t _circ_idx; int16_t _circ_idx;

@ -253,7 +253,7 @@ void mdaEPiano::setOverdrive(float value)
void mdaEPiano::setLoudness(float value) void mdaEPiano::setLoudness(float value)
{ {
//volume = value * 0.32258; // 0.00002 * 127^2 //volume = value * 0.32258; // 0.00002 * 127^2
volume = value * 0.2f; volume = value * 0.18f;
} }
void mdaEPiano::setParameter(int32_t index, float value) void mdaEPiano::setParameter(int32_t index, float value)

Loading…
Cancel
Save