Skip to content

An implementation of a biquad filter that suppresses high frequencies while preserving low frequencies using Unix pipes to chain programs together.

Notifications You must be signed in to change notification settings

eric-li18/Biquad-Filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Biquad Filter

Course: CSCB09: Software Tools and Systems Programming Summer 2019

Professor: Albert Lai

Assignment: 3

An implementation of a biquad filter that suppresses high frequencies while preserving low frequencies using Unix pipes to chain program instances together.

Graph

Plotted with gnuplot showing the frequencies of the "ugly.wav" file pre-filtering (ugly.txt), and the resulting suppression of high frequencies as "out.wav" (out.txt).

Files

Work supplied by, and credited to Professor Albert Lai:

  • towav.c
    • converts WAV files to readable input for the program
  • unwav.c
    • converts output of program to a WAV file
  • ugly.wav
    • starting frequency to work with
  • All shell commands and pipelines

Personal Work

  • biquad.c
    • an implementation of the difference equation given by :

      Difference Equation

  • cascade.c
    • utilizes biquad.c to create multiple pipelines of biquad.c for use in filtering
  • run.sh
    • a file created from provided commands for ease of compiling

Compilation

To run the files, I have created a small shell script to ease the compiling process.

Options

-b runs the biquad pipeline

-c runs the cascade file

-g graphs the plot above (requires gnuplot installation)

E.g.

$ ./run.sh -b

Notes about the file compilation and compiling separately with different arguments is provided below, this script is only for working with the ugly.wav file we are provided here.

About Compilation

Requires a C compiler and *nix Environment before you can play around with arguments

Listen to ugly.wav

Compilation with GCC compiler:

$ gcc biquad.c -o biquad
$ gcc cascade.c -o cascade
$ gcc towav.c -o towav
$ gcc unwav.c -o unwav

Piping biquad instances:

$ ./unwav < ugly.wav | ./biquad 1 0 1 -0.7 0 | ./biquad 1 1.18 1 -1.58 0.81 | ./biquad 4.42e-3 1 0 0 0 | ./towav > out.wav

Then listen to out.wav and see if you can spot the frequency difference!

Alternatively, we can use cascade.c to implement the pipeline instead which will create the same result:

$ ./unwav < ugly.wav | ./cascade 1 0 1 -0.7 0 1 1.18 1 -1.58 0.81 4.42e-3 1 0 0 0 | ./towav > out.wav

The plot in the first section was generated by:

$ ./unwav < ugly.wav | head -300 > ugly.txt
$ ./unwav < out.wav | head -300 > out.txt
$ 
$ gnuplot
$ plot 'ugly.txt' with lines, 'out.txt' with lines

About

An implementation of a biquad filter that suppresses high frequencies while preserving low frequencies using Unix pipes to chain programs together.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published