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

Thread: Noise at higher filterfreqs

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    5

    Noise at higher filterfreqs

    hey,

    im a bit confused and would like to know how to get this working.

    I'm trying to add an LFO (waveform) to a filter (second input). I noticed the filter will just noise and glitch when higher then filter.frequency(13000). (standard?)

    If I add the LFO the cutoff freq will of course reach this maximum value and start to noise
    How should I "cut off" the "too much"-LFO-values?

    Cheers
    Felix

  2. #2
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    154
    You could use the amplitude member function from the AudioSynthWaveform class, assuming this is the class you use for your lfo.

  3. #3
    Junior Member
    Join Date
    Sep 2019
    Posts
    5
    Yes, i do use the AudioSynthWaveform. In case of reducing the amplitude i would not be able to let the filter swing widely in upper cutoff regions.
    There must be a way doing this. I can't be the only one trying this..

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,544
    Which filter type are you using? State variable filters (Chamberlin) work only well up to fs/6 without or fs/3 with 2x oversampling while Biquad filters have coefficient precision problems in the low frequency range. If you need to go that high (13kHz is just a little less than 44kHz/3), you should either use a Biquad filter or extend a Chamberlin filter to 3x oversampling.

  5. #5
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    154
    @f.wberg
    What do you exactly mean by "let the filter swing widely in upper cutoff regions"?

    Again assuming you use AudioFilterStateVariable, if you want to "swing" the frequency above or past 13kHz you will have to follow Theremingenieur's advice.
    Otherwise the filter's freq is calculated as follows,

    F = Fcenter * 2^(signal * octaves)

    Scale signal(your lfo) and set Fcenter and octaves so that F does not exceed your max desired freq.
    see: https://www.pjrc.com/teensy/gui/inde...rStateVariable

  6. #6
    Junior Member
    Join Date
    Sep 2019
    Posts
    5
    Well, I wrote a huge explanation to my problem and obviously didn't post it right.

    Short Explanation: I don't want to filter in higher regions then 10kHz. I want to stop the filter at this value and wait till the lfo falls again, hits this threshold and the filter start to fall then, too.

    I found this in <filter_variable.h>:

    void frequency(float freq) {
    if (freq < 20.0) freq = 20.0;
    else if (freq > AUDIO_SAMPLE_RATE_EXACT/2.5) freq = AUDIO_SAMPLE_RATE_EXACT/2.5;
    setting_fcenter = (freq * (3.141592654/(AUDIO_SAMPLE_RATE_EXACT*2.0)))
    * 2147483647.0;
    // TODO: should we use an approximation when freq is not a const,
    // so the sinf() function isn't linked?
    setting_fmult = sinf(freq * (3.141592654/(AUDIO_SAMPLE_RATE_EXACT*2.0)))
    * 2147483647.0;
    }

    If I just add
    if (freq > 10000) freq = 10000;
    my problem should be solved. Is this the way to get a max. cuttoff freq?

    Thanks for your help so far

  7. #7
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,544
    Why cripple a working algorithm if you might be able to make intelligent choices about the filter center frequency and the octave hub to limit the max fc to 10000Hz?

  8. #8
    Junior Member
    Join Date
    Sep 2019
    Posts
    5
    I want to achieve the full Amplitude of the LFO (even if the filter stays still in upper regions) while changing Fcenter.

    I will never need to set F or Fcenter above aprox 10kHz. So if you say "cripple", do you mean I just restrict the higher freqs or will I get problems by doing this?

  9. #9
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    154
    Quote Originally Posted by f.wberg View Post
    Well, I wrote a huge explanation to my problem and obviously didn't post it right.

    Short Explanation: I don't want to filter in higher regions then 10kHz. I want to stop the filter at this value and wait till the lfo falls again, hits this threshold and the filter start to fall then, too.

    I found this in <filter_variable.h>:

    void frequency(float freq) {
    if (freq < 20.0) freq = 20.0;
    else if (freq > AUDIO_SAMPLE_RATE_EXACT/2.5) freq = AUDIO_SAMPLE_RATE_EXACT/2.5;
    setting_fcenter = (freq * (3.141592654/(AUDIO_SAMPLE_RATE_EXACT*2.0)))
    * 2147483647.0;
    // TODO: should we use an approximation when freq is not a const,
    // so the sinf() function isn't linked?
    setting_fmult = sinf(freq * (3.141592654/(AUDIO_SAMPLE_RATE_EXACT*2.0)))
    * 2147483647.0;
    }

    If I just add
    if (freq > 10000) freq = 10000;
    my problem should be solved. Is this the way to get a max. cuttoff freq?

    Thanks for your help so far
    No, this will not work since this is only evaluated when you set the cutoff freq, not while modulating it. You would have to modify AudioFilterStateVariable::update_variable() in filter_variable.cpp to achieve that.

    But as stated before by Theremingenieur and myself, based on your chosen cutoff freq, scale octaves and/or lfo level so F does not exceed your max desired freq.

  10. #10
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,544
    The problem with your approach is (and that's why I called it crippled) that the filter corner frequency would remain constant for a certain time while the LFO would remain in move. Which can technically be done, but which is not forcibly a musical approach. Musical expression lives from parameters moving on. Thats why I'd suggest to adapt the octaves parameter each time you change the center frequency to make sure that in the end, you never go above 10000Hz.

    That means that each of your myFilter.frequency(Fnew) function calls would immediately be followed by a myFilter.octaveControl(log2f(10000.0/(float)Fnew)).

  11. #11
    Junior Member
    Join Date
    Sep 2019
    Posts
    5
    I just change
    //if (fmult > 5378279) fmult = 5378279;
    to
    if (fmult > 4300000) fmult = 4300000;

    in AudioFilterStateVariable::update_variable() in filter_variable.cpp.

    That's all i had to do, thats all i wanted. Thx for help.

Tags for this Thread

Posting Permissions

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