h[0]–h[4]–h[8]–h[9]–h[10]–FIR1n = np.arange(21)2hd = 0.25*np.sinc(0.25*(n-10))3w = np.hamming(21)4h = hd*w0
-100102030-0.100.10.20.3n (sample)valueTAPS OVER nideal hihd (cut)h = hd·wdelay 10 sampleskeep n = 0 .. 20-10010203000.51n (sample)w[n]WINDOW w[n]rectangleHamming0100020003000400000.51f (Hz)gainGAIN |H(f)|idealrect 21Hammingrect 61peak 1.073 at 643 Hz61 taps: peak 1.084peak 1.00401000200030004000-80-60-40-20020f (Hz)dBGAIN IN dBidealrect 21Hamming0 = gain 1 · −20 dB = 0.1worst −19.6 dB−19.6 → −49.8 dB500 Hz −0.31 · 2000 Hz −49.8 dB
Coloured parts: what the current step is about; everything else rests in whiteBlocks: the spec, the ideal response, the window, the tap memory, the FIR chip and a Python code cardPlots: the taps and the window over n, and the gain over frequency, plain and in dBA token carries each tap value along the line; the sinc stems slide as the delay is appliedA 1000 Hz lowpass at 8000 samples a second with 21 taps: the ideal sinc, delayed 10 samples, cut to 21 taps and tapered by a Hamming window. scipy.signal.firwin uses the same window method with the Hamming window by default, then divides by the sum of the taps (1.0040 here), so its taps are about 0.4% smaller than h[n] on the card.

The ideal filter

  1. We sample at 8000 Hz and want a lowpass filter: keep everything below 1000 Hz, remove everything above. The ideal answer is a brick wall: gain 1 up to the cutoff, gain 0 after it.

Cut it short

Window it

Use it

The working

# step 1/11 · ask

fs = 8000 samples per second
highest frequency: fs/2 = 4000 Hz

ask:  gain 1  for   0 .. 1000 Hz  (passband)
      gain 0  for 1000 .. 4000 Hz  (stopband)

cutoff as an angle per sample:
  ωc = 2π·1000 / 8000 = π/4 rad

plots: gain against frequency,
plain (0 .. 1.2) and in decibels (dB)

The sample rate, the 1000 Hz cutoff and the 21 taps are a chosen example; every tap, gain and dB figure is computed from this model with the DTFT sum on a 1 Hz grid, and the Python card was checked with numpy. Gains are plain ratios of output to input amplitude; dB = 20·log10(gain). Oppenheim & Schafer's Table 7.2 lists peak stopband errors of about −21 dB (rectangle) and −53 dB (Hamming); those are for long filters. With only 21 taps this design measures −19.6 dB and −49.8 dB.