Filter for modulator implemented again (just testing).

master
Holger Wirtz 5 years ago
parent f8d7c097ac
commit 3393c60ed6
  1. 19
      effect_modulated_delay.cpp
  2. 5
      effect_modulated_delay.h

@ -58,6 +58,16 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delayline = delayline;
_delay_length = d_length;
// modulator filter
// coefficients calculated with "IOWA Hills IIR Filter Designer 6.5"
// OmegaC = 0.5, SR = 44117.64706, Fc = 11 kHz, N=2
modulator_filter_coeffs[0] = 0.291938819295525787; // b0
modulator_filter_coeffs[1] = 0.582700575839973478; // b1
modulator_filter_coeffs[2] = 0.291938819295525787; // b2
modulator_filter_coeffs[3] = -0.005242268129729576; // a1
modulator_filter_coeffs[4] = 0.171820482560754689; // a2
modulator_filter_data = {1, &modulator_filter_state, modulator_filter_coeffs};
return (true);
}
@ -65,8 +75,6 @@ void AudioEffectModulatedDelay::update(void)
{
audio_block_t *block;
audio_block_t *modulation;
float alpha = 0.9f; // 90% new value, 10% feedback
static float filteredOutput;
if (_delayline == NULL)
return;
@ -85,6 +93,7 @@ void AudioEffectModulatedDelay::update(void)
bp = block->data;
arm_q15_to_float(modulation->data, modulation_f32, AUDIO_BLOCK_SAMPLES);
arm_biquad_cascade_df1_f32(&modulator_filter_data, modulation_f32, modulation_f32, AUDIO_BLOCK_SAMPLES);
mp = modulation_f32;
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)
@ -94,12 +103,8 @@ void AudioEffectModulatedDelay::update(void)
_cb_index = 0;
_delayline[_cb_index] = *bp;
// Simple 1st order IIR, mix the new value with the old value (for modulation to get a band-limited signal)
filteredOutput = (*mp * alpha) + filteredOutput * (1 - alpha);
// Calculate the modulation-index as a floating point number for interpolation
//mod_index = *mp * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
mod_index = filteredOutput * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
mod_index = *mp * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
mod_fraction = modff(mod_index, &mod_number); // split float of mod_index into integer (= mod_number) and fraction part
// calculate modulation index into circular buffer

@ -54,7 +54,10 @@ class AudioEffectModulatedDelay :
uint16_t _cb_index; // current write pointer of the circular buffer
uint16_t _delay_offset; // number of samples for the read offset of the modulation inside the circular buffer
uint16_t _delay_length; // calculated number of samples of the delay
int16_t cb_mod_index; // current read pointer with modulation for the circular buffer
int16_t cb_mod_index; // current read pointer with modulation for the circular buffer
arm_biquad_casd_df1_inst_f32 modulator_filter_data;
float32_t modulator_filter_state;
float32_t modulator_filter_coeffs[5];
};
#endif

Loading…
Cancel
Save