h*z^2 + h*z + h H(z) = ------------------------ . z^2 + h*z + h
The output is formed using the following relationship,
y[i] = h*x[i] + h*x[i-1] + h*x[i-2] - h*y[i-1] - h*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 and A) represent past output values. The next two elements (A and A) are past input values. The next Nout elements starting with A are new input values. In this case, this routine can be invoked as
FIbiquad (&A, &A, Nout, h)On output Nout new output values are placed starting at A, 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.