10

Given a frequency response obtained with FFT, I would like to apply a 1/n octave smoothing. What filter should I be using and how? Maybe someone could point to a good reference (a paper or book on the subject).

Psirus
  • 101
  • 1
  • 1
  • 5
  • Are you looking for a pinking filter, which attenuates frequency $f$ to amplitude $1/f$? Or do you really want something that attenuates frequency $f$ to amplitude $1/(\lg_2 f)$? – Wandering Logic Jul 18 '13 at 12:04
  • 2
    I don't want to attenuate any frequencies. I want the data to be smoothed, with a variable bandwidth, i.e 1 octave, 1/3 of an octave, etc. – Psirus Jul 18 '13 at 12:23
  • I see, so you are filtering the frequency data, and you want a nonstationary filter that gets wider as you get to higher frequencies? (I.e., for an octave-wide filter you want frequencies 16Hz-32Hz to be averaged together, 8Hz-16Hz, 2Hz-4Hz, etc.?) Would interpolating your data onto a logarithmic x-axis and then doing a low-pass filter on the result be what you are after? – Wandering Logic Jul 18 '13 at 12:57
  • Yes, possibly. How would I choose the order and cutoff-frequency? Cutoff-frequency would influence the bandwidth then, right? – Psirus Jul 18 '13 at 13:06
  • What do you mean by "smoothing with an 1/3 octave filter"? By smoothing I assume you mean a low-pass filter. Assuming that is correct, what do you mean by a 1/3 octave low-pass filter? – Jim Clay Jul 21 '13 at 01:07
  • 2
    Loudspeaker frequency responses are typically smoothed, either to make the graph easier to interpret but still quite accurate (1/20-octave smoothed), or very high smoothing (1/3-octave) for example in marketing. This is what I've read numerous times, what is meant exactly I'm trying to find out here. – Psirus Jul 21 '13 at 14:23
  • 2
    So your question is not about changing a signal, per se, it's about how to graphically show the frequency response of a device. Is that right? – Jim Clay Jul 22 '13 at 13:46
  • Correct. As stated in the question, the bounty will most likely go to an answer with a good reference. @Hilmar 's response is helpful, but I'd prefer an answer including a reference. – Psirus Jul 22 '13 at 14:47
  • So you want to take the frequency response of something, show the curve on a logarithmic (octaves or decades) frequency axis, and then apply a lowpass filter to the frequency response curve, to make the curve visually smoother? So like the "Smooth curve" function in LMS software described on page 110 of http://www.linearx.com/files/pdf/LMS-4_Manual.pdf ? From an FFT (linear frequency), you need to 1. resample to a log frequency axis 2. apply a zero-phase (to not shift the spectrum left or right) lowpass filter with cutoff "frequency" determined by the sample rate along the octaves axis. – endolith Jul 22 '13 at 16:55
  • 1
    I think this article contains valuable information. However, unfortunately, it is not free. The fundamental approach is also described in this one. – applesoup Feb 23 '16 at 23:54

1 Answers1

9

Typically "smoothing" means "replace the current value with average over the neighboring ones". Most common is energy smoothing, where the smoothing results in the energy average over the smoothing interval and the phase information is lost. Complex smoothing can be done as well but it's tricky business because of phase wrapping.

Energy smoothing can be expressed as $$Y(k)=\sqrt{\frac{1}{N}\cdot \sum_{i=0}^{N-1}X(i)\cdot X^{*}(i)\cdot W_{k}(i)}$$

where $W_{k}(i)$ is some suitable window function. In the case of, say, third-octave smoothing this could be derived as the the magnitude squared of the transfer function of a third octave band pass filter around frequency k. This also means that for a, say, 1024 point FFT you need to design 1024 different bandpass filters, so that's a fair bit of work.

Things can be simplified if the exact shape of the smoothing filter is flexible. Rectangular smoothing can be done as $$Y(k)=\sqrt{\frac{1}{b-a+1}\cdot \sum_{i=a}^{b}X(i)\cdot X^{*}(i)}$$

where $$a = round(k*2^{-\frac{1}{2\cdot n}}), b = round(k*2^{\frac{1}{2\cdot n}})$$

are simply the indices of the band edges for $n^{th}$ octave smoothing.

There are a few more methods that are in between in the arbitrary window and the rectangular one in terms of complexity.

Hilmar
  • 44,604
  • 1
  • 32
  • 63
  • I'm trying to implement this in C code, and I'm afraid I get a little lost in the notation. I'm having a hard time understanding how for example, the summation of i running from a to b works? Any assistance appreciated. – Andrew Smith Dec 16 '13 at 14:39
  • Two thumbs, but alas only one vote, up. This additional question asks how 1/n complex smoothing is done including the tricky business around phase wrapping. – SpeedCoder5 Jun 01 '14 at 18:07