Howto Filter with low steepness?

Status
Not open for further replies.

cebersp

Well-known member
Hi,
at the Moment I use:

biquad1.setHighpass(0, p_value[1], 0.707); // Butterworth filter, 12 db/octave

Is there a way to get less than 12 db/octave? I would be grateful for some link with additional Information about "biquad filters".

Many thanks, Christof
 
Biquads are 12dB/oct or 40dB/decade. Same for the state variable filters based on the Chamberlin algorithm. Both are the preferred filters for musical applications since these are second order filters which allow not only to set a corner frequency, but also a Q-factor, sometimes also called damping or resonance.

Simpler filters are the recursive 1st order filters with 6dB/oct which correspond to the simple "classic" RC filters in analog circuits. Since these can often simply be realized in code by just one multiplication and one subtraction on the current and the previous sample, you won't probably find not much literature about that rather trivial thing.

Some design guidance can be found in the following article : http://freeverb3vst.osdn.jp/iir_filter.shtml
 
Since these can often simply be realized in code by just one multiplication and one subtraction on the current and the previous sample, you won't probably find not much literature about that rather trivial thing.

@cebersp A 'trivial' 6dB/octave high-pass filter is the difference of two consecutive samples y[n]=x[n]-x[n-1]; equivalently a 'trivial' 6dB/octave low-pass filter is the integral over consecutive samples y[n]=x[n]+y[n-1];
for other slopes, best is to use IIR/FIR filters
 
Thank you for the inputs!
Sometimes one only needs to know the right words to google. "Recursive 1st order filter" was helpful! I found: http://www.analog.com/media/en/technical-documentation/dsp-book/dsp_book_Ch19.pdf and http://www.spinsemi.com/knowledge_base/dsp_basics.html#low_pass_filter

In your link http://freeverb3vst.osdn.jp/iir_filter.shtml there is information how to calculate filter coefficients.

"Highpass 1-st order

H(S) = S/(S + 1)
W = tan (PI*Fc/Fs)
N = 1/(1+W)
B0 = N
B1 = -B0
A1 = N*(W-1) "

Fc is the cut-off frequency, Fs is the sampling frequency.

As far as I have understood I can use the biquad filter object setting the coefficients B2=A2=0.
The coefficients can be transferred to the biquad object by "setCoefficients()".

Thank you very much! Best regards Christof

yep, seems to work :)

Code:
void set6dbHp(float fc) // set coefficients for biquad filter highpass with 6db/octave
{
  float w = tan(PI*fc/44100.0); // see: http://freeverb3vst.osdn.jp/iir_filter.shtml
  float n = 1.0/(1.0+w);
  float b0 = n;
  float b1 = -b0;
  float a1 = n*(w-1);
  float a2=0, b2=0;
  double array1[5] = {b0, b1, b2, a1, a2};
  biquad1.setCoefficients(0, array1);
}
 
Last edited:
You could do that, basically. But there are technologies to rewrite it for more efficient and less cpu cycle consuming code. See WMXZ's equations which are just missing the coefficients.
 
But there are technologies to rewrite it for more efficient and less cpu cycle consuming code.
Sorry, better to do it quick and dirty instead of not doing it at all....

I am not familiar with the dsp-instructions of this CPU M4 so I cannot do it better quickly.
:) Christof
 
Salut Christof,

there is no need to use dsp-instructions or something similar. And it is not at all complicated, try to understand what is behind the IIR, it is really quite simple, WMXZ has already given you the clue.

For your specific problem:

Try to understand "exponential averaging" for the lowpass version

http://blog.prosig.com/2003/04/28/data-smoothing-rc-filtering-and-exponential-averaging/

You will also find a formula for the time constant there.


For your highpass filter desires, try this

http://peabody.sapp.org/class/dmp2/lab/dcblock/

https://github.com/simonyiszk/csdr/blob/master/libcsdr.c --> search for dcblock_ff

DC elimination is basically the same as a very simple highpass filter.

Have fun with the Teensy!

Frank DD4WH
 
Status
Not open for further replies.
Back
Top