int QccFilterInitialize(QccFilter *filter);
int QccFilterAlloc(QccFilter *filter);
void QccFilterFree(QccFilter
*filter);
int QccFilterCopy(QccFilter *filter1, const QccFilter *filter2);
int QccFilterReversal(const QccFilter *filter1, QccFilter *filter2);
int QccFilterAlternateSignFlip(QccFilter *filter);
intQccFilterRead(FILE*"infile,
QccFilter *filter);
int QccFilterWrite(FILE *outfile, const QccFilter
*filter);
int QccFilterPrint(const QccFilter *filter);
typedef struct
{
int causality;
int length;
QccVector coefficients;
} QccFilter;
The fields of QccFilter are as follows:
Suppose that length is N. If causality is QCCFILTER_CAUSAL, then the coefficients, h[n], of the length-N causal FIR filter in coefficients are in the order:
h[0] h[1] h[2] ... h[N-1]If causality is QCCFILTER_ANTICAUSAL, then the coefficients, h[n], of the length-N anti-causal FIR filter in coefficients are in the order:
h[N-1] h[N-2] ... h[1] h[0]If causality is QCCFILTER_SYMMETRICWHOLE, then the coefficients, h[n], of the length-(2N-1) whole-sample symmetric FIR filter in coefficients are in the order:
h[0] h[1] h[2] ... h[N-1]That is, only the right half of the filter coefficients are stored for a whole-sample symmetric filter. If causality is QCCFILTER_SYMMETRICHALF, then the coefficients, h[n], of the length-2N half-sample symmetric FIR filter in coefficients are in the order:
h[0] h[1] h[2] ... h[N-1]That is, only the right half of the filter coefficients are stored for a half-sample symmetric filter.
where c is filter->causality, d is filter->length, and the fi are the filter coefficients, filter->coefficients.c
d
f0
f1
.
.
.
casuality: QCCFILTER_CAUSAL
length: 0
coefficients: NULL
QccFilterAlloc() Alloctates storage space for the filters coefficients. filter->length must give a nonzero filter length. The appropriate amount of storage space is allocated by calling QccVectorAlloc(3) , with a pointer to the vector returned as filter->coefficients.
QccFilterFree() frees space previously allocated by QccFilterAlloc().
QccFilterCopy() copies filter2 to filter1. If filter1 has not been allocated prior to calling QccFilterCopy() (as is evidenced by a NULL filter1->coefficients pointer), then QccFilterAlloc() is called to allocate space for filter1 with the same size as filter2. Otherwise (non-NULL filter1->coefficients pointer), it is assumed that sufficient space as already been allocated to filter1.
QccFilterReversal() creates the time reversal of filter2, storing the resulting time-reversed filter in filter1. Sufficient storage space for the coefficients of filter1 must be allocated prior to calling QccFilterReversal(). For example, if filter2 is a length-N causal filter, QccFilterReversal() produces a length-N anti-causal filter, which is returned as filter1.
QccFilterAlternateSignFlip() changes the sign of every other coefficient in filter. For example, if filter is a length-N (N even) casual filter
h[0] h[1] h[2] ... h[N-3] h[N-2] h[n-1],then, after QccFilterAlternateSignFlip() returns, filter is
-h[0] h[1] -h[2] ... h[N-3] -h[N-2] h[N-1].
QccFilterRead() reads the filter structure from the file pointed to by infile which must be already opened for reading via a call to QccFileOpen(3) .
QccFilterWrite() writes the filter structure to the file pointed to by outfile which must be already opened for writing via a call to QccFileOpen(3) .
QccFilterPrint() prints a formated list of the filter coefficients of filter to stdout.