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() Question

Hello E2E,

I am calculating biquad coefficients (for tuning filters) on the fly and applying them through DSPF_sp_biquad() on C6713 DSK. It is partially working. 

The audio output is clean when the application starts with a[ ] and b[ ] = 1.0f. When the new set of coefficients are applied:

1. I hear clicks in the output. The sine wave output is not smooth.

2. The sine sweep on Audio Precision is intelligible for given Fc, gain and Q, but towards the lower frequency (below 1kHz) I don't see the clean bell-shape curves. 

The filter function is as below:

a. DSPF_q15tofl(...);

b. DSPF_sp_biquad(...);

c. DSPF_fltoq15(...);

So far I have tried scaling the input, scaling the coeffs, optimization (-o3) and HWI_disable/enable, but no luck in getting rid of the noise.

Is there any initialization required before calling DSPF_sp_biquad() before applying the new set of coeffs? What am I missing? Greatly appreciate a sooner response. Kindly let me know if you need more info.

Thanks,

Sach

  • Sach,

    This sounds like a digital quantization problem, but it is not clear what your signal source to step a. DSPF_q15tofl() is. Also, you have not stated what the sample frequency is, only that 1kHz is much lower.

    My recommendation is to look at the data at each step to see where the noise enters the signal. You may want to start with disabling the biquad step at first, then examine closely the results of the biquad with attention at the lower frequencies to how the float values vary. Especially consider how those values will be converted to the q15 fixed point representation.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Randy,

    Thank you for looking into my query.

    My signal source for DSPF_q15tofl( ) is from Audio Precision landing into short buffer of size 1280 samples. I am sweeping the input from 20kHz down to 20Hz. The sampling frequency set on AIC23 and filter calculation is 48kHz. 

    When I compare the biquad coeffs on DSK and Matlab side-by-side they match precisely. I am surprised to see the noise floor on the C6713 DSK is around -54 dBV. With a 16bit codec ideally you would expect the noise floor around -96 dBV, with the losses say around -80 dBV. Is -54 dBV noise floor typical for C6713 DSKs or is it just my board issue? 

    When I pass though audio DSPF_q15tofl() -> DSPF_fltoq15( ) the audio is clean. The q15 buffers' data match bit-by-bit before and after the conversion. I am more concerned about the EQ curves and the biquad stability. I am stuck with this problem for over 2 weeks. Can you kindly review my code if I email you the CCS project? 

    Regards,

    Sach

  • Sach,

    I would not be able to help you with the project file. I will try to work with you remotely to suggest debug methods.

    How many steps are there between the q15tofl and fltoq15 calls? If only the biquad, then please look at the data to see whether it looks correct at the floating point stage. If there are mutliple blocks, you will need to find out which block introduces the data changes that cause the noise.

    Are you able to graph the data at the float- and fixed-point stages?

    Regards,
    RandyP

  • Hello Randy,

    No problem. I have 3 stages between q15tofl and fltoq15, but the problem occurs even with just one stage. I graphed the data prior to inserting the biquad sections to make sure the audio in and out is clean. Let me try to  graph the data again. But I know for sure that the integrity of the signal is getting affected (please see the graph below) for any non-zero gain for any freq and Q. Once I set the gain to zero the signal is clean again.

    This is the filter function for left channel and the right channel merely duplicates it. I have left the commented code intentionally to show what I have tried. Please note that all the buffers are double-word aligned.

     

    1. Void apply_filter_lt(short* in, short* out, int bufsz)
    2. {
    3. int i;
    4. DSPF_q15tofl(in, fFltBufX, bufsz);
    5. /*     for (i = 0; i < bufsz; i++)
    6. {
    7. fFltBufX[i] = (float)(in[i] / 32768.0f);
    8. }
    9. */
    10. // iir_df2_2tp_1ch_sp_sp_sp(fFltBufX, fFltBufY, iir_a1, iir_b1, lt_delay1, bufsz);
    11. // iir_df2_2tp_1ch_sp_sp_sp(fFltBufY, fFltBufX, iir_a2, iir_b2, lt_delay2, bufsz);
    12. // iir_df2_2tp_1ch_sp_sp_sp(fFltBufX, fFltBufY, iir_a3, iir_b3, lt_delay3, bufsz);
    13. HWI_disable();
    14. DSPF_dp_biquad_C(fFltBufX, iir_b1, iir_a1, lt_delay1, fFltBufY, bufsz);
    15. DSPF_dp_biquad_C(fFltBufY, iir_b2, iir_a2, lt_delay2, fFltBufX, bufsz);
    16. DSPF_dp_biquad_C(fFltBufX, iir_b3, iir_a3, lt_delay3, fFltBufY, bufsz);
    17. HWI_enable();
    18. DSPF_fltoq15(fFltBufY, out, bufsz);
    19. /*     for (i = 0; i < bufsz; i++)
    20. {
    21. out[i] = (short)(fFltBufY[i] * 32768.0f);
    22. }
    23. */

     

    Here is how the lower frequency signals (@300Hz as an example)  look like.

    Regards,

    Sach

  • Sach,

    What does the noise repetition period of 12.5ms tell you? What feature of this process does that line up with?

    The variable declarations are not visible, but you appear to be using single-precision float with a double-precision function.

    Is there a requirement for the biquad function that interrupts be disabled, or did you insert the HWI_disable/enable pair for debug purposes?

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • RandyP said:

    Sach,

    What does the noise repetition period of 12.5ms tell you? What feature of this process does that line up with?

    The variable declarations are not visible, but you appear to be using single-precision float with a double-precision function.

    Is there a requirement for the biquad function that interrupts be disabled, or did you insert the HWI_disable/enable pair for debug purposes?

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

     

    What does the noise repetition period of 12.5ms tell you? What feature of this process does that line up with?

    I am not sure. Can you please elaborate this?

    The variable declarations are not visible, but you appear to be using single-precision float with a double-precision function.

    The variables are declared as SP. I tried using both SP and DP functions, both behaved same. 

    Is there a requirement for the biquad function that interrupts be disabled, or did you insert the HWI_disable/enable pair for debug purposes?

    I read that on couple of threads here on the forum and also DSPLIB doc (spru657) says "the function is interrupt-tolerant but not interruptible". To answer your question, yes for debug purpose. 

     

  • Sach,

    FYI, when you are writing a reply you can select a line or any amount of text in the previous post (displayed above your edit box) and then click the red Quote link. This will create a quote box with just the selected portion. If nothing is selected when you click on Quote, then the entire previous thread is copied in.

    Sach said:

    What does the noise repetition period of 12.5ms tell you? What feature of this process does that line up with?

    I am not sure. Can you please elaborate this?

    The picture you supplied shows noise spikes every 12.5ms. That does not seem like a basic functionality problem but more of a setup or edge condition problem. It could be in the function being called or it could be from outside of the function. I do not know what significance 12.5ms has for your system, so I cannot predict an error cause or solution.

    What do you think could be significant about 12.5ms between noise spikes?

    Regards,
    RandyP

  • Randy,

    RandyP said:
    The picture you supplied shows noise spikes every 12.5ms. That does not seem like a basic functionality problem but more of a setup or edge condition problem. It could be in the function being called or it could be from outside of the function. I do not know what significance 12.5ms has for your system, so I cannot predict an error cause or solution.

    I see what you mean. So further investigating, along the lines of your explanation, it turns out that 12.5ms is the buffer boundary in turn thats when the biquad function gets called.

    1/48000 (samplerate) * 600 (buffer size) = 12.5ms

    Just to prove the point to myself I changed the buffer size to 1280, sure enough the spikes spread apart 26.6ms.

    1/48000 (samplerate) * 1280 (buffer size) = 26.6ms

    So is there any priming/initialization required between the biquad function calls for each new set data? How do I fix the spikes/noise while switching the buffers?

    Regards,

    Sach

  • Sach,

    My guess is this has to do with the delay values that are carried from one call to the next. How are these handled in your code?

    Regards,
    RandyP