# How do Anti-Aliasing Filters filter the signal?

I have programmed a anti-aliasing filter that uses the fourier-transformation and makes a perfect cutoff on my desired cutoff frequency for downsampling without aliasing. I have read about other types of filters for anti-aliasing. Here i have a nice picture of different filters from this site:

The dotted line seems for me the perfect or ideal filter, but in practical it is not possible to filter a signal perfectly right? And therefore we can use different filters with different orders. Does this graph mean, the different filters do not filter completely on the perfect cutoff frequency and always contains a little aliasing?

The programmed FFT-Filter is used as followed in python:

    def lowpass(x, binmax):
N = len(x)
return np.fft.irfft(np.fft.rfft(x, axis=0)[:binmax], N, axis=0)

x48hr is a Signal sampled with 48kHz and do a cutoff at 4kHz
lr_signal = lowpass(x48hr, binmax=len(x48hr)*4//48) #hr


I use this filter for generating low-resolution samples to train an convolutional neuronal network to learn the mapping between lr and hr to make a hr signal reconstruction.

In general I am actually trying to understand how much aliasing my measurements have and how I can use my measurements to study different types of filters and the aliasing in them. I want to increase the resolution of my signal, therefore I need aliasing in my low-resolution signals. I have asked another question regarding my problem here if you want to know more about it.

• For a bit of discussion on how many taps a typical low-pass filter design approach (equiripple, to be specific) needs: How many taps does an FIR filter need?. Mar 29, 2020 at 17:47
• Problem with the y-axis label, "Amplitude (dB)": First, it's not "dB"—this is not a chart of 0-1 dB. Also, "Magnitude" would be more correct. Mar 29, 2020 at 17:52
• yeah, the fact that there's a "-3dB" point at ca 0.8 dB according to the y-axis does make this plot a bit queeeestionable (i.e. wrong, w.r.t. that). But, that was probably just a remnant of how this (otherwise actually pretty nice) graph was generated. Mar 29, 2020 at 17:53
• The idea of dB is good, though, here—it supports the idea that the important thing would be not that aliasing may be present, but how far down it is. Mar 29, 2020 at 18:01
• When you say, "I have programmed a anti-aliasing filter that uses the fourier-transformation and makes a perfect cutoff", that sounds like you might be saying you set upper "bins" to zero. If so, the problem is that they aren't really bins, such action wouldn't make everything between them zero. And could you clarify exactly where and how you are using this filter? The chart and article is really about an analog antialiasing filter ahead of ADC, you are asking about digital, clearly somewhere else. Are you doing sample rate conversion? Mar 29, 2020 at 18:10

Yes that is correct. The width of the transition band is inversely proportional to the length (or memory) of the filter which means to say that you would need an infinite amount of time to achieve your perfect filter. Therefore for practical reasons you decide how much aliasing would be tolerable (similar in many ways to deciding how many decimal places you need to include for a number describing the length of something) and then design your filter accordingly. The tighter the rejection the longer will be the filter delay and higher will be the overall complexity.

Sound absorption is an example of filtering. You can build an enclosure (room) to lessen sound coming from your clothes washer. Adding insulation inside the wall helps further, as does offsetting studs on each side to minimize vibration transfer. This comes at a cost, but at some point you’ve made the problem unnoticeable—you don’t need 100% eradication.

With typical digital audio, the floor is the 24th bit (sometimes the 16th), and also practical hearing levels, so while we can't achieve perfection, we can achieve the practical equivalent. Another factor on our side is that there is never aliasing when there is no signal. So, there are times where we can accept even less attenuation of aliasing because it’s so hard to hear against the signal.

The reference filters shown in the question are for an analog anti-aliasing filter used in analog to digital conversion. In the digital domain, for instance with sample rate conversion, there are reasons we might prefer linear phase filtering, though it’s not mandatory. Digital versions of the filters shown would not have linear phase. We could also use a combination of filter in stages that give linear phase throughput, even though individual stages may not have linear phase throughout their ranges.

A windowed sinc filter is a popular choice, since it’s easy to calculated coefficients, easy to implement with reasonable performance, has linear phase, and a perfectly flat pass band. If it gives you the performance you're after, you can probably stop there. If you need a given level of performance with less computational cost, there are many things you can do, such as multistage (multirate) conversions, with optimized filter per stage, including stages that might individual allow some more significant aliasing (half band filters, for instance).

It's like building the wall—it's all a matter of tradeoffs, but at the same time some individual materials choices are better than others.

• hay, is that you, Nigel?  welcome. Mar 30, 2020 at 4:52
• That's me Robert—just trying to keep the brain exercised. (The body's not getting as much as usual during the lockdown.) Cheers! Mar 30, 2020 at 17:33
• you need to have a canoe, a backwater, and a 200 acre natural waterpark in your back yard. Mar 30, 2020 at 18:02
• OK, it made sense to change to using my name (had to comment so your first comment doesn't look funny going forward ;-) Apr 8, 2020 at 7:06
• i didn't wanna make you do that, Nigel. i hope you didn't do that just because of me. a lotta people here have pseudonyms, but i just ain't one of them. there are some other carry-overs from comp.dsp here, like our admin, @PeterK . Apr 8, 2020 at 16:33