|
|
@ -58,6 +58,22 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length) |
|
|
|
_delayline = delayline; |
|
|
|
_delayline = delayline; |
|
|
|
_delay_length = d_length; |
|
|
|
_delay_length = d_length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CHORUS_MODULATOR_BIQUAD |
|
|
|
|
|
|
|
mod_lp_coeffs[0] = -1.98982427; // https://arachnoid.com/BiQuadDesigner/ Lopass Fc=50Hz, Q=0.7
|
|
|
|
|
|
|
|
mod_lp_coeffs[1] = 0.98987476; |
|
|
|
|
|
|
|
mod_lp_coeffs[2] = 1.26228228e-5; |
|
|
|
|
|
|
|
mod_lp_coeffs[3] = 2.52456456e-5; |
|
|
|
|
|
|
|
mod_lp_coeffs[4] = 1.26228228e-5; |
|
|
|
|
|
|
|
biquad_mod = {1, mod_lp_state, mod_lp_coeffs}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef CHORUS_OUTUT_BIQUAD // https://web.fhnw.ch/technik/projekte/eit/Fruehling2016/MuelZum/html/parametric__equalizer__example_8c_source.html
|
|
|
|
|
|
|
|
out_lp_coeffs[0] = -0.10987036; // https://arachnoid.com/BiQuadDesigner/ Lopass Fc=10000Hz, Q=0.3
|
|
|
|
|
|
|
|
out_lp_coeffs[1] = -0.24497694; |
|
|
|
|
|
|
|
out_lp_coeffs[2] = 0.16128817; |
|
|
|
|
|
|
|
out_lp_coeffs[3] = 0.32257635; |
|
|
|
|
|
|
|
out_lp_coeffs[4] = 0.16128817; |
|
|
|
|
|
|
|
biquad_out = {1, out_lp_state, out_lp_coeffs, 0}; |
|
|
|
|
|
|
|
#endif |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -84,6 +100,9 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
bp = block->data; |
|
|
|
bp = block->data; |
|
|
|
arm_q15_to_float(modulation->data, mod_float, AUDIO_BLOCK_SAMPLES); |
|
|
|
arm_q15_to_float(modulation->data, mod_float, AUDIO_BLOCK_SAMPLES); |
|
|
|
mp = mod_float; |
|
|
|
mp = mod_float; |
|
|
|
|
|
|
|
#ifdef CHORUS_MODULATOR_BIQUAD |
|
|
|
|
|
|
|
arm_biquad_cascade_df1_f32(&biquad_mod, mod_float, mod_float, AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -93,11 +112,11 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
_delayline[_circ_idx] = *bp; |
|
|
|
_delayline[_circ_idx] = *bp; |
|
|
|
|
|
|
|
|
|
|
|
// Calculate the modulation-index as a floating point number for interpolation
|
|
|
|
// Calculate the modulation-index as a floating point number for interpolation
|
|
|
|
mod_idx = _delay_offset + (*mp * (1 - MODULATION_MAX_FACTOR) * _delay_length); |
|
|
|
mod_idx = *mp * (1 - MODULATION_MAX_FACTOR) * _delay_length; |
|
|
|
mod_fraction = modff(mod_idx, &mod_number); |
|
|
|
mod_fraction = modff(mod_idx, &mod_number); |
|
|
|
|
|
|
|
|
|
|
|
// calculate modulation index into circular buffer
|
|
|
|
// calculate modulation index into circular buffer
|
|
|
|
c_mod_idx = (_circ_idx - int(mod_number)) % _delay_length; |
|
|
|
c_mod_idx = (_circ_idx - _delay_offset - int(mod_number)) % _delay_length; |
|
|
|
if (c_mod_idx < 0) // check for negative offsets and correct them
|
|
|
|
if (c_mod_idx < 0) // check for negative offsets and correct them
|
|
|
|
c_mod_idx += _delay_length; |
|
|
|
c_mod_idx += _delay_length; |
|
|
|
|
|
|
|
|
|
|
@ -117,7 +136,11 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
idx[0] = c_mod_idx + 1; |
|
|
|
idx[0] = c_mod_idx + 1; |
|
|
|
idx[1] = c_mod_idx; |
|
|
|
idx[1] = c_mod_idx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (mod_idx < 0.0) |
|
|
|
*bp = round(float(_delayline[idx[0]]) * (mod_fraction) + float(_delayline[idx[1]]) * (1.0 - mod_fraction)); |
|
|
|
*bp = round(float(_delayline[idx[0]]) * (mod_fraction) + float(_delayline[idx[1]]) * (1.0 - mod_fraction)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
*bp = round(float(_delayline[idx[0]]) * (1.0 - mod_fraction) + float(_delayline[idx[1]]) * mod_fraction); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// push the pointers forward
|
|
|
|
// push the pointers forward
|
|
|
|
bp++; // next audio data
|
|
|
|
bp++; // next audio data
|
|
|
@ -131,6 +154,9 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
|
|
|
|
|
|
|
if (block) |
|
|
|
if (block) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef CHORUS_OUTPUT_BIQUAD |
|
|
|
|
|
|
|
arm_biquad_cascade_df1_fast_q15(&biquad_out, (q15_t*)block, (q15_t*)block, AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
#endif |
|
|
|
transmit(block, 0); |
|
|
|
transmit(block, 0); |
|
|
|
release(block); |
|
|
|
release(block); |
|
|
|
} |
|
|
|
} |
|
|
|