Spartan Bandpass
Senior Project for BSEE
Reza Ghassemi
San Jose State University
Abstract
The goal of this project was to create an easy, efficient
and free software to introduce entry-level engineering students to the concept
of the frequency domain. It was
decided to design an efficient digital filtering software to be used for this
educational tool. To this end,
students should be able to use the software to emulate passing an audio-range
signal through mediums with various bandwidth limitations including, but not
limited to, the telephone system.
Introduction
Digital filters have gained respect in the technical
community for their efficiency and for having low amounts of noise and accurate
cut-off frequency characteristics. In
addition, a system implementing a digital filter can easily be reconfigured to
solve a wide array of problems without any hardware changes. Analog filters are
extremely cheap to make, consisting of op-amps and passive components but lack
the advantages that their digital counterparts excel in. As an example
reconfiguring a simple analog filter requires replacing several components,
making it impractical in a changing environment.
However, digital filtering hasn’t been cheap
historically. The programmable
chips used by companies such as Texas Instruments, Motorola, and Analog Devices
are not extremely expensive, but their development environments are.
This makes their use as an educational tool unlikely and costly.
In the software field, filtering programs are made in every shape and
size. In the audio field in
particular, sound editing programs such as Sound Forge, Wavelab, and Cool Edit
are extremely popular but also cost up to $500.
For this reason, this software project was started with the
aim of developing a free software that educators could use without licensing or
permission.
The software had several requirements.
First, it had to run off any PC running Microsoft Windows.
Second, it needed to work with any sound card.
Finally, it needed to be easy to use.
Product Description
The software first records the analog input signal from the
computer’s sound card using a Microsoft Media Control Interface (MCI) command.
The file can now be played back for the user to hear.
It then parses the samples in the resulting wav file and stores them into
an array. A spectrum analysis of
the signal is performed, and the resulting time and frequency domain signals are
displayed to the user. The user
then inputs a low and high cutoff frequency and selects the order of the filter.
The program then generates the resulting filter coefficients and
difference equation. The samples
are then passed through the difference equation.
Another spectrum analysis is performed and the resulting time and
frequency domain signals of the output are displayed.
Finally, the output file is stored in wav format and the user is able to
play back the file and hear the result of the filtering.
The program was designed using the C language.
It’s graphical interface was constructed using the National
Instrument’s LabWindows integrated development enviroment.
The Wav Format
The Wav format is a subset of Microsoft’s RIFF file
format. It is used for digital
audio and supports both uncompressed Pulse Code Modulation (PCM) and compressed
data schemes. It is essentially a
chunk of data with separate smaller chunks of data inside of it that represent
file information and samples. The
Wav file is separated into three main areas: a RIFF header, the format chunk,
and the data chunk. The full file
structure is shown below.
Offset Length Contents
(Riff Header)
0 4 bytes 'RIFF'
4 4 bytes <file length - 8>
8 4 bytes 'WAVE'
(Format Chunk)
12 4 bytes 'fmt '
16 4 bytes 0x00000010 // Length of the fmt data (16 bytes)
20 2 bytes 0x0001 // Format tag: 1 = PCM
22 2 bytes <channels> // Channels: 1 = mono, 2 = stereo
24 4 bytes <sample rate> // Samples per second: e.g., 44100
28 4 bytes <bytes/second> // sample rate * block align
32 2 bytes <block align> // channels * bits/sample / 8
34 2 bytes <bits/sample> // 8 or 16
(Data Chunk)
36 4 bytes 'data'
40 4 bytes <length of the data block>
(Begin Audio Samples)
44 4 bytes <sample data> 48 4 bytes <sample data>
...
Windows MCI Commands
The Windows Media Control Interface is a high-level suite
of Windows commands that let the software talk directly to the media devices in
the computer. The advantage of the
MCI suite is that it communicates with the devices that the operating system
itself has already designated for that specific purpose.
In our case, the sound card has a user-defined default recording input.
This could be either a line input or microphone input.
The MCI command assumes that the default is the device to use, and hence
it eliminates the need for the elaborate code used to access each individual
input device. The MCI controls are
used in this program to record and save the wav files and to stop and start
their playback.
Filter Coefficients and Difference Equations
The coefficients for a digital filter can be found from the
following parameters:
analog cutoff frequency
L = damping factor
sampling frequency

Which gives us the following coefficients:





This allows us to filter the signal using the difference
equation of the form:

While testing our filter, we came across a simple
LabWindows function that completes both the filter coefficient and difference
equation problems in one step. The
Butterworth Bandpass function takes the following parameters and outputs the
filtered samples. Since executing
the difference itself took a large amount of time and provided less than
accurate results, we chose to use the Butterworth Bandpass function to solve the
filter coefficients and execute the difference equation.
Finances
Since the project was aimed at being free, the goal was to
prevent its development from becoming costly.
Thankfully, a group member owned a copy of the development environment.
In addition, all research materials were either borrowed from the library
or found on the internet. Therefore,
the goal of keeping the project
free was achieved.
Competition
Competitors in our market are those who develop
professional audio editing software. Since
there are other features in these programs other than filtering, their costs are
quite high. Below are the costs of
the top three audio editing software:
Cool Edit
$150
Wavelab
$300
Sound Forge
$500
These products are a huge overkill for educators wanting to
explain the concept of filtering to their students.
This projects wins over these products because it provides a single
function to the educators at no cost at all.
Conclusion
The frequency domain is complicated concept for engineering
students to grasp. Educators have a
need to explain this concept to students in an informative and easy way.
The audio range is the frequency range most commonly known to all
students. Because they hear as a
part of everyday life, teaching them the frequency domain in a way that will let
them hear the results is the most effective way of teaching them.
This project sought to solve this problem by providing a free and easy
software for educators to use for explaining the concept of filtering and the
frequency domain to their students and allowing them to simulate passing a
signal through channels such as the telephone system.
The project was a success and was completed on time with no budget.
|