I've been using some code which implements a low pass filter on audio signal data sampled every 100 microseconds (EDIT: i originally mistakenly typed nano) (aka 10Khz) and then subtracts that lowpassed data from the original signal to yield a highpassed signal. If I'm not mistaken, this code is an implementation of the single pole lowpass filter described here.
My question is how do i calculate the cutoff frequency this code is giving me?
EDIT: added declaration of valueLowpassed
void hw_timer_sample_fn(void) {
// init this to typical bias level from op amp
static float valueLowpassed = 555.0f;
// read a sample from the Analog to Digital Converter (ADC)
uint16_t adcValue = system_adc_read();
// single pole, low-pass filter -- what is FREQUENCY?
valueLowpassed = valueLowpassed + (adcValue - valueLowpassed) / 64.0f;
// remove lowpassed from original signal
const float valueHighpassed = adcValue - valueLowpassed;
// etc. etc.
}
I have a vague sense that if I increase 64.0f, this is making the filter less drastic but its effect is more sluggish and steady -- is this lowering or raising the cutoff frequency? I decrease that number it has a much more active 'correction' of the original signal.
64.0f
isalpha
[per article]. But, the article calculatesalpha
from:delta_t = t[1]-t[0]; tau = 0.002; alpha = delta_t / tau
. So, that might be a better basis to start with rather than hardwiring it. - Craig EsteyvalueLowpassed
? Integer or Float? - Michael Dorgan