I am using the following IIR code as a low-pass filter in a software project, and it works great. However, I would like the slope of the filter to be much steeper as the one here seems to be very gradual (6 db/octave, from what I understand):
#define CUTOFF_FREQ 500.0 #define SAMPLE_RATE 48000.0 float RC = 1.0/(CUTOFF_FREQ*2*M_PI); float dt = 1.0/SAMPLE_RATE; float alpha = dt/(RC+dt); float output_sample,prev_sample,cur_sample; /* Run the filter on the two samples (normally done inside a loop) */ output_sample = prev_sample + (alpha*(cur_sample - prev_sample));
I would like perhaps a 12 db/octave slope or even 18 db/octave, similar to the low-pass filters in popular audio programs. Is it possible to modify this code for this purpose? Or should I be looking into alternate implementations altogether?