Closed SitrucL closed 2 years ago
To be honest, I'm not sure why the last two parameters are inverted. The function is borrowed from the AidaDSP project, and this is the explanation found in the source code there:
// For Sigma DSP implementation we need to normalize all the coefficients respect to a0
// and inverting by sign a1 and a2
if(a0 != 0.00 && equalizer->onoff == true)
{
if(equalizer->phase == false) // 0°
{
coefficients[0]=b0/a0;
coefficients[1]=b1/a0;
coefficients[2]=b2/a0;
coefficients[3]=-1*a1/a0;
coefficients[4]=-1*a2/a0;
}
@MaxPayne86 do you have an explanation for why coefficients[3] and coefficients[4] are inverted?
Hello, this is related to Sigma DSP biquad cell implementation.
https://wiki.analog.com/resources/tools-software/sigmastudio/toolbox/filters/general2ndorder
For all of the above filters, the coefficients are divided by a0, normalizing them and making a0 = 1 so that only 5 coefficients must be stored. In the actual implementation on the DSP, when the coefficients are stored in parameter RAM, a1 and a2 need to be inverted. SigmaStudio performs this operation automatically, in software, before the parameters are written to DSP memory. Microcontrollers must invert a1 and a2 before writing new coefficients to DSP memory.
I've been playing around with this library and believe that the coefficient calculations for equaliser state may not be correct. I used another calculator (https://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/) to verify my assumptions and I've updated the relevant equations.