Fixing types.

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

@ -227,22 +227,22 @@ void setup()
Serial.print(audio_block_time_us);
Serial.println(F("ms)"));
/*
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1);
}
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH)) {
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed"));
while (1);
}
if (!modchorus_r.begin(r_delayline, CHORUS_DELAY_LENGTH)) {
Serial.println(F("AudioEffectModulatedDelay - right channel begin failed"));
while (1);
}
if (!modchorus_l.begin(l_delayline, CHORUS_DELAY_LENGTH)) {
Serial.println(F("AudioEffectModulatedDelay - left channel begin failed"));
while (1);
}
// chorus modulation fixed
modulator.begin(CHORUS_WAVEFORM);
modulator.amplitude(1.0);
modulator.frequency(1.0);
modulator.phase(0);
modulator.offset(0.0);
// chorus modulation fixed
modulator.begin(CHORUS_WAVEFORM);
modulator.amplitude(0.1);
modulator.frequency(1.0);
modulator.phase(0);
*/
// internal mixing of original signal(0), reverb(1) and chorus(2)
mixer_r.gain(0, 1.0);
mixer_l.gain(0, 1.0);

@ -62,7 +62,7 @@
#define USE_XFADE_DATA 1
// CHORUS parameters
#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_DELAY_LENGTH (16*AUDIO_BLOCK_SAMPLES)

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

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

Loading…
Cancel
Save