Design of a Anti-aliasing Filter

Consider the design of an anti-aliasing filter for filtering prior to
converting between a sampling rate of 48 kHz and a sampling rate of 8 kHz.
Such a filter could for instance be used in downsampling the output of a
Digital Audio Tape (DAT) recorder.  In such an application, the input signal is
sampled with a resolution of 16 bits resulting in a sine-wave Signal-to-Noise
ratio of nearly 100 dB.

Ideally the anti-aliasing filter should be a brick wall filter cutting off at
4 kHz.  A practical filter requires a finite width transition band.  The
stopband should start at 4 kHz to avoid aliasing.  This means the passband
edge must be below 4 kHz, inevitably removing some of the "high" frequencies
in the 8 kHz signal.  Consider using a filter with cutoff at 3450 Hz.  We will
use 255 coefficients.

The first attempt uses a weight of one in the passband and a weight of ten in
the stopband.

DFiltFIR -n 255 -s 48000 Ex1-1.cof << EoF
0     1  1
3450  1  1

4000  0  10
24000 0  10
EoF
Linear Phase FIR Filter
           Freq.      Value    Weight           Limits      Deviation  Dev dB
Band  1:  0.0000          1         1      ----       ----     0.0059    0.05
          0.0719          1         1      ----       ----     0.0059    0.05
Band  2:  0.0833          0        10      ----       ----    0.00059  -64.54
          0.5000          0        10      ----       ----    0.00059  -64.54

This filter is a good start, with 0.05 dB passband ripple and a minimum 64 dB
stopband attenuation.

We can improve on this design by applying a weighting which changes across a
band.  Basically, the critical region is near the passband and stopband edges.
We can increase the attenuation far from the stopband edge with only a small
effect on the attenuation at the stopband edge.  Here we will specify
increased attenuation at frequencies above 6 kHz.  We would like to push this
attenuation down to near 90 dB.  This means a 30 dB increase or about a 30-fold
increase in weight.
DFiltFIR -n 255 -s 48000 Ex1-2.cof << EoF
0     1  1
3450  1  1

4000  0  10
6000  0  100
24000 0  300
EoF
Linear Phase FIR Filter
           Freq.      Value    Weight           Limits      Deviation  Dev dB
Band  1:  0.0000          1         1      ----       ----      0.009    0.08
          0.0719          1         1      ----       ----      0.009    0.08
Band  2:  0.0833          0        10      ----       ----     0.0009  -60.88
          0.1250          0     1e+02      ----       ----      9e-05  -80.88
          0.5000          0     3e+02      ----       ----      3e-05  -90.42

We have pushed the extra attenuation quite close to the band edge and have
paid a penalty - the passband ripple is now 0.08 dB.

Such a filter might benefit from a dc constraint.  The dc response can be
constrained to be unity, so that constant values in the input are preserved at
the output of the filter.  In addition, we can taper the attenuation in the
passband so that the low frequencies suffer less from the passband ripple than
higher frequencies.  We require the ripple near zero to be 1/5 of the ripple at
the passband edge.  Further, we constrain the dc response to be zero.

DFiltFIR -n 255 -s 48000 Ex1-3.cof << EoF
0     1  5    1   1
3450  1  1   -1e6 1e6

4000  0  10
6000  0  100
24000 0  300
EoF
Linear Phase FIR Filter
           Freq.      Value    Weight           Limits      Deviation  Dev dB
Band  1:  0.0000          1         5          1          1         0    ****
          0.0719          1         1     -1e+06      1e+06      0.01    0.09
Band  2:  0.0833          0        10      ----       ----      0.001  -60.00
          0.1250          0     1e+02      ----       ----     0.0001  -80.00
          0.5000          0     3e+02      ----       ----    3.3e-05  -89.54

The ripple at the passband edge has deteriorated slightly, but the ripple in
most of the passband has decreased significantly.

To increase the passband size, we will have to also increase the number of
coefficients.  Consider setting the passband edge to 3700 and increasing the
number of coefficients to 511.  After a number of iterations on the weights,
the following design seems to be a reasonable compromise.
DFiltFIR -n 511 -s 48000 Ex1-4.cof << EoF
0     1  15   1     1
3000  1  5    -1e6  1e6 
3700  1  1    -1e6  1e6

4000  0  1.5
6000  0  20
24000 0  100
EoF
Linear Phase FIR Filter
           Freq.      Value    Weight           Limits      Deviation  Dev dB
Band  1:  0.0000          1        15          1          1         0    ****
          0.0625          1         5     -1e+06      1e+06   0.00054    0.00
          0.0771          1         1     -1e+06      1e+06    0.0027    0.02
Band  2:  0.0833          0       1.5      ----       ----     0.0018  -54.89
          0.1250          0        20      ----       ----    0.00014  -77.39
          0.5000          0     1e+02      ----       ----    2.7e-05  -91.37

$Id: Example1,v 1.2 1996/04/08 FilterDesign-V1R7a $
