Live data from Hacker News

Why is it a bad idea to filter by zeroing out FFT bins? (2020)

dsp.stackexchange.com

31–40 of 43 posts

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#31
post #21
post #16

This is indeed an excellent way of filtering if your audio is cyclic and fits into a single FFT, like a periodic waveform, a drum loop or an Optigan track. Just make sure not to apply any window.

You also need to make sure that the gibbs phenomena does not cause the filtered signal to leave the range of the representation. So a prefiltered signal is less than 1, but the post filtered signal wont be. Meaning if 1 is the cap for your audio output, then enjoy a brand new category of distortion. But its a terrible way in general ofc, just optimize an appropriate, zero phase filter with an unaffected passband and…

This is the case for any sharp filter. It is not unique to the FFT approach. It doesn't matter if you use a linear phase FIR; any time you "remove" frequencies you can increase your peak levels. Try graphing sin(x) + 0.2sin(3x) and then try removing/filtering out the 3x component.

It's even true for reconstruction. A digital waveform can represent peak levels far above "digital peak", in between samples.

This is why if you're mastering songs, you'd better keep your peak levels at -0.5dB or -1dB so (so the filtering from lossy compression won't make it clip), and why you'd better use an oversampling limiter. Especially if you're doing loudness war style brutal limiting, because that's the stuff that really creates inter sample peaks. But you shouldn't be doing that, because Spotify and YouTube will just turn your song down to -14 LUFS anyway and all you'll have accomplished is making it sound shitty :-)

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#32

A much less well known fact about the FFT (or the DFT) is that it is also exhibits a brickwall (rectangular) response. This can manifest itself when using zero padding in the frequency domain for upsampling, but is also the reason for artifacts when FFTing a nonperiodic window. It's used in OFDM, where the subchannels are generated by an FFT and have a sinc shape (the Impulse response of the FFT) in the frequency dom…

Thanks for mentioning this, because after reading the answer my first thought was "wait, but what if I do nothing before doing IFFT which is also equivalent to multiplying by a rectangle (but that nonzero from -nyquist to nyquist)"

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#35

Why use an FFT at all? Yes it's easy but you'll almost always get a better result with a lot less computation by building an actual digital filter.

Some standards define a frequency response of the whole measurement chain, including things like the frequency response of your sensor and anti aliasing filter. An FFT is the easiest way to deal with that.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#36
post #21
post #16

This is indeed an excellent way of filtering if your audio is cyclic and fits into a single FFT, like a periodic waveform, a drum loop or an Optigan track. Just make sure not to apply any window.

You also need to make sure that the gibbs phenomena does not cause the filtered signal to leave the range of the representation. So a prefiltered signal is less than 1, but the post filtered signal wont be. Meaning if 1 is the cap for your audio output, then enjoy a brand new category of distortion. But its a terrible way in general ofc, just optimize an appropriate, zero phase filter with an unaffected passband and…

I'd assumed fft was just a dft with O(n log(n)) performance - am I missing something?

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#37
post #10
post #6

This would be a really good interview question!

I think it's a terrible interview question, unless maybe you're hiring an electrical engineer. It's not something you can expect someone to reason through from the basics, and it's not something I'd expect someone to know unless they've worked on problems involving the technique.

It's blindingly obvious that you would only ask this to someone who should know it.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#38
post #10
post #6

This would be a really good interview question!

I think it's a terrible interview question, unless maybe you're hiring an electrical engineer. It's not something you can expect someone to reason through from the basics, and it's not something I'd expect someone to know unless they've worked on problems involving the technique.

Seems like a pretty reasonable question for a job involving signal processing where the candidate has experience. Certainly that could be electrical engineers. In that context putting a signal into the frequency domain seems pretty basic actually. Knowing the caveats of sharp edged filters in that situation doesn't seem like outrageously obscure knowledge.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#39
post #36
post #21

Earlier quoted context omitted.

You also need to make sure that the gibbs phenomena does not cause the filtered signal to leave the range of the representation. So a prefiltered signal is less than 1, but the post filtered signal wont be. Meaning if 1 is the cap for your audio output, then enjoy a brand new category of distortion. But its a terrible way in general ofc, just optimize an appropriate, zero phase filter with an unaffected passband and…

I'd assumed fft was just a dft with O(n log(n)) performance - am I missing something?

You're not. The FFT is just a particular way of implementing the DFT.

Re: Why is it a bad idea to filter by zeroing out FFT bins? (2020)

#40
post #39
post #36

Earlier quoted context omitted.

I'd assumed fft was just a dft with O(n log(n)) performance - am I missing something?

You're not. The FFT is just a particular way of implementing the DFT.

Quite. So I'm puzzled by what mistake the 'skilled programmers' are making, when confusing DFT and FFT. Implementing DFT in quadratic time?
Post reply on HN