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.

TAS5717: TAS5717 biquad transfer function

Part Number: TAS5717
Other Parts Discussed in Thread: TAS5782M

Hello,

I need to implement a parametric equalizer using the TAS5717 biquad cofficients. That means I need to calculate the biquads on the fly and cannot use your TI tool.

Could you please tell me the H(z) transfer function that is used in the amplifier? It seems TAS uses a different function than the common H(z) = (b0 + b1* z[-1] + b2 * z[-2]) / (1 + a1 * z[-1] + a2 * z[-2]) which is used in filter calculations.

Thanks

Petr

  • Hi Petr,

    Please refer to the attached document for the BQ filter equations on TAS devices.

    0027.Biquad Filters Application Note.pdf

    Best regards,

    Shawn Zheng

  • Hi Shawn,

    thanks a lot for the document, it gives a good insight. Is this how the TI tool calculates the coefficients?
    I use different formulas for the coefficient calculation (from Bristow-Johnson shepazu.github.io/.../audio-eq-cookbook.html), but I guess they should work as well if the coefficients are normalized accordingly?

    I don't understand one thing in the normalization. In the example on page 25, in step 2 all the numerator coefficients are scaled by 1/b0 because b0 > 1. The maths doesn't seem to fit. How can b0 * (1/b0) result in something else than 1? (in the example the result is 0.9924645424)

    Best regards
    Petr
  • Hi Petr,

    Sorry for the confusion. This document is based on 1.23 format(AIC Codec), so there is a step for the normalization to avoid the over-float. But for our open-loop audio amp devices (e.g. TAS5717) which is based on 3.23 format, there is actually NO this step. Please ignore this step in the document and just convert the calculated coefficients to 26-bit 3.23 format directly. The covert method is explained on the Page 31 in the TAS5717 datasheet. But the EQ coefficients calculation formula in that document apply to TAS5717 open-loop device. Sorry again for the confusion.

    Best regards,

    Shawn Zheng    

  • Hi Petr,
    Plesase let us know if you have any other question here. Please help to close it if you don't more other question.
    Best regards,
    Shawn Zheng
  • Hi Shawn,

    I have now implemented my filters using your help, though I use the "cookbook" formulas because my input is Fc, gain and Q (instead of BW). The reason I still haven't closed this topic is that it seems the filters are performing a different kind of filter operation than expected. They are however not completely wrong as before. Before there were pops, noise and the amplifier was switching of, perhaps due to overruns in the maths.

    I use the following calculation (in C):

        float b0, b1, b2, a0, a1, a2;

        float omega0 = 2* M_PI * freq / Fs;
        float cos_o0 = cos(omega0);
        float alpha = sin(omega0) / (2 * Q);
        float A = powf(10, gain / 40);

        /*
         * our calculation uses the following transfer function
         *         b0*x[n] + b1*x[n-1] + b2*x[n-2]
         * H(z) = ----------------------------------
         *         a0*y[n] + a1*y[n-1] + a2*y[n-2]
         */

        /* Notch filter */
        b0 = b2 = 1;
        b1 = a1 = -2 * cos_o0;
        a0 = 1 + alpha;
        a2 = 1 - alpha;

        /* normalize to a0 == 1 (i.e. create 5 coefficients) */
        b0 /= a0;
        b1 /= a0;
        b2 /= a0;
        a1 /= a0;
        a2 /= a0;

        /*
         * convert to TI transfer function
         *         b0*x[n] + 2*b1*x[n-1] + b2*x[n-2]
         * H(z) = ----------------------------------
         *         y[n] - 2*a1*y[n-1] - a2*y[n-2]
         */
        b1 *= 0.5;
        a1 *= -0.5;
        a2 = -a2;

        uint32_t b0_323 = to3_23(b0);
        uint32_t b1_323 = to3_23(b1);
        uint32_t b2_323 = to3_23(b2);
        uint32_t a1_323 = to3_23(a1);
        uint32_t a2_323 = to3_23(a2);

    Here the conversion function
    uint32_t to3_23(float x)
    {
        uint32_t r;
        if (x >= 0)
            r = x * (1 << 23);
        else {
            r = (-x) * (1 << 23);
            r = -r;
        }

        return r & 0x03ffffff;
    }


    The coefficients are then written in the order b0_323, b1_323, b2_323, a1_323, a2_323.
    Is this correct?

    Best regards
    Petr

  • Hi Petr,

    Thanks for the update. The notch filter calculation formula is introduced in section 1.3 in the document that I uploaded previously. Here I upload another tool that can be used to simulate the notch filter response. You could use it to generate the register config for any notch filter setting.

    notch_filter.xlsx

    Best regards,

    Shawn Zheng

  • Hi Shawn,

    thanks a lot, the last document helped! The a1 and b1 are not divided by 2 as written in the Application Note 0027. So the transfer function is actually:

        /*
         * TI transfer function
         *         b0*x[n] + b1*x[n-1] + b2*x[n-2]
         * H(z) = ----------------------------------
         *         y[n] - a1*y[n-1] - a2*y[n-2]
         */

    I.e. just the a1 and a2 are multiplied by -1.

    With this modification the filtering actually sounds like doing the right thing. I am just getting some audio artefacts, loud pops and audio mutes when changing the EQ parameters too quickly (the EQ is connected to a UI).
    I am suspecting a bit the coefficient loading which is loading them one by one. Unfortunately the intermediate SW API I'm using doesn't allow to set all 5 coefficients at once. So there might be transitional moments when some of the coefs are old and some are new. That would of course result in calculation errors. Is there a way to write the coefs first and then tell the amp to use the new ones (some kind of double buffering)?

    Best regards
    Petr

  • Hi Petr,
    Very glad to know your SW is working as expected now. Unfortunately there is no way to write the coefficients at the same time on TAS5717, because this is an old device. So when changing the BQ efficients on TAS5717, need to mute the output signal to avoid the pop noise on the speaker. For the later device, e.g. TAS5782M, the 5 coefficients are writen to a buffer at the first, and then load the filter at the same time. But this is not supported on TAS5717.
    Best regards,
    Shawn Zheng
  • Hi Shawn,

    would it be sufficient to set the "EQ Off" bit (bit 7) in the EQ Control register (0x50) prior to updating the biquads and then clearing it to "EQ On" afterwards ?

    Best regards
    Petr
  • Hi Petr,
    This is a good point, you could try that. But usually we recommend users to mute the output first and then program the BQ taps to avoid the unexpected noise for this device.
    Best regards,
    Shawn Zheng