ΣSigmaStudio Ask AI Русский Log in

the coefficients of biquad do not match

SigmaDSP & SigmaStudio Fell1987 Oct 16, 2025 00:00 3 replies Original on forum ↗
Thread Summary

Thread Summary

The user encountered discrepancies in filter coefficients between the Sigma Studio filter block and the filter table generator. The final answer identified that the mismatch in gain settings (scale gain in dB) was causing the differences. The user's function for calculating coefficients was clarified to use the gain value for controlling the EQ curve, with boost always set to 0dB. The solution also noted the importance of normalizing coefficients relative to a0 and inverting the signs of a1 and a2 for correct implementation.
AI Generated Content
Subscribe
Fell1987 Question
Oct 16, 2025 00:00

Hello! I'm writing code for a microcontroller, and I've reached the stage of equalization, but I'm facing difficulties.
In the sigma studio window, the coefficients differ from the generator built into the program. Why is this happening, and how can I calculate it correctly?

Biquad Coefficient

software

adau 1701

Sigma Studio v4.7

gen.png
gen.png
-1.png
-1.png
-2.png
-2.png
adr.jpg
Open original image
adr1701.jpg
Open original image
Harishgowtham Reply
Oct 17, 2025 00:00

Hello Fell1987,

I have tried with same parameters in filter block and filter table generator; I ended up getting the same results.

Please have a look below and try with same parameters.

I tried with the same parameters as you did and ended up getting the expected results.

I have noticed in your screenshot that your filter block's gain (named as 'scale gain (dB)') is set for -1dB and -2dB whereas in the filter table generator window, the gain is set for 0dB. So, that mismatch in the parameter causes these differences.

Below are your screenshots, where I marked the mismatches.

Regards,

Harish

pastedimage1760682188351v1.png
pastedimage1760682188351v1.png
pastedimage1760682654281v2.png
pastedimage1760682654281v2.png
pastedimage1760683078272v3.png
pastedimage1760683078272v3.png
pastedimage1760683102836v4.png
pastedimage1760683102836v4.png
pastedimage1760683119427v5.png
pastedimage1760683119427v5.png
Fell1987 Reply
Oct 17, 2025 00:00

Thanks for the quick response!
Apparently, I'm confusing boost and gain.
In order to control the EQ curve, I need to pass the gain values that I'm adjusting to the function. Boost always = 0
Correct assumption?

Here's my function

