Hi folks, First of all, I know _very_ little about DSP and the jargon that comes with it so please be gentle <g> I have implemented, in a computer program, a routine that converts parametric EQ values (Frequency, Amplitude and Q) to Biquad coefficients. Works fine. The conversion consists of pre-warping correction followed by a bilinear transformation, Normalize and Quantize. Now I need to reverse the process. I need to get the Frequency, Amplitude and Q values from the 6 Biquad coefficients. As an example, at 1000Hz, -12 dB gain and a Q of 22.387, the following coefficients are produced: b0: 16175 b1: -31590 b2: 16034 a0: 16384 a1: -31590 a2: 15825 I need to convert these coefficients back to A, F and Q. Also, I noticed that not matter what values of F, A and Q I start off with, the following is true: b1 and a1 are always equal. a0 is always 16384 So is it possible to get the inidividual EQ parameters from the Biquad coefficients ? Thanks ! Steph
BiQuad coefficients to EQ parameters or Reverse Bilinear Transform
Started by ●June 10, 2005
Reply by ●June 10, 20052005-06-10
Steph wrote:> Hi folks, > > First of all, I know _very_ little about DSP and the jargon that comes with > it so please be gentle <g> > > I have implemented, in a computer program, a routine that converts > parametric EQ values (Frequency, Amplitude and Q) to Biquad coefficients. > Works fine. The conversion consists of pre-warping correction followed by a > bilinear transformation, Normalize and Quantize. > > Now I need to reverse the process. I need to get the Frequency, Amplitude > and Q values from the 6 Biquad coefficients. > > As an example, at 1000Hz, -12 dB gain and a Q of 22.387, the following > coefficients are produced: > > b0: 16175 > b1: -31590 > b2: 16034 > a0: 16384 > a1: -31590 > a2: 15825 > > I need to convert these coefficients back to A, F and Q. > Also, I noticed that not matter what values of F, A and Q I start off with, > the following is true: > > b1 and a1 are always equal. > a0 is always 16384 > > So is it possible to get the inidividual EQ parameters from the Biquad > coefficients ?Sometimes, but not always. Parametric equalizer sections are just a subset of the filters that can be built of biquads, so there's not always a set of F, A, and Q to go back to. When you can reverse the process, it's just algebra. jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●June 10, 20052005-06-10
Jerry, Thanks for replying. I understand your response. Let me elaborate a litle more. This has to do with a notch filter. I already know the exact combinations of F, A and Q that I want to use. F=37 values - Range from 800Hz to 6700Hz A= -3dB, -6dB, -9dB, -12dB Q=1 octave, 1/2 octave, 1/3 octave, 1/4 octave, 1/6 octave, 1/12 octave The actual Q value for each octave is dependant on the amplitude, therefore there are 4 different Q values per amplitude value. Again, I know exactly what these values are. So for each combination of F, A and Q, I get a different set of coefficients. Sure I could whip up a huge lookup table, but I rather go thru the mathematical approach. Does the fact of having a precise set of possible EQ values help in guarenteeing that reversing the process will in fact generate the appropriate EQ values ? I checked out chapter 33 of the DSPGuide book (The Z-Transform). If it's in there, I haven't picked up how to do what I want. Now why do I want to do this ? Because the DSP device I work with stores Biquad values but my software application allows the user to control the filter with F, A and Q. When I read the Biquad values from the device, I need to set the controls to their appropriate settings. A user can very well read from a DSP device that he did not oringinally program, so without means to convert from Biquad to EQ values, i'm screwed <g> Again, thanks. Steph "Jerry Avins" <jya@ieee.org> wrote in message news:MZydncoHNLHTfjTfRVn-qQ@rcn.net...> Steph wrote: > > Hi folks, > > > > First of all, I know _very_ little about DSP and the jargon that comeswith> > it so please be gentle <g> > > > > I have implemented, in a computer program, a routine that converts > > parametric EQ values (Frequency, Amplitude and Q) to Biquadcoefficients.> > Works fine. The conversion consists of pre-warping correction followedby a> > bilinear transformation, Normalize and Quantize. > > > > Now I need to reverse the process. I need to get the Frequency,Amplitude> > and Q values from the 6 Biquad coefficients. > > > > As an example, at 1000Hz, -12 dB gain and a Q of 22.387, the following > > coefficients are produced: > > > > b0: 16175 > > b1: -31590 > > b2: 16034 > > a0: 16384 > > a1: -31590 > > a2: 15825 > > > > I need to convert these coefficients back to A, F and Q. > > Also, I noticed that not matter what values of F, A and Q I start offwith,> > the following is true: > > > > b1 and a1 are always equal. > > a0 is always 16384 > > > > So is it possible to get the inidividual EQ parameters from the Biquad > > coefficients ? > > Sometimes, but not always. Parametric equalizer sections are just a > subset of the filters that can be built of biquads, so there's not > always a set of F, A, and Q to go back to. When you can reverse the > process, it's just algebra. > > jerry > -- > Engineering is the art of making what you want from things you can get. > �����������������������������������������������������������������������
Reply by ●June 10, 20052005-06-10
"Steph" <sgtpepper@bootcamp.com> wrote in message news:gLkqe.16080$_n2.1228632@news20.bellglobal.com...> Hi folks, > > First of all, I know _very_ little about DSP and the jargon that comes with > it so please be gentle <g> > > I have implemented, in a computer program, a routine that converts > parametric EQ values (Frequency, Amplitude and Q) to Biquad coefficients. > Works fine. The conversion consists of pre-warping correction followed by a > bilinear transformation, Normalize and Quantize. > > Now I need to reverse the process. I need to get the Frequency, Amplitude > and Q values from the 6 Biquad coefficients. > > As an example, at 1000Hz, -12 dB gain and a Q of 22.387, the following > coefficients are produced: > > b0: 16175 > b1: -31590 > b2: 16034 > a0: 16384 > a1: -31590 > a2: 15825 > > I need to convert these coefficients back to A, F and Q. > Also, I noticed that not matter what values of F, A and Q I start off with, > the following is true: > > b1 and a1 are always equal. > a0 is always 16384When you go from A/F/Q to biquad coefficients, you create 6 coefficients from 3 parameters, which is fine. But going the other way, that means you have 6 equations to find 3 unknowns, which is an "over-determined system". This is because, as Jerry also mentioned, not all possible 6-coef. biquads map to a parametric EQ. You already realized 2 important facts which will be true for parametric EQs, but necessarily not other biquad filter types (e.g. low-pass, shelf, etc.). What I would do is pick 3 of your equations, say b0, b1, and b2 and then try to go through the algebra to get back to A/F/Q. Since you have 3 equations and 3 unknowns, this should be possible. Depending on how you do your frequency pre-warping, you may need to undo that when you are done as well. If you get stuck, try posting the 3 equations here and maybe someone will help. Good luck! -- Jon Harris SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply.
Reply by ●June 10, 20052005-06-10
Jon, I posted more info in my reply to Jerry, so I'll wait and see what he, or anyone else, thinks before trying what you suggest. Thanks, Steph "Jon Harris" <jon_harrisTIGER@hotmail.com> wrote in message news:11ajtl7bnj1ep08@corp.supernews.com...> "Steph" <sgtpepper@bootcamp.com> wrote in message > news:gLkqe.16080$_n2.1228632@news20.bellglobal.com... > > Hi folks, > > > > First of all, I know _very_ little about DSP and the jargon that comeswith> > it so please be gentle <g> > > > > I have implemented, in a computer program, a routine that converts > > parametric EQ values (Frequency, Amplitude and Q) to Biquadcoefficients.> > Works fine. The conversion consists of pre-warping correction followedby a> > bilinear transformation, Normalize and Quantize. > > > > Now I need to reverse the process. I need to get the Frequency,Amplitude> > and Q values from the 6 Biquad coefficients. > > > > As an example, at 1000Hz, -12 dB gain and a Q of 22.387, the following > > coefficients are produced: > > > > b0: 16175 > > b1: -31590 > > b2: 16034 > > a0: 16384 > > a1: -31590 > > a2: 15825 > > > > I need to convert these coefficients back to A, F and Q. > > Also, I noticed that not matter what values of F, A and Q I start offwith,> > the following is true: > > > > b1 and a1 are always equal. > > a0 is always 16384 > > When you go from A/F/Q to biquad coefficients, you create 6 coefficientsfrom 3> parameters, which is fine. But going the other way, that means you have 6 > equations to find 3 unknowns, which is an "over-determined system". Thisis> because, as Jerry also mentioned, not all possible 6-coef. biquads map toa> parametric EQ. You already realized 2 important facts which will be truefor> parametric EQs, but necessarily not other biquad filter types (e.g.low-pass,> shelf, etc.). What I would do is pick 3 of your equations, say b0, b1,and b2> and then try to go through the algebra to get back to A/F/Q. Since youhave 3> equations and 3 unknowns, this should be possible. Depending on how youdo your> frequency pre-warping, you may need to undo that when you are done aswell.> > If you get stuck, try posting the 3 equations here and maybe someone willhelp.> Good luck! > > -- > Jon Harris > SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply. > >
Reply by ●June 10, 20052005-06-10
"Steph" <sgtpepper@bootcamp.com> wrote in message news:ktmqe.15182$Nd3.817821@news20.bellglobal.com...> > Now why do I want to do this ? Because the DSP device I work with stores > Biquad values but my software application allows the user to control the > filter with F, A and Q. When I read the Biquad values from the device, I > need to set the controls to their appropriate settings. A user can very > well read from a DSP device that he did not oringinally program, so without > means to convert from Biquad to EQ values, i'm screwed <g>If you have full control over the DSP device, you could just store the F/A/Q values along with the biquad coefs in the DSP memory. Then when your application needs to figure out the EQ settings, it just reads back the F/A/Q values, ignoring the DSP coefs. Similarly, the DSP would ignore the F/A/Q values and use only the coefs. But if this is a "black box" DSP device you can't touch, that obviously won't be an option.
Reply by ●June 10, 20052005-06-10
Steph wrote:> Jon, > > I posted more info in my reply to Jerry, so I'll wait and see what he, or > anyone else, thinks before trying what you suggest. > > Thanks,I think Jon answered you as fully as can be without a lot of work and seeing the equations you use. One approach is a guided trial-and-error search by the computer might work. It would be aided by the limited number of values you allow. What is tedious to us might be plenty quick with a computer. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●June 10, 20052005-06-10
Hi Steph, It's no problem going from coefficients back to parameters. I've done it many times when I've had to duplicate a DSP algorithm, created on another device and running at a different sample rate, lacking documentation. (This is an extrememly common practice--developers tend to calculate the filters they need in a filter-building application, then convert the values to fixed point in hexadecimal and stuff them in a table that gets transferred to the DSP from the host. I beat on one employer of mine for a few years to spec their filters in terms of frequency, Q, and other non-rate-specific values; it took a while, but they finally caved in when they started having to work with multiple sample rates and platforms and found what an enormous pain it is to reverse engineer everything.) I assume that you have the equations that generate the coefficients ( used by the UI code that generates the coefficients from the user knob- twiddling). You just need to rearrange the equations, and sovle in terms of frequency, etc. A trivial example is the one-pole lowpass: k = e^(-2 * pi * Fc / Fs) for which you solve in terms of Fc to get back to frequency, knowing the coefficient k: Fc = -ln(k) * Fs / (2 * pi) For biquads, you'll have the obvious simultaneous equations, but it's pretty straight-forward mathematical manipulation to get what you want. Nigel In <ktmqe.15182$Nd3.817821@news20.bellglobal.com> Steph wrote:> Does the fact of having a precise set of possible EQ values help in > guarenteeing that reversing the process will in fact generate the > appropriate EQ values ? > > ... > > Now why do I want to do this ? Because the DSP device I work with > stores Biquad values but my software application allows the user to > control the filter with F, A and Q. When I read the Biquad values > from the device, I need to set the controls to their appropriate > settings.
Reply by ●June 10, 20052005-06-10
"Jerry Avins" <jya@ieee.org> wrote in message news:WJmdnWi2jaQ1kzffRVn-qQ@rcn.net...> Steph wrote: > > Jon, > > > > I posted more info in my reply to Jerry, so I'll wait and see what he, or > > anyone else, thinks before trying what you suggest. > > > > Thanks, > > I think Jon answered you as fully as can be without a lot of work and > seeing the equations you use. One approach is a guided trial-and-error > search by the computer might work. It would be aided by the limited > number of values you allow. What is tedious to us might be plenty quick > with a computer.OK, I took a stab at this, and it wasn't too bad in terms of the algebra. First of all, if you haven't already seen it, check out the audio EQ cookbook at http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt, because I'm assuming those definitions (peaking EQ, Q specified). Given that, here is a short Matlab script that calculates the 6 biquad coefficients for a parametric ("peaking") EQ and then reverses the process to find gain, frequency, and Q: %Implements RBJ's peaking EQ % see: http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt % Then reverses the equations to find gain, Q, and frequency from the coefficients sampleRate = 48000; dBgain = 15; freq = 767; Q = 1.234; A = 10^(dBgain/40); omega = 2*pi*freq/sampleRate; sinn = sin(omega); cosn = cos(omega); alpha = sinn/(2*Q) %if Q is specified b0 = 1 + alpha*A; b1 = -2*cosn; b2 = 1 - alpha*A; a0 = 1 + alpha/A; a1 = -2*cosn; a2 = 1 - alpha/A; %Now reverse the process omega0Calc = acos(-b1/2); freqCalc = omega0Calc*sampleRate/(2*pi) Acalc = sqrt( (b0-1) / (1-a2) ); dBgainCalc = log10(Acalc)*40 alphaCalc = sqrt( (1-a2) * (b0-1) ); QCalc = sin(omega0Calc)/(2*alphaCalc) %end of Matlab Don't worry if you don't have Matlab, you should be able to use the 6 equations at the end to reverse your filter. I did this by simply starting with the equations for b0, b1, and a2 and solving simeltaneously for A, omega0, and alpha. Once I had those 3 parameters, I converted them into the standard gain (in dB), Q, and frequency. You can probably combine that conversion step with the previous formula if you like and some simplficiation might result. -- Jon Harris SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply.
Reply by ●June 10, 20052005-06-10
Oops, I just noticed that this only works if the filter coefficients are NOT normalized. If they are normalized, so that a0 = 1, it doesn't give the right answer. Fixing to work with normalized coefficients looks pretty messy, so I will defer to someone else... -- Jon Harris SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply. "Jon Harris" <jon_harrisTIGER@hotmail.com> wrote in message news:11aka4va0mk94a5@corp.supernews.com...> "Jerry Avins" <jya@ieee.org> wrote in message > news:WJmdnWi2jaQ1kzffRVn-qQ@rcn.net... > > Steph wrote: > > > Jon, > > > > > > I posted more info in my reply to Jerry, so I'll wait and see what he, or > > > anyone else, thinks before trying what you suggest. > > > > > > Thanks, > > > > I think Jon answered you as fully as can be without a lot of work and > > seeing the equations you use. One approach is a guided trial-and-error > > search by the computer might work. It would be aided by the limited > > number of values you allow. What is tedious to us might be plenty quick > > with a computer. > > OK, I took a stab at this, and it wasn't too bad in terms of the algebra.First> of all, if you haven't already seen it, check out the audio EQ cookbook at > http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt, because I'm assumingthose> definitions (peaking EQ, Q specified). Given that, here is a short Matlab > script that calculates the 6 biquad coefficients for a parametric ("peaking")EQ> and then reverses the process to find gain, frequency, and Q: > > %Implements RBJ's peaking EQ > % see: http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt > % Then reverses the equations to find gain, Q, and frequency from the > coefficients > > sampleRate = 48000; > dBgain = 15; > freq = 767; > Q = 1.234; > A = 10^(dBgain/40); > omega = 2*pi*freq/sampleRate; > > sinn = sin(omega); > cosn = cos(omega); > alpha = sinn/(2*Q) %if Q is specified > > b0 = 1 + alpha*A; > b1 = -2*cosn; > b2 = 1 - alpha*A; > a0 = 1 + alpha/A; > a1 = -2*cosn; > a2 = 1 - alpha/A; > > %Now reverse the process > > omega0Calc = acos(-b1/2); > freqCalc = omega0Calc*sampleRate/(2*pi) > > Acalc = sqrt( (b0-1) / (1-a2) ); > dBgainCalc = log10(Acalc)*40 > > alphaCalc = sqrt( (1-a2) * (b0-1) ); > QCalc = sin(omega0Calc)/(2*alphaCalc) > > %end of Matlab > > > Don't worry if you don't have Matlab, you should be able to use the 6equations> at the end to reverse your filter. I did this by simply starting with the > equations for b0, b1, and a2 and solving simeltaneously for A, omega0, and > alpha. Once I had those 3 parameters, I converted them into the standard gain > (in dB), Q, and frequency. You can probably combine that conversion step with > the previous formula if you like and some simplficiation might result. > > -- > Jon Harris > SPAM blocked e-mail address in use. Replace the ANIMAL with 7 to reply.






