Reson~ with sharp Q has long attack/decay. Why?

    Jan 31 2011 | 1:11 am
    I'm trying to extract information about a few specific frequencies from an audio stream.
    The easiest way, I thought, was to use a reson~ object at the desired frequency with an extremely high Q, say 10,000. However, I noticed that by doing so, I lose temporal resolution: if the input signal abruptly switches away from the resonant frequency, it takes output from reson~ a long time to catch up.
    Why is this?
    I'm attaching a patch that shows this effect clearly. Use the preset to pre-load the reson~ filter with the correct settings, then use the messages attached to the cycle~ object to jump between frequencies.
    I'm not attached to reson, so if there's a better way to isolate specific frequencies very quickly (say with a +/- 25hz bandwidth and 100ms response time) I'm all ears.

    • Jan 31 2011 | 8:03 pm
      normal digital time domain filters are made of delay units. to obtain a very steep rolloff, these filters either need a lot of delay units (i.e. a very long filter kernel) or you use recursive filters, that have a feedback path. reson~ is one of those. so, if you set the resonance very high to make the filter bandwidth small, the feedback coefficients are set high and the filter starts to resonate (to ring).
      if you want to reduce the ringing and still have a steep rolloff you could try to put a few of these in series.
      in the example below, i used a 4 biquad~s in bandpass mode and it seems to work ok.
      if you want to find out, if a signal component is present (and not necessarily filter the signal) you could look into goertzel filters. these are used in DTMF signaling. if you are on osx and want to try it out, you can find an goertzel filter external here
    • Jan 31 2011 | 11:07 pm
      Volker, thanks very much for the explanation and patch. I've only been able to give it a cursory look but the response seems to be much faster. Thanks. I've also downloaded your goertzel filter; my end goal with this is actually quite similar to DTMF recognition.
    • Jan 31 2011 | 11:46 pm
      Hi Volker,
      thanks alot for the goertzel filter !
      I have one question about its frequency resolution:
      Are the frequency bins centered on multiples of sr/blocksize like with DFT ?
      Is the output of the goertzel filter any different from the magnitude of the coresponding of a "complete" DFT ?
      nochmals vielen Dank,
    • Jan 31 2011 | 11:59 pm
      Umm a q of 10,000 seems excessive to me > at 1000Hz this gives a bandwidth of 0.1 Hz . . .
      Is this what you were after? for 25Hz Bandwidth at 1kHz Q would be 40 . . . .
    • Feb 01 2011 | 12:15 pm
      > Is the output of the goertzel filter any different from the magnitude of the
      > coresponding of a "complete" DFT ?
      no, there shouldn't be any difference, except that the goertzel output is already scaled to 0 - 1 range. also in windowing (gaussian) mode i tried to rescale the values, so they have the same range as with no windowing.
      (btw. i just uploaded a new version where this rescaling value is slightly more accurate).
      > Are the frequency bins centered on multiples of sr/blocksize like with DFT ?
      as i understand it there are no 'bins' involved, so you can look for any kind of frequency.
      but you are right, you get the most accurate/stable readings, for frequencies that are multiples of sr/blocksize.
      maybe one could think of it, as if the 'in between freqs' are more or less perfect interpolations of the magnitudes of two neighbouring 'bin freqs'.
      as i understand it, the goertzel filter is a simple iir filter, you could even build one with a biquad~.
      however i was interested in accurate readings, that's why i ended up making an external.
      > thanks alot for the goertzel filter !
      you are welcome!