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

Thread: AudioFilterStateVariable unwanted noise

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    11

    AudioFilterStateVariable unwanted noise

    I'm getting a raspy noise from the AudioFilterStateVariable under certain conditions.
    (I'm using a Teensy 4.1 with TEENSY4_AUDIO adapter board).

    when the combination of the freq control input, frequency(freq) and resonance(.707) push the filter parameters out of wack the filter outputs a awful, unwanted noise.

    I've created an example design to demonstrate the problem. I believe that the problem occurs when the filter cutoff frequency is pushed close to or above Nyquist, particularly when the resonance is low (like .707).

    It would be great if the filter could internally limit the F after the calculation F = Fcenter*2^(signal*octaves).

    Or perhaps, someone has a work around?

    The attached file has the example design is attached (filter_noise.ino).

    filter_noise.ino

  2. #2
    Junior Member
    Join Date
    Oct 2020
    Posts
    11
    Apparently, there is a limit to the F after the calculation F = Fcenter*2^(signal*octaves).
    in

    void AudioFilterStateVariable::update_variable(const int16_t *in,
    const int16_t *ctl, int16_t *lp, int16_t *bp, int16_t *hp)

    ...
    if (fmult > 5378279) fmult = 5378279;
    fmult = fmult << 8;

    ...
    though I'm not sure what the magic number 5378279 and why fmult gets shifted left by 8 here.

    Anyway, this doesn't explain why the filter makes that really loud, raspy white noise sound as described in the post above.

    anyone know why it does that?

  3. #3
    Junior Member
    Join Date
    Oct 2020
    Posts
    11
    Ok, so after analyzing filter_variable.cpp, I fixed the problem with the noise.

    I made a couple of changes to filter_variable.cpp
    First, I uncommented line 42 to define IMPROVE_HIGH_FREQUENCY_ACCURACY
    next I changed line 133 from:
    if (fmult > 5378279) fmult = 5378279;
    to:
    if (fmult > 4205728) fmult = 4205728;

    then after fmult << 8, fmult (normalized) is limited to slightly more than 1.0
    This limits the adjusted filter cutoff ( Fcenter*2^(signal*octaves) ) to 14,744 Hz


    this magic number of 4205728, should probably be tied to resonance value ('damp' in filter_variable.cpp), then the filter's adjusted cutoff could go higher with higher resonance values.

    I'm not sure if there are other ramifications regarding this hack, but it seems to work well for my purposes.

  4. #4
    Senior Member
    Join Date
    Apr 2019
    Posts
    149
    Thanks very much for this. It's solved a problem where resonance values below 1.1 were causing noise for me.

Posting Permissions

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