Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Howto Filter with low steepness?

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    14

    Howto Filter with low steepness?

    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

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,589
    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

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,710
    Quote Originally Posted by Theremingenieur View Post
    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

  4. #4
    Junior Member
    Join Date
    Dec 2017
    Posts
    14
    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/techn..._book_Ch19.pdf and http://www.spinsemi.com/knowledge_ba...ow_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 by cebersp; 12-21-2017 at 11:19 AM.

  5. #5
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,589
    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.

  6. #6
    Junior Member
    Join Date
    Dec 2017
    Posts
    14
    Quote Originally Posted by Theremingenieur View Post
    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

  7. #7
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    253
    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/da...ial-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/b...ster/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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •