Recursive Digital Filters: A Concise Guide

Software

Below are the C programs that accompany the book, Recursive Digital Filters: A Concise Guide. You can download each as you need it, or all of them in a zip file. For other programs not listed here, see our digital signal processing page.

This software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. If you have questions or comments contact: Stefan (stefan at exstrom dot com) or Richard (richard at exstrom dot com).

• lpf.c
Applies a low pass filter to x[n] read from stdin.
```Usage: lpf s f
s = sampling frequency
f = half power frequency < s/2
```
• hpf.c
Applies a high pass filter to x[n] read from stdin.
```Usage: hpf s f
s = sampling frequency
f = half power frequency < s/2
```
• bpf.c
Applies a band pass filter to x[n] read from stdin.
```Usage: bpf s f b
s = sampling frequency
f = center frequency
b = half power bandwidth
```
• bsf.c
Applies a band stop filter to x[n] read from stdin.
```Usage: bsf s f b
s = sampling frequency
f = stop frequency
b = half power bandwidth
```
• bsfb.c
Applies a band stop filter bank to x[n] read from stdin.
```Usage: bsfb s b f1 f2 ...
s = sampling frequency
b = half power bandwidth
fi = stop frequencies
```
• brownrv.c
Generates n samples of an integrated gaussian random variable.
```Usage: brownrv n m a seed
n = number of samples
m = mean of gaussian
a = standard deviation of gaussian
seed = optional random number seed
```
• sines.c
Produces n samples of the sine waves defined in file.
```Usage: sines file s n
s = sampling frequency
```
• noise.c
```Usage: noise m a seed
m = mean of gaussian
a = standard deviation of gaussian
seed = optional random number seed
```
• fft.c
Calculates the FFT of the first n points read from stdin.
```Usage: fft n
n = number of points read from stdin
```
• extract.c
Extracts information from an fft file read from stdin.
```Usage: extract info
info = m for magnitude
p for phase
r for real part
i for imaginary part
```

Awk scripts

Below are awk scripts that have been converted from the C programs above. They are also included in the zip file with the C programs. These awk scripts are executable like a shell script. They should run as is on any Unix related operating system (Linux, BSD, OSX), with the exception of having to possibly change the path of the awk executable on the first line. You need to make the script executable with a command like this:
chmod u+x file.awk
In Windoze, you can just delete the first line of the file (starts with #!), then run it as a regular non-executable awk file like this:
awk -f file.awk ...

• lpf.awk
Implements lpf.c as an awk script, i.e. it applies a low pass filter to x[n] read from stdin.
```Example: brownrv 1000 0 0.5 13 | lpf.awk -v s=1000 -v f=10
where s = sampling frequency, f = half power frequency < s/2
This produces the same output as running lpf.c like so:
brownrv 1000 0 0.5 13 | lpf 1000 10
```
• hpf.awk
Implements hpf.c as an awk script, i.e. it applies a high pass filter to x[n] read from stdin.
```Example: brownrv 1000 0 0.5 13 | hpf.awk -v s=1000 -v f=20
where s = sampling frequency, f = half power frequency < s/2
This produces the same output as running hpf.c like so:
brownrv 1000 0 0.5 13 | hpf 1000 20
```
• bpf.awk
Implements bpf.c as an awk script, i.e. it applies a band pass filter to x[n] read from stdin.
```Example: brownrv 1000 0 0.5 13 | bpf.awk -v s=1000 -v f=20 -v b=10
where s = sampling frequency, f = center frequency, b = half power bandwidth
This produces the same output as running bpf.c like so:
brownrv 1000 0 0.5 13 | bpf 1000 20 10
```
• bsf.awk
Implements bsf.c as an awk script, i.e. it applies a band stop filter to x[n] read from stdin.
```Example: brownrv 1000 0 0.5 13 | bsf.awk -v s=1000 -v f=20 -v b=10
where s = sampling frequency, f = stop frequency, b = half power bandwidth
This produces the same output as running bsf.c like so:
brownrv 1000 0 0.5 13 | bsf 1000 20 10
```

Send comments to: Richard Hollos (richard[AT]exstrom DOT com)
Copyright 2019 by Exstrom Laboratories LLC