This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSPF_sp_biquad Usage, Example

Hi team,

Do we have any code examples on how to use the DSPF_sp_biquad function? Is there anything other API call that we need to fun before attempting to use this function?

Thank you,

Akash Patel

  • Akash,

    Go to 

    <dsplib_install_dir>\dsplib_c66x_<version>\packages\ti\dsplib\src\DSPF_sp_biquad\c66\DSPF_sp_biquad_d.c

    and you will find the usage of API. In general, DSPLib has *_d.c files and these mean "demonstration" for the related DSP lib kernel.

    Best Regards,
    Naoki

  • Hi ,

    Thanks for pointing me that file. It looks like that file has the delay coefficients set to 0. Do you know why this is the case?

    Do you know how to determine the delay coefficients?

    The Wiki (http://processors.wiki.ti.com/index.php/C674x_DSPLIB#DSPF_sp_biquad_.28Biquad_Filter.29) appears to mention this as delay[0] = b_1 x[n-1] + b_2 x[i-2] - a_1 y[i-1] - a_2 y[i-2] and delay[1] = b_2 x[i-1] - a_2 y[i-1] but I can't seem to figure out what that means. What are i and n?

    Regards,

    Akash Patel

  • Akash,

    I believe that is typo or something restriction for legacy iir implementation.

    Please see your doxygen API reference:

    C:\ti\dsplib_c66x_3_4_0_0\docs\doxygen\html\dsplib_html\group___d_s_p_f__sp__biquad.html

    Parameters:
    x Pointer to input samples
    b Pointer to Nr coefs b0, b1, b2
    a Pointer to Dr coefs a1, a2
    delay Pointer to filter delays
    y Pointer to output samples
    nx Number of input/output samples

    I don't see any requirement with delay parameter. Also, I don't see any code for pre-calculation with delay parameter in DSPF_sp_biquad_d.c.

    Best Regards,
    Naoki

  • Hi ,

    Thanks again for the quick response. I have looked at this documentation but it does not say what I should make my filter delays. Is that something that I should set? Where do I get these delay values?

    I think I read somewhere else on the forum that nx has to be multiple of 6 or it has to be an even number. Are either of those true?

    Also 'a' should be a pointer to a0, a1, a2. Even though a0 is not used, it must be included as the actual function requires 3 elements in that array.

    Regards,
    Akash Patel
  • Akash,

    DSPF_sp_biquad_d.c implies the code should pass zero-filled delay parameter at the first call of DSPF_sp_biquad. The delay should be updated in the kernel for next call. I believe you can just pass the delay as is for subsequent calls.
    As for 'a', I think you are correct, a[0] is just a place holder.

    If you need further help, ask DSP lib owner .

    Best Regards,
    Naoki
  • Naoki,

    Thanks, it looks like the delay is updated at the end of the DSPF_sp_biquad function call.

    /* find final delay elements to return */
    delay[0] = b[1] * x1 + b[2] * x0 - a[1] * sum - a[2] * y0;
    delay[1] = b[2] * x1 - a[2] * sum;

    If we are intending to have a multi-stage biquad filter, should we just call this function multiple times adjusting the input and output or is there a better function for us to instead use?

    Regards,

    Akash Patel

  • Akash,

    If cascaded biquad filter is needed, I think you will have to do your own implementation for getting better performance. I think subsequent call adjusting input/output/delay is so inefficient in performance.

    Best Regards,
    Naoki
  • Hi Naoki,

    Do you know if the DSPF_sp_iir function is the correct function for a multi-stage biquad filter? The parameters for this function appear to be different than for the DSPF_sp_biquad function.

    Regards,
    Akash Patel

  • Hi Akash

    My suggestion is always to look at the C model of the functions. This is part of the release and you can see clearly what is the algorithm and how to use the function.

    And you can always look at the Wiki http://processors.wiki.ti.com/index.php/C674x_DSPLIB#DSPF_sp_iir_.28IIR_Filter.29 to understand what the function is doing and how to use it.  The library is implemented differently for different platform but the API and what it does are always teh same  (OK almost always)

    Ran