FILT(3SP)

NAME
Filt, FiltByName, FiltCoefficents - FIR digital filters

SYNOPSIS

#include <speech.h>

int Filt (float *filter, int numfilt, short *adc,
          int numadc, short **adcfilt)

int FiltByName (char *filtername, short *adc, int numadc, short **adcfilt)

int FiltCoefficents (char *filtername, float **coeff, int *numcoeff)

DESCRIPTION

Filt() applies the FIR filter filter to adc and places the result in adcfilt. If the filtering succeeds, Filt() returns a positive number.

filter is a pointer to an array of coefficents for the FIR filter. numfilt is the number of coefficents in filter.

adc is a pointer to an array of data points for the waveform. numadc is the number of points in adc.

adcfilt is a pointer to a pointer where the address of newly created filtered waveform will be placed. The space for the filtered waveform is allocated by Filt() and can be freed using free(3).

FiltByName() applies a named filter to adc. FiltByName() uses Filt() to do the filtering.

FiltCoefficents returns the coefficents of the named filter.

coeff is a pointer to a pointer where the address of the array for the coefficents will be placed. numcoeff is a pointer to an int were the number of coefficents is stored.

SUPPLIED fILTERS

A number of filters are supplied with Filt() . These filters can easly be used with FiltByName(). The table below contains the list of supplied filters. The passband values are in normalized frequencies. The 16 KHz and 8 KHz columns are examples of which frequencies are passed through for a given sample rate.
Filters |
Name | Passband | 16KHz | 8KHz
 | Low | Hight | Low | High | Low | High
0-075 | 0.0 | 0.075 | 0 | 1200 | 0 | 600
0-15625 | 0.0 | 0.15625 | 0 | 2500 | 0 | 1250
0-04375 | 0.0 | 0.04375 | 0 | 700 | 0 | 350
0625-125 | 0.0625 | 0.125 | 1000 | 2000 | 500 | 1000
0625-21875 | 0.0625 | 0.21875 | 1000 | 3500 | 500 | 1750
075-5 | 0.075 | 0.5 | 1200 | 8000 | 600 | 4000
125-21875 | 0.125 | 0.21875 | 2000 | 3500 | 1000 | 1750
0125-05 | 0.0125 | 0.05 | 200 | 800 | 100 | 400
15625-28125 | 0.15625 | 0.28125 | 2500 | 4500 | 1250 | 2250
15625-5 | 0.15625 | 0.5 | 2500 | 8000 | 1250 | 4000
015625-21875 | 0.015625 | 0.21875 | 250 | 3500 | 125 | 1750
21875-5 | 0.21875 | 0.5 | 3500 | 8000 | 1750 | 4000
3125-5 | 0.3125 | 0.5 | 5000 | 8000 | 2500 | 4000
0-25 | 0.0 | 0.25 | 0 | 4000 | 0 | 2000
01875-2 | 0.01875 | 0.2 | 300 | 3200 | 150 | 1600

EXAMPLES

Filter adc[] with filter "0625-125" using FiltByName:

    float adc[100];
    float *filt_adc;
    FiltByName( "0625-125", adc, 100, &filt_adc );

Filter adc[] using Filt and built-in filter "0-25":

    float adc[100];
    float *filt_adc;
    float *coeff;
    int numcoeff;
    FiltCoefficents( "0-25", &coeff, &numcoeff );
    Filt( coeff, numcoeff, adc, 100, &filt_adc );

RETURN VALUES

Filt(), FiltByName(), and FiltCoefficents() return a positive number on success, otherwise a negative number is returned and ErrorString is set.

unknown filter
    The named filter is not known.

malloc failed
    The space for the filter waveform could not be allocated.

SEE ALSO
ErrorString(3SP), malloc(3), free(3)

BUGS