Function

vDSP_biquadm_CreateSetup

Builds a data structure that contains precalculated single-precision data for use by multichannel cascaded biquad IIR filter functions.

Declaration

vDSP_biquadm_Setup vDSP_biquadm_CreateSetup(const double *__coeffs, vDSP_Length __M, vDSP_Length __N);

Parameters

__coeffs

Array of double-precision real coefficients. Its length should be 5 times the number of sections in the biquad filter.

__M

The number of sections in the biquad filter. The same number of sections is used for each channel, so only one value is specified.

__N

The number of input/output channels.

Return Value

Pointer to an allocated and initialized struct of type vDSP_biquadm_SetupStruct.

Discussion

This function constructs and returns a biquad IIR filter object from the coefficients specified by the array pointed to by coeffs. It initializes the internal state of the setup object such that all delay elements used are set to zero.

This array of coefficients is laid out by channel, followed by section. Each set of 5 coefficients specific to a given channel and section is specified with the 3 feedforward coefficients first, followed by the 2 feedback coefficients.

For example, the array could be constructed as follows (b0, b1, b2 are the feedforward coefficients and a1 and a2 are the feedback coefficients such that the difference equation relating the input x[n] to the output y[n] could be expressed as y[n] = b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2] as shown in the pseudocode below:

for (vDSP_Length i = 0; i < sections; i++)
  for (vDSP_Length j = 0; j < channels; j++)
    A[i*channels*5 + j*5 + 0] = (double)b0_for_section_i_and_channel_j;
    A[i*channels*5 + j*5 + 1] = (double)b1_for_section_i_and_channel_j;
    A[i*channels*5 + j*5 + 2] = (double)b2_for_section_i_and_channel_j;
    A[i*channels*5 + j*5 + 3] = (double)a1_for_section_i_and_channel_j;
    A[i*channels*5 + j*5 + 4] = (double)a2_for_section_i_and_channel_j;

This function allocates memory for its own use; the allocated memory can be freed by the vDSP_biquadm_DestroySetup function.