cSounds.com - Professor R. Erik Spjut's FIR Filters - erik_spjut@hmc.edu

FIR Filter Files

Below are sets of FIR (Finite Impulse Response or All-Zero) filter files. They are all in either AIFF or AIFF-C format. But Csound reads them all perfectly regardless of platform. These files were not meant to be listened to, but are to be used with cvanal and convolve as brick wall (very steep cutoff) filters. They are useful for such things as removing DC offsets from soundfiles and removing high frequencies prior to downsampling (changing a file to a lower sample rate).

The filters are available with two transition widths: narrow, which drops from -3 dB at the cutoff frequency, Fc, to -96 dB at either 0.9 Fc (Highpass) or 1.1 Fc (Lowpass), or wide, which drops from -3 dB at the cutoff frequency, Fc, to -96 dB at either 0.8 Fc (Highpass) or 1.2 Fc (Lowpass). For example, a narrow lowpass filter with a cutoff at 10 kHz is 0 dB at 9 kHz, -3 dB at 10 kHz, and -96 dB at 11 kHz and above. The wide one would be -96 dB at 12 kHz and above. A narrow 20 Hz highpass filter would be 0 dB at 22 Hz, -3 dB at 20 Hz and -96 dB at 18 Hz and below.

The filters all have linear phase, which means that they will not distort waveforms, or cause ringing. They simply remove the unwanted frequencies. The phase delay is equal to 1/2 of the soundfile length.

The filter names are descriptive, i.e., hp-44-5000-w.aifc is a HighPass, sr=44100 Hz, Fc=5000 Hz, Wide-transition, 32-bit AIFF-C file. and lp-96-200-n.aif is a LowPass, sr=96000 Hz, Fc=200 Hz, Narrow-transition, 16-bit AIFF file.

The files are available as either 32-bit floating-point AIFF-C files or 16-bit AIFF files. One would normally use the 32-bit floating-point AIFF-C files. The AIFF-C files have a passband gain of 1.00 (they won't change the amplitude of signals in the passband) when used with cvanal and convolve (Except for Mac perf's other than perf 4.05.2). And they're guaranteed to meet the frequency specifications. The 16-bit AIFF files were included by request, but I don't recommend their use. The 16-bit files have undetermined gains (you'll have to experiment) and especially the highpass filters have poorer (sometimes much poorer) frequency responses.

The filters are available for sr=44100 Hz, sr=48000 Hz, and sr=96000 Hz.

The lowpass filter cutoff frequencies are:
  • 100 Hz
  • 200 Hz
  • 500 Hz
  • 1000 Hz
  • 2000 Hz
  • 5000 Hz
  • 10000 Hz
  • 16000 Hz (Coming Soon)
  • 20000 Hz (48 kHz (N) & 96 kHz only)

The highpass filter cutoff frequencies are:
  • 10 Hz
  • 20 Hz
  • 25 Hz
  • 50 Hz
  • 100 Hz
  • 200 Hz
  • 500 Hz
  • 1000 Hz
  • 2000 Hz
  • 5000 Hz

You can use the filters at sampling rates other than the displayed one. To calculate the cutoff frequency at the new sampling rate, multiply the given cutoff frequency by the new sampling rate and divide by the old sampling rate. A little calculation will show that there is quite a bit of duplication between the 48 kHz and the 96 kHz filters.

Use of cvanal and convolve is explained quite well in the Csound manual. A brief summary of the steps is:
  1. Analyze the file with cvanal:

    Csound -Ucvanal hp-44-25-n.aifc hp-44-25-n.cv

  2. Calculate the delay (in the Csound manual) and add 1/2 of the file length.

  3. Process the desired sound with the convolve opcode in a Csound orchestra:

    aproc convolve ain,"hp-44-25-n.cv"

For those who care about the technical details, the filters were created with the windowed FIR filter method described in Chapter 20 of The Csound Book. The steps are as follows:
  1. The ideal filter response was determined.

  2. A filter length was chosen.

  3. The IFFT of the ideal filter was taken.

  4. A window (usually Blackman) was applied.

  5. The actual frequency response of the windowed filter was calculated.

  6. If the actual response was not good enough, a new filter length was chosen (by a sophisticate search algorithm) and the process was repeated until the desired response was obtained.
I examined both the Parks-McLellan algorithm and using Kaiser windows, for generating the filters but the Blackman usually worked best. The algorithms for searching for the best filters and writing the AIFF and AIFF-C files were coded as LabVIEW Virutal Insturments (VI's). For most of the filters the search went very quickly, but for some of the long highpass filters (10 Hz, 20 Hz, & 25 Hz) the search took as long as three hours.

Prof. R. Erik Spjut (spyoot rhymes with cute)
Engineering Department, Harvey Mudd College, Claremont, CA 91711
erik_spjut@hmc.edu - Phone (909) 607-3890 - Fax (909) 621-8967

The Filters!

[+] Click here to download the floating point lowpass set [lp_float.zip 791k]

[+] Click here to download the floating point hipass set [hp_float.zip 7.6M]

[+] Click here to download the integer lowpass set [lp_int.zip 255k]

[+] Click here to download the integer hipass set [hp_int.zip 77k]