void SigmaDSP::EQsecondOrder(uint16_t startMemoryAddress, secondOrderEQ_t &equalizer)
{
float A, w0, alpha, gainLinear;
float b0, b1, b2, a0, a1, a2;
float coefficients[5];

A=pow(10,(equalizer.boost/40)); // equalizer.boost is '0' always
w0=2*PI*equalizer.freq/FS; // 2*PI*freq/FS
gainLinear = pow(10,(equalizer.gain/20)); // exactly what I adjust with the gain knob

//********next, just the calculations********//

switch(equalizer.filterType)

// Parametric
case parameters::filterType::parametric:
// Peaking
case parameters::filterType::peaking:
default:
alpha = sin(w0)/(2*equalizer.Q);
a0 = 1 + alpha/A;
a1 = -2 * cos(w0);
a2 = 1 - alpha/A;
b0 = (1 + alpha*A) * gainLinear;
b1 = -(2 * cos(w0)) * gainLinear;
b2 = (1 - alpha*A) * gainLinear;
break;

// Low shelf
case parameters::filterType::lowShelf:
alpha=sin(w0)/2*sqrt((A+1/A)*(1/equalizer.S-1)+2);
a0 = (A+1)+(A-1)*cos(w0)+2*sqrt(A)*alpha;
a1 = -2*((A-1)+(A+1)*cos(w0));
a2 = (A+1)+(A-1)*cos(w0)-2*sqrt(A)*alpha;
b0 = A*((A+1)-(A-1)*cos(w0)+2*sqrt(A)*alpha)*gainLinear;
b1 = 2*A*((A-1)-(A+1)*cos(w0)) * gainLinear;
b2 = A*((A+1)-(A-1)*cos(w0)-2*sqrt(A)*alpha)*gainLinear;
break;

// High shelf
case parameters::filterType::highShelf:
alpha = sin(w0)/2 * sqrt((A + 1/A)*(1/equalizer.S - 1) + 2);
a0 = (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha;
a1 = 2*((A-1) - (A+1)*cos(w0));
a2 = (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha;
b0 = A*((A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha) * gainLinear;
b1 = -2*A*((A-1) + (A+1)*cos(w0)) * gainLinear;
b2 = A*((A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha) * gainLinear;
break;

// Lowpass
case parameters::filterType::lowpass:
alpha = sin(w0)/(2*equalizer.Q);
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 - cos(w0)) * (gainLinear/2);
b1 = (1 - cos(w0)) * gainLinear;
b2 = (1 - cos(w0)) * (gainLinear/2);
break;

// Highpass
case parameters::filterType::highpass:
alpha = sin(w0)/(2*equalizer.Q);
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 + cos(w0)) * (gainLinear/2);
b1 = -(1 + cos(w0)) * gainLinear;
b2 = (1 + cos(w0)) * (gainLinear/2);
break;

// Bandpass
case parameters::filterType::bandpass:
alpha = sin(w0) * sinh(log(2)/(2 * equalizer.bandwidth * w0/sin(w0)));
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = alpha * gainLinear;
b1 = 0;
b2 = -alpha * gainLinear;
break;

// Bandstop
case parameters::filterType::bandstop:
alpha = sin(w0) * sinh(log(2)/(2 * equalizer.bandwidth * w0/sin(w0)));
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = 1 * gainLinear;
b1 = -2*cos(w0) * gainLinear;
b2 = 1 * gainLinear;
break;

// Butterworth lowpass
case parameters::filterType::butterworthLowpass:
alpha = sin(w0) / 2.0 * 1/sqrt(2);
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 - cos(w0)) * gainLinear / 2;
b1 = (1 - cos(w0)) * gainLinear;
b2 = (1 - cos(w0)) * gainLinear / 2;
break;

// Butterworth highpass
case parameters::filterType::butterworthHighpass:
alpha = sin(w0) / 2.0 * 1/sqrt(2);
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 + cos(w0)) * gainLinear / 2;
b1 = -(1 + cos(w0)) * gainLinear;
b2 = (1 + cos(w0)) * gainLinear / 2;
break;

// Bessel lowpass
case parameters::filterType::besselLowpass:
alpha = sin(w0) / 2.0 * 1/sqrt(3) ;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 - cos(w0)) * gainLinear / 2;
b1 = (1 - cos(w0)) * gainLinear;
b2 = (1 - cos(w0)) * gainLinear / 2;
break;

// Bessel highpass
case parameters::filterType::besselHighpass:
alpha = sin(w0) / 2.0 * 1/sqrt(3) ;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
b0 = (1 + cos(w0)) * gainLinear / 2;
b1 = -(1 + cos(w0)) * gainLinear;
b2 = (1 + cos(w0)) * gainLinear / 2;
break;
}

// 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.state == parameters::state::on)
{
if(equalizer.phase == parameters::phase::nonInverted) // 0 deg
{
coefficients[0] = b0/a0;
coefficients[1] = b1/a0;
coefficients[2] = b2/a0;
coefficients[3] = -1*a1/a0;
coefficients[4] = -1*a2/a0;
}
else //if(equalizer.phase == parameters::phase::inverted) // 180 deg
{
coefficients[0] = -1*b0/a0;
coefficients[1] = -1*b1/a0;
coefficients[2] = -1*b2/a0;
coefficients[3] = -1*a1/a0; // This coefficient does not change sign!
coefficients[4] = -1*a2/a0; // This coefficient does not change sign!
}
}
else //if(equalizer.state == parameters::state::off)
{
coefficients[0] = 1.00;
coefficients[1] = 0;
coefficients[2] = 0;
coefficients[3] = 0;
coefficients[4] = 0;
}

safeload_write(startMemoryAddress, coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4]);
}

Gain.png
Gain.png
7610.graph.png
7610.graph.png
Harishgowtham Reply
Oct 17, 2025 00:00

Hello Fell1987,

The Gain parameter is an overall gain factor that will be applied to the entire signal whereas the boost parameter sets up the EQ curve to boost a particular frequency.

Below I set the boost (slider) to 0dB (input will be unaffected (magnitude level) by the filter) and set the gain to '0dB' in one example and '1dB' in another example.

You can see above that the entire spectrum is boosted by 1dB.

When I set up the low shelf filter to -6dB at 150Hz, you can see the difference in the plot between gain = 0 and gain = 1.

I have explained this in detail in the below thread

difference between boost and gain of Medium EQ - Q&A - SigmaDSP Processors & SigmaStudio Dev. Tool - EngineerZone

Regards,

Harish

pastedimage1760699320969v1.png
pastedimage1760699320969v1.png
pastedimage1760699598801v2.png
pastedimage1760699598801v2.png