Neil's Digital Filter Page
Why this page?

Tell me about digital filters
Shareware
Dos utilities
DLLs and demos for developers
Other interesting places...
Contact me
Home
Download


Filter
A program to design digital filters

Filter1

1. System Requirements:

    Filter will run on any standard PC running Windows 3.1 or Windows95. To generate the filters and to filter an existing .WAV file, the minimum system requirements are a 386 processor and 4Mbyte of memory. Less than half a megabyte of hard disc space is required.

    If you wish to use the 'listen' facilities then you will also require a Windows compatible sound card. To listen at the highest rate (44.1ks/s, stereo) you'll need a 486DX2 at 66MHz or better. However, this is not required if you simply wish to generate filter coefficients.

    Note: There is a problem with this program and Windows 3.11 - for reasons I haven't investigated (and without encouragement, I'm unlikely to) Filter will occasionally lock up W3.11 if the network is in use.

2. Installation:

    Filter is supplied as an executable file (filter.exe), a Borland DLL file (bwcc.dll) and this document (manual.doc). bwcc.dll should be placed in the \windows or \windows\system directories if you do not already have a copy on your system - if you have, ignore it. The manual.doc file is for reference only and you can also ignore this file. Filter.exe may be placed in the directory of your choice - you'll also need to make a shortcut to it. A later version will include a self install facility!

3. The File Menu:

    (Although the illustrations are taken from a Windows 95 environment, the comments apply equally to Windows 3.1)

    filemenuThe main choices in the filter program are selected from the File menu. Filter Type offers a sub-menu (which can also be quickly accessed using a right mouse click) allowing you to select the type of filter you require. Graphic Equaliser is separated from the rest as it is operated in a slightly different way.

    Low Pass and High Pass options are effectively inverses of each other, and therefore offer similar parameter choices.

    low

    The Scale in dB checkbox controls the way in which the computed frequency response is shown. The default option is to display using a logarithmic (dB) vertical scale: un-checking it lets you see the response in linear form.

    Use window is the other default - it applies a Hamming window to the filter to improve both the in-band ripple response and the out-of-band rejection ratio.

    Number of filter taps allows you to select the number of coefficients used to create the filter. It is always odd, and can be set between three and four hundred and ninety nine. Generally you will want to keep the number of taps as low as possible (while the filter still meets your specification) to increase the speed of the final filter.

    Sample rate is er… the sampling rate! The sampling rate and corner frequencies scale with each other (so the same filter is generated for a 22050 sample rate and 5000 corner frequency, and a 44100 sample rate and 10000 corner frequency) but it is convenient to be able to define the exact frequencies you will be using and not have to bother with the scaling.

    Corner frequency defines the point at which the frequency response drops to -6dB relative to the maximum pass band response. Note that the responses are always scaled to show 0dB as the pass band maximum.

    Band Pass and Band Stop are again logical inverses of each other. The only difference is that instead of a corner frequency, you have instead a centre frequency to mark the centre of the pass (or stop) band, and a Width entry which sets the gap between the -6dB points. As an example, in the examples shown above, the -6DB points are at 5012Hz and 6012Hz.

    The Graphic Equaliser is operated in a slightly different way from the preceding options. All the other options have no user input once the parameters have been set, but this selection requires you to define the frequency response you require. The only parameters you can change at this point are whether or not you use a window, and the number of filter coefficients. The scaling of the display is automatically returned to logarithmic (dB).

    After the 'OK' button is pressed, you are presented with a flat response curve:

    The straight line is the response which the filter will try to track. The black squares are handles which you can use to move the line - left click on a handle and drag to a new position. When the left button is released the filter response is re-calculated. To add another handle, left click on the line. You'll notice that the cursor tracks the frequency and the level as you move. After you've defined a few points you'll see that the program has begun to track the response. The more filter taps you select, the better the tracking will be. You can have a maximum of twenty one handles.

    If you need to remove a handle, right click on the handle and you'll be offered a sub-menu with a choice: either remove the handle on which you've clicked, or remove all the handles and restore to a flat response.

    The other options offered by the File menu are Open Filter and Save Filter. These allow you to save and load named filters. Because this is a sixteen bit application, the normal 8.3 file names apply, rather than the long filenames available in Windows 95.

    There are two files which are saved: one with an '.inc' extension which can be used as a C++ include file (and which is loaded back into the program on an Open Filter), and a simpler binary file which can be used directly as data by a program. This is a sample of the '.inc' file:

      // digital filter parameters
      // filename: DEMO.INC
      // type 4 <user defined>
      // filter taps: 21
      // sampling frequency: 22050
      // Handles: 4 100 0 58 23 96 53 55 100
      #define DEMOTaps 21 static int DEMOCoeffs[21] = {
      0, // 0.00000010
      155, // 0.00475310
      412, // 0.01258510
      487, // 0.01488610
      165, // 0.00506110
      834, // 0.02547110
      2704, // 0.08254810 etc…

    When you include the file, two variables become visible: the defined xxTaps, and a static array xxCoeffs[], where xx is the name of the file (always in capitals). The array contains the 16 bit signed values of the coefficients, with the decimal fractions commented. Note that the commented parts are used by Filter when a file is loaded.

    A second file is also saved, this time with the file type '.fir'. Here, the format is simpler: it is a binary file intended to be read by a program (say as a command line parameter). It consists of sixteen bit integer values, the first one being the number of coefficients and the remainder the coefficients themselves. The integers follow normal Intel format, low byte first.

4. The Apply Menu:

    Three options are available here. If you have a standard Windows compatible soundcard, then you can use the Listen to short sample to check the first five seconds of a '.wav' file, before you filter it. You can also use Filter short sample to listen to the same sample, but filtered - this action is just a check; it does not make any changes to your file.

    Whether you have a soundcard fitted or not, you can still filter a complete file. Be warned: this can take a long time, particularly on a 44.1 ks/s stereo signal, or if you have a filter with a lot of taps. The input '.wav' file must be sixteen bits, but can be both mono or stereo (with the registered version). The input file is not changed as a result of the filtering - a file named 'filtrout.wav' is created which you will need to rename later.