One of the things I do when learning a new language is to pick a program I want and code it up in that language. As part of some future projects I will be working on, I need to design some audio filters, so I dusted off some old information I had, and spent a few hours whipping out some quick and dirty code to design FIR filters using Fourier Series in C#. Even though there are several sites on the web that will allow you to do this, finding source code for it is a bit trickier. A lot of the DSP links that I ran across in my hunt seem to be broken. As a result, I decided to put my code up for anyone to use that may need it.
The new improved version of the program is more interactive. You can readily see the difference the windowing functions have on the filter response. Controls allow you to define the filter type, sample rate and corner frequency or frequencies, the number of taps, and the window type. Everytime you change any of the input controls, a new coeff.txt file is generated. If you want, you can plot the response of the filter just designed with linear or logrithmic scales for amplitude and frequency.
You might be surprised at how the "quality" of the different window functions change with the number of taps. Try designing a simple low pass filter, and switch the amplitude display to Log. Toggle through all the different window functions, and note what is happening at say -40 dB. Then double the number of taps, and try all the window functions again. Double the number of taps one last time, and try all the window functions. You may be surprised at the interaction of number of taps and the window function. Take home message: Always play with both the number of taps and the windowing function to get to the performance you want.
I'd like to give a special thanks to David Bakkom for working with me to find several little bugs in early versions of the applications. The code for coefficient calculation is mostly taken from C. Britton Rorabaugh's Digital Filter Designer's Handbook ISBN 0-07-911166-1. There were a few corrections of my own.
The program is a Visual Studio 2010 C# program. The source for the project is available in the zip file below if you want to take it apart to see how it works, or modify it. There are no restrictions on the use of the source code, so have fun.
Here is a link to the project source code. Project source
If you just want to run the program to generate coefficients, I have a zipped file below that you can download and unzip on your machine. It contains the minimum number of files needed to execute the program. After you have unzipped the folder, and moved it to where ever you want it to live on you machine, just go into the folder and double click setup.exe. This will perform a standard install.
Here is a link to the executable. Executable