Fixing types.

Enabling chorus in etup() again.
Small fixes.
master
Holger Wirtz 6 years ago
parent 19c9fbc24e
commit fd409c2be3
  1. 6
      MicroMDAEPiano.ino
  2. 2
      config.h
  3. 28
      effect_modulated_chorus.cpp
  4. 8
      effect_modulated_chorus.h

@ -227,7 +227,6 @@ void setup()
Serial.print(audio_block_time_us); Serial.print(audio_block_time_us);
Serial.println(F("ms)")); Serial.println(F("ms)"));
/*
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) { if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed")); Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1); while (1);
@ -239,10 +238,11 @@ void setup()
// chorus modulation fixed // chorus modulation fixed
modulator.begin(CHORUS_WAVEFORM); modulator.begin(CHORUS_WAVEFORM);
modulator.amplitude(0.1); modulator.amplitude(1.0);
modulator.frequency(1.0); modulator.frequency(1.0);
modulator.phase(0); modulator.phase(0);
*/ modulator.offset(0.0);
// 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, 1.0); mixer_r.gain(0, 1.0);
mixer_l.gain(0, 1.0); mixer_l.gain(0, 1.0);

@ -62,7 +62,7 @@
#define USE_XFADE_DATA 1 #define USE_XFADE_DATA 1
// CHORUS parameters // CHORUS parameters
#define INTERPOLATION_WINDOW_SIZE 7 // For chorus, only odd numbers,please! #define INTERPOLATION_WINDOW_SIZE 7 // For chorus, only odd numbers,please!
#define INTERPOLATE LAGRANGE // LINEAR QUADRATIC COSINE CUBIC LAGRANGE #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_TRIANGLE // WAVEFORM_SINE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE WAVEFORM_SQUARE WAVEFORM_TRIANGLE
#define CHORUS_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES) #define CHORUS_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES)

@ -58,7 +58,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delay_length = d_length; _delay_length = d_length;
_delay_length_half = d_length / 2; _delay_length_half = d_length / 2;
memset(_delayline, 0, sizeof(short)*_delay_length); memset(_delayline, 0, sizeof(int16_t)*_delay_length);
return (true); return (true);
} }
@ -69,8 +69,8 @@ void AudioEffectModulatedDelay::update(void)
audio_block_t *block; audio_block_t *block;
audio_block_t *modulation; audio_block_t *modulation;
short *bp; int16_t *bp;
short *mp; int16_t *mp;
float mod_idx; float mod_idx;
if (_delayline == NULL) if (_delayline == NULL)
@ -83,8 +83,6 @@ void AudioEffectModulatedDelay::update(void)
block = receiveWritable(0); block = receiveWritable(0);
modulation = receiveReadOnly(1); modulation = receiveReadOnly(1);
if (block && modulation)
{
#ifdef INTERPOLATE #ifdef INTERPOLATE
int8_t j; int8_t j;
float x[INTERPOLATION_WINDOW_SIZE]; float x[INTERPOLATION_WINDOW_SIZE];
@ -94,13 +92,15 @@ void AudioEffectModulatedDelay::update(void)
modulation_interpolate.valueY(y); modulation_interpolate.valueY(y);
for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++) for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++)
x[j] = j; x[j] = float(j);
#endif #endif
bp = block->data; bp = block->data;
mp = modulation->data; mp = modulation->data;
for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) if (block && modulation)
{
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)
{ {
// write data into circular buffer // write data into circular buffer
if (_circ_idx >= _delay_length) if (_circ_idx >= _delay_length)
@ -117,15 +117,17 @@ void AudioEffectModulatedDelay::update(void)
#ifdef INTERPOLATE #ifdef INTERPOLATE
// get x/y values around mod_idx // get x/y values around mod_idx
uint16_t i_mod_idx = int(mod_idx + 0.5); uint16_t i_mod_idx = int(mod_idx + 0.5);
uint8_t c = 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 ji_mod_idx = i_mod_idx + j; int16_t ji_mod_idx = i_mod_idx + j;
if (ji_mod_idx > _delay_length) if (ji_mod_idx > _delay_length)
y[j] = _delayline[ji_mod_idx - _delay_length - 1]; y[c] = float(_delayline[ji_mod_idx - _delay_length - 1]);
else if (ji_mod_idx < 0) else if (ji_mod_idx < 0)
y[j] = _delayline[_delay_length + j + 1]; y[c] = float(_delayline[_delay_length + j + 1]);
else else
y[j] = _delayline[ji_mod_idx]; y[c] = float(_delayline[ji_mod_idx]);
c++; // ;-)
} }
modulation_interpolate.valueI(mod_idx); modulation_interpolate.valueI(mod_idx);
@ -155,8 +157,12 @@ void AudioEffectModulatedDelay::update(void)
} }
} }
// transmit the block if (block)
{
transmit(block, 0); transmit(block, 0);
release(block); release(block);
}
if (modulation)
release(modulation); release(modulation);
} }

@ -50,10 +50,10 @@ class AudioEffectModulatedDelay :
private: private:
audio_block_t *inputQueueArray[2]; audio_block_t *inputQueueArray[2];
short *_delayline; int16_t *_delayline;
short _circ_idx; int16_t _circ_idx;
int _delay_length; uint16_t _delay_length;
int _delay_length_half; uint16_t _delay_length_half;
}; };
#endif #endif

Loading…
Cancel
Save