Added arm_biquad LP filter for modulation.

dev
Holger Wirtz 5 years ago
parent 9e6e5bca3a
commit b2cf72fae0
  1. 1
      config.h
  2. 42
      effect_modulated_delay.cpp
  3. 13
      effect_modulated_delay.h

@ -60,7 +60,6 @@
//#define CHORUS_MODULATOR_FILTER_FRQ 10 // see https://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/ //#define CHORUS_MODULATOR_FILTER_FRQ 10 // see https://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/
//#define CHORUS_MODULATOR_FILTER_Q 0.7 //#define CHORUS_MODULATOR_FILTER_Q 0.7
#define CHORUS_MODULATOR_BIQUAD 1 #define CHORUS_MODULATOR_BIQUAD 1
//#define CHORUS_OUTPUT_BIQUAD 1
//************************************************************************************************* //*************************************************************************************************
//* DEBUG OUTPUT SETTINGS //* DEBUG OUTPUT SETTINGS
//************************************************************************************************* //*************************************************************************************************

@ -59,20 +59,15 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delay_length = d_length; _delay_length = d_length;
#ifdef CHORUS_MODULATOR_BIQUAD #ifdef CHORUS_MODULATOR_BIQUAD
mod_lp_coeffs[0] = -1.98982427; // https://arachnoid.com/BiQuadDesigner/ Lopass Fc=50Hz, Q=0.7 filter_lp_mod.numStages = 1;
mod_lp_coeffs[1] = 0.98987476; filter_lp_mod.pState = filter_lp_state;
mod_lp_coeffs[2] = 1.26228228e-5; filter_lp_mod.pCoeffs = filter_lp_coeffs;
mod_lp_coeffs[3] = 2.52456456e-5;
mod_lp_coeffs[4] = 1.26228228e-5; filter_lp_coeffs[0] = 0.072959657268266670;
biquad_mod = {1, mod_lp_state, mod_lp_coeffs}; filter_lp_coeffs[1] = 0.072959657268266670;
#endif filter_lp_coeffs[2] = 0.0;
#ifdef CHORUS_OUTUT_BIQUAD // https://web.fhnw.ch/technik/projekte/eit/Fruehling2016/MuelZum/html/parametric__equalizer__example_8c_source.html filter_lp_coeffs[3] = 0.854080685463466605;
out_lp_coeffs[0] = -0.10987036; // https://arachnoid.com/BiQuadDesigner/ Lopass Fc=10000Hz, Q=0.3 filter_lp_coeffs[4] = 0.0;
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 #endif
return (true); return (true);
} }
@ -95,13 +90,12 @@ void AudioEffectModulatedDelay::update(void)
float mod_idx; float mod_idx;
float mod_number; float mod_number;
float mod_fraction; float mod_fraction;
float mod_float[AUDIO_BLOCK_SAMPLES];
bp = block->data; bp = block->data;
arm_q15_to_float(modulation->data, mod_float, AUDIO_BLOCK_SAMPLES); arm_q15_to_float(modulation->data, modulation_f32, AUDIO_BLOCK_SAMPLES);
mp = mod_float; mp = modulation_f32;
#ifdef CHORUS_MODULATOR_BIQUAD #ifdef CHORUS_MODULATOR_BIQUAD
arm_biquad_cascade_df1_f32(&biquad_mod, mod_float, mod_float, AUDIO_BLOCK_SAMPLES); arm_biquad_cascade_df1_f32(&filter_lp_mod, modulation_f32, modulation_f32, AUDIO_BLOCK_SAMPLES);
#endif #endif
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)
@ -133,14 +127,13 @@ void AudioEffectModulatedDelay::update(void)
} }
else else
{ {
idx[0] = c_mod_idx + 1; idx[0] = c_mod_idx;
idx[1] = c_mod_idx; idx[1] = c_mod_idx + 1;
} }
if (mod_idx < 0.0) if (mod_idx < 0.0)
*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); *bp = round(float(_delayline[idx[0]]) * (1.0 - mod_fraction) + float(_delayline[idx[1]]) * mod_fraction);
else
*bp = round(float(_delayline[idx[0]]) * mod_fraction + float(_delayline[idx[1]]) * (1.0 - mod_fraction));
// push the pointers forward // push the pointers forward
bp++; // next audio data bp++; // next audio data
@ -154,9 +147,6 @@ 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);
} }

@ -57,15 +57,12 @@ class AudioEffectModulatedDelay :
int16_t c_mod_idx; int16_t c_mod_idx;
uint16_t idx[2]; uint16_t idx[2];
#ifdef CHORUS_MODULATOR_BIQUAD #ifdef CHORUS_MODULATOR_BIQUAD
arm_biquad_casd_df1_inst_f32 biquad_mod; arm_biquad_casd_df1_inst_f32 filter_lp_mod;
float mod_lp_state[2]; float filter_lp_state[4];
float mod_lp_coeffs[5]; float filter_lp_coeffs[5];
#endif float modulation_f32[AUDIO_BLOCK_SAMPLES];
#ifdef CHORUS_OUTPUT_BIQUAD
arm_biquad_casd_df1_inst_q15 biquad_out;
float out_lp_state[2];
float out_lp_coeffs[5];
#endif #endif
}; };
#endif #endif

Loading…
Cancel
Save