h[0]*z^2 + h[1]*z + h[2] H(z) = ------------------------ . z^2 + h[3]*z + h[4]
The output is formed using the following relationship,
y[i] = h[0]*x[i] + h[1]*x[i-1] + h[2]*x[i-2] - h[3]*y[i-1] - h[4]*y[i-2] .
The filtering procedure needs the present and past two input samples and the past two output samples to form a new output sample. These are supplied as extensions to the input and output arrays.
The input array x and the output array y can share storage. Consider an array A with Nout+4 elements. Let the first two elements (A[0] and A[1]) represent past output values. The next two elements (A[2] and A[3]) are past input values. The next Nout elements starting with A[4] are new input values. In this case, this routine can be invoked as
FIbiquad (&A[2], &A[0], Nout, h)On output Nout new output values are placed starting at A[2], overlaying the input values. The last two input values (A[Nout+2] and A[Nout+3]) remain intact. These along with the last two output values (A[Nout] and A[Nout+1]) are suitable for priming the array for processing the next group of samples. This can be achieved by moving the top 4 elements of the array to the bottom of the array and appending Nout new input values.