1.4.2.10 DSP_FilterFIRInterp32 Function
Performs an interpolating FIR filter on the input array.
Description
void DSP_FilterFIRInterp32(int32_t *outdata, int32_t *indata, int32_t *coeffs, int32_t *delayline, int N, int K, int scale, int rate);
Perform an interpolating FIR filter on the first N samples of indata, and stores the result in outdata. The number of output elements is N*rate. The number of filter taps, K, must be an even multiple of N. The coefficients array, Coeffs, must be K elements long. The delay line array, delayline, must be K/R elements long, and be initialized to zero. All data elements must be in Q31 fractional data format. Scaling is performed via binary shift on the input equivalent to (1/2^shift). The function will saturate the output if it exceeds maximum or minimum values. The function creates R output values for each input value processed. The delayline of previous values is processed with R elements of the coefficient array. Numerically:
Y(1,0) = X(0)*C(0) + X(-1)*C(rate) + X(-2)C(2rate) ... Y(1,1) = X(0)*C(1) + X(-1)*C(rate+1) + X(-2)C(2rate + 1) ... Y(1,rate) = X(0)*C(N) + X(-1)*C(rate+N) + X(-2)C(2rate + N) ...
where output Y corresponds to (input,rate) different outputs, input X has (M/rate) sample delays and C is the coefficient array.
Preconditions
The pointers outdata and indata must be aligned on 4-byte boundaries. delayline must have (K/R) elements, and be initialized to zero. K (taps) must be an even multiple of R (rate). outdata must have R*N elements.
Parameters
outdata pointer to output array of elements (int32_t)
indata pointer to input array of elements (int32_t)
coeffs pointer to an array of coefficients (int32_t)
delayline pointer to an array of delay variables (int32_t)
N number of output elements to be processed (int)
K number of filter taps and coeffs (int)
scale binary scaler divisor (1 / 2^scale) (int)
rate decimation ratio (int)
Returns
None.
Remarks
The function processes each input (rate) times. With each pass, coefficients are offset so that (K/rate) multiply accumulate cycles occur.
Example
_// interpret evenly 1/3 spaced values_ #define N 4 _// number of output samples_ #define TAPS 6 #define INTERP 3 int ifiltN = N; int ifiltK = TAPS; _// k must be an even multiple of R_ int ifiltR = INTERP; int32_t ifiltOut[N*INTERP]={0}; int32_t ifiltDelay[2]={0}; _// must be initialized to zero_ int ifiltScale = 0; _// no scaling_ int32_t ifiltCoefsThirds[TAPS]={0x2AAAAAA9, 0x55555555,0x7FFFFFFE, 0x55555555,0x2AAAAAA9,0x00000000}; _// 0.333333, 0.6666667, 0.99999999, 0.6666667, 0.33333333, 0_ int32_t ifiltInput[N]={0x0CCCCCCD, 0x19999999, 0x26666666, 0x33333333}; _// 0.1, 0.2, 0.3, 0.4_ DSP_FilterFIRInterp32(ifiltOut, ifiltInput, ifiltCoefsThirds, ifiltDelay, ifiltN, ifiltK, ifiltScale, ifiltR); _// ifiltOut = {0x04444444, 0x08888889, 0x0CCCCCCD, 0x11111111, 0x15555555, 0x19999999,_ _// 0x1DDDDDDD, 0x22222221, 0x26666665, 0x2AAAAAAA,0x2EEEEEEE, 0x33333332}_ _// = 0.0333, 0.0667, 0.1, 0.1333, 0.1667, 0.2, 0.2333, 0.2667, 0.3, 0.3333, 0.3667, 0.4_
C
void DSP_FilterFIRInterp32 (int32_t * outdata , int32_t * indata , int32_t * coeffs , int32_t * delayline , int N , int K , int scale , int rate );