in article -e2dnb04YcARFW7enZ2dnUVZ_tGdnZ2d@giganews.com, rkthebad at raviyenduri@gmail.com wrote on 02/15/2006 15:01:> I implemented the EQ with the DF-1 structure with first order noiseshaping.> There appears to be some problem though. A desired output isobtained only for> some settings of the EQ. If the settings (coefficients)are changed, the> output goes wild. Any suggestions?this is the simulation of the 16 bit filter with a 32 or 40 bit accumulator? or is this with full precision floating-point? have you tried it both ways: same input signal and same coefficients but different word widths/formats? if it behaves with the floating-point and not with the fixed-point, then, i guess, at least we know it's a numerical problem. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Amplitude response of a Biquad Filter
Started by ●January 27, 2006
Reply by ●February 16, 20062006-02-16
Reply by ●February 16, 20062006-02-16
>in article -e2dnb04YcARFW7enZ2dnUVZ_tGdnZ2d@giganews.com, rkthebad at >raviyenduri@gmail.com wrote on 02/15/2006 15:01: > >> I implemented the EQ with the DF-1 structure with first order noise >shaping. >> There appears to be some problem though. A desired output is >obtained only for >> some settings of the EQ. If the settings (coefficients) >are changed, the >> output goes wild. Any suggestions? > >this is the simulation of the 16 bit filter with a 32 or 40 bitaccumulator?>or is this with full precision floating-point?This is a 16-bit filter with 32 bit accumulator.>have you tried it both ways: same input signal and same coefficients but >different word widths/formats? if it behaves with the floating-pointand>not with the fixed-point, then, i guess, at least we know it's anumerical>problem.I have not come across any problems with the floating point implementation. The first order noise shaping does help for some settings of the EQ. But, everything remaining same, just changing the gains of the bands throws my system into instability. Specifically, the BASS band.>-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >I was even wondering whether having a very low freq. band at a high sampling rate is creating any ringing? My bands are with center frequencies 100 , 300, 1000, 3000 and 10000 Hz. And, if these sound wrong, can you suggest any specifications for a 5-band eq.?? ~ R K
Reply by ●February 16, 20062006-02-16
in article GaqdnTAzoZb3k2nenZ2dnUVZ_v6dnZ2d@giganews.com, rkthebad at raviyenduri@gmail.com wrote on 02/16/2006 00:32:> I have not come across any problems with the floating pointimplementation.> The first order noise shaping does help for some settingsof the EQ. But,> everything remaining same, just changing the gains of thebands throws my> system into instability. Specifically, the BASS band.i guess i would suggest comparing the fixed-point coefficients to their floating-point counterparts for filters given identical parameters. see if coefficient rounding or truncation is giving you trouble. the poles will be at: p1 = -a1/2 + sqrt((a1/2)^2 - a2) p2 = -a1/2 - sqrt((a1/2)^2 - a2) if a1/2)^2 < a2, then you have to factor a -1 out of the inside of the square root and you get complex conjugate poles: p1 = -a1/2 + j*sqrt(a2 - (a1/2)^2) p2 = -a1/2 - j*sqrt(a2 - (a1/2)^2) then you need to make sure that the poles have magnitude less than 1 for stability. in the later (complex conj) case: |p1| = |p2| = sqrt(a2) in the former case (real poles) max{|p1|, |p2|} = |a1/2| + sqrt((a1/2)^2 - a2) so to put the two together, to insure stability 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 2. if (a1/2)^2 < a2 then a2 < 1 using your *quantized* coefficients, you must check to see that whichever criteria 1. or 2. (whichever condition applies) is satisfied. it the criterion that is applicable is not satisfied, you cannot expect stability. now, i am convinced that the cookbook equations result in stable filters at least until there is coefficient quantization, and after quantization i am not so sure. and 16 bit quantization is pretty severe. ...> I was even wondering whether having a very low freq. band at a highsampling> rate is creating any ringing? My bands are with centerfrequencies 100 , 300,> 1000, 3000 and 10000 Hz.because cos(w0) gets so close to 1 for 0 < w0 << pi (Nyquist), the low bands might be the worst problem from a numerical POV. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●February 16, 20062006-02-16
>in article GaqdnTAzoZb3k2nenZ2dnUVZ_v6dnZ2d@giganews.com, rkthebad at >raviyenduri@gmail.com wrote on 02/16/2006 00:32: > >> I have not come across any problems with the floating point >implementation. >> The first order noise shaping does help for some settings >of the EQ. But, >> everything remaining same, just changing the gains of the >bands throws my >> system into instability. Specifically, the BASS band. > >i guess i would suggest comparing the fixed-point coefficients to their >floating-point counterparts for filters given identical parameters. seeif>coefficient rounding or truncation is giving you trouble. the poles willbe>at: > > p1 = -a1/2 + sqrt((a1/2)^2 - a2) > p2 = -a1/2 - sqrt((a1/2)^2 - a2) > >if a1/2)^2 < a2, then you have to factor a -1 out of the inside of the >square root and you get complex conjugate poles: > > p1 = -a1/2 + j*sqrt(a2 - (a1/2)^2) > p2 = -a1/2 - j*sqrt(a2 - (a1/2)^2) > >then you need to make sure that the poles have magnitude less than 1 for >stability. in the later (complex conj) case: > > |p1| = |p2| = sqrt(a2) > >in the former case (real poles) > > max{|p1|, |p2|} = |a1/2| + sqrt((a1/2)^2 - a2) > >so to put the two together, to insure stability > > 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 > > 2. if (a1/2)^2 < a2 then a2 < 1 > >using your *quantized* coefficients, you must check to see thatwhichever>criteria 1. or 2. (whichever condition applies) is satisfied. it the >criterion that is applicable is not satisfied, you cannot expectstability.> >now, i am convinced that the cookbook equations result in stable filtersat>least until there is coefficient quantization, and after quantization iam>not so sure. and 16 bit quantization is pretty severe. > > >... >> I was even wondering whether having a very low freq. band at a high >sampling >> rate is creating any ringing? My bands are with center >frequencies 100 , 300, >> 1000, 3000 and 10000 Hz. > >because cos(w0) gets so close to 1 for 0 < w0 << pi (Nyquist), the lowbands>might be the worst problem from a numerical POV. > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >Apart from the conditions that you mentioned above, I found one more stability condition in a textbook. Condition is : |a2| < 1 and |a1| < |1 + a2. I did not venture too much into the math, but I am guessing your conditions might come down to this after simplification. But, wouldn't it be sufficient to see whether the poles of the quantized filter are inside the unit circle? ~ R K
Reply by ●February 16, 20062006-02-16
>>in article GaqdnTAzoZb3k2nenZ2dnUVZ_v6dnZ2d@giganews.com, rkthebad at >>raviyenduri@gmail.com wrote on 02/16/2006 00:32: >> >>> I have not come across any problems with the floating point >>implementation. >>> The first order noise shaping does help for some settings >>of the EQ. But, >>> everything remaining same, just changing the gains of the >>bands throws my >>> system into instability. Specifically, the BASS band. >> >>i guess i would suggest comparing the fixed-point coefficients to their >>floating-point counterparts for filters given identical parameters.see>if >>coefficient rounding or truncation is giving you trouble. the poleswill>be >>at: >> >> p1 = -a1/2 + sqrt((a1/2)^2 - a2) >> p2 = -a1/2 - sqrt((a1/2)^2 - a2) >> >>if a1/2)^2 < a2, then you have to factor a -1 out of the inside of the >>square root and you get complex conjugate poles: >> >> p1 = -a1/2 + j*sqrt(a2 - (a1/2)^2) >> p2 = -a1/2 - j*sqrt(a2 - (a1/2)^2) >> >>then you need to make sure that the poles have magnitude less than 1for>>stability. in the later (complex conj) case: >> >> |p1| = |p2| = sqrt(a2) >> >>in the former case (real poles) >> >> max{|p1|, |p2|} = |a1/2| + sqrt((a1/2)^2 - a2) >> >>so to put the two together, to insure stability >> >> 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 >> >> 2. if (a1/2)^2 < a2 then a2 < 1 >> >>using your *quantized* coefficients, you must check to see that >whichever >>criteria 1. or 2. (whichever condition applies) is satisfied. it the >>criterion that is applicable is not satisfied, you cannot expect >stability. >> >>now, i am convinced that the cookbook equations result in stablefilters>at >>least until there is coefficient quantization, and after quantization i >am >>not so sure. and 16 bit quantization is pretty severe. >> >> >>... >>> I was even wondering whether having a very low freq. band at a high >>sampling >>> rate is creating any ringing? My bands are with center >>frequencies 100 , 300, >>> 1000, 3000 and 10000 Hz. >> >>because cos(w0) gets so close to 1 for 0 < w0 << pi (Nyquist), the low >bands >>might be the worst problem from a numerical POV. >> >>-- >> >>r b-j rbj@audioimagination.com >> >>"Imagination is more important than knowledge." >> >> >> > >Apart from the conditions that you mentioned above, I found one more >stability condition in a textbook. >Condition is : |a2| < 1 and |a1| < 1 + a2. >I did not venture too much into the math, but I am guessing your >conditions might come down to this after simplification. > >But, wouldn't it be sufficient to see whether the poles of the quantized >filter are inside the unit circle? > >~ R K >Typo in my previous post. Condition is : |a2| < 1 and |a1| < 1 + a2. Also, when I compare the spectrum of the filter before and after quantization, I see a considerable change in the spectrum of the first two bands as the sampling frequency increases. This was *practically" eliminated if I had the flexibility to use 32 bit coefficients. Looking at the spectrum, I also notice that when I apply a boost of 12 dB on my first band, I do not see the required boost. I can see a boost of only 9 dB. The same is the case with the second band. Upon decreasing the Q, I could see the 12 dB increase. Why is this so? ~ R K
Reply by ●February 16, 20062006-02-16
rkthebad wrote:> > Apart from the conditions that you mentioned above, I found one more > stability condition in a textbook. > Condition is : |a2| < 1 and |a1| < 1 + a2. > I did not venture too much into the math, but I am guessing your > conditions might come down to this after simplification.the second one looks different, but the first is the same. whatever, i am convinced that the criteria i stated: 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 2. if (a1/2)^2 < a2 then a2 < 1 is both necessary and sufficient. if it's case 1. then sqrt((a1/2)^2 - a2) < 1 - |a1/2| (a1/2)^2 - a2 < (1 - |a1/2|)^2 = 1 - |a1| + (a1/2)^2 which comes to |a1| < 1 + a2 so you're right, it's the same thing (except, it's a "either or" not *both*). thanks for pointing that out.> But, wouldn't it be sufficient to see whether the poles of the quantized > filter are inside the unit circle?that's precisely what i was doing. take a look at the math, that is all that it is. r b-j
Reply by ●February 17, 20062006-02-17
> >rkthebad wrote: > >> >> Apart from the conditions that you mentioned above, I found one more >> stability condition in a textbook. >> Condition is : |a2| < 1 and |a1| < 1 + a2. >> I did not venture too much into the math, but I am guessing your >> conditions might come down to this after simplification. > >the second one looks different, but the first is the same. > >whatever, i am convinced that the criteria i stated: > > 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 > > 2. if (a1/2)^2 < a2 then a2 < 1 > >is both necessary and sufficient. > >if it's case 1. then > > sqrt((a1/2)^2 - a2) < 1 - |a1/2| > > (a1/2)^2 - a2 < (1 - |a1/2|)^2 = 1 - |a1| + (a1/2)^2 > >which comes to > > |a1| < 1 + a2 > >so you're right, it's the same thing (except, it's a "either or" not >*both*). thanks for pointing that out. > >> But, wouldn't it be sufficient to see whether the poles of thequantized>> filter are inside the unit circle? > >that's precisely what i was doing. take a look at the math, that is >all that it is. > >r b-j > >Here is one strange thing that I observed. Can anyone explain why? I am trying to see the actual response of the designed 5-band equalizer. I put a gain of +12 dB for all the bands. Then I vary the sampling frequency of the system. It is observed that at a sampling freq. of 48 kHz, the first band (with fc = 300 Hz) does not show a gain of +12 dB. Instead, it only shows a gain of +9 dB. Why is this so? Thanks, ~ R K
Reply by ●February 17, 20062006-02-17
"rkthebad" <raviyenduri@gmail.com> wrote in news:J8KdncyPSKDCkGveRVn-ug@giganews.com:>> >>rkthebad wrote: >> >>> >>> Apart from the conditions that you mentioned above, I found one more >>> stability condition in a textbook. >>> Condition is : |a2| < 1 and |a1| < 1 + a2. >>> I did not venture too much into the math, but I am guessing your >>> conditions might come down to this after simplification. >> >>the second one looks different, but the first is the same. >> >>whatever, i am convinced that the criteria i stated: >> >> 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 >> >> 2. if (a1/2)^2 < a2 then a2 < 1 >> >>is both necessary and sufficient. >> >>if it's case 1. then >> >> sqrt((a1/2)^2 - a2) < 1 - |a1/2| >> >> (a1/2)^2 - a2 < (1 - |a1/2|)^2 = 1 - |a1| + (a1/2)^2 >> >>which comes to >> >> |a1| < 1 + a2 >> >>so you're right, it's the same thing (except, it's a "either or" not >>*both*). thanks for pointing that out. >> >>> But, wouldn't it be sufficient to see whether the poles of the > quantized >>> filter are inside the unit circle? >> >>that's precisely what i was doing. take a look at the math, that is >>all that it is. >> >>r b-j >> >> > Here is one strange thing that I observed. Can anyone explain why? > > I am trying to see the actual response of the designed 5-band > equalizer. I put a gain of +12 dB for all the bands. Then I vary the > sampling frequency of the system. It is observed that at a sampling > freq. of 48 kHz, the first band (with fc = 300 Hz) does not show a > gain of +12 dB. Instead, it only shows a gain of +9 dB. Why is this > so? > > Thanks, > ~ R K > >I think you are a victim of 16 bit precision. The low frequency bands with high Q are the first place where the problem is likely to occur. This kind of problem illustrates why the Motorola 56K (24 bits) and later the SHARC (32 bits) became so popular in high performance audio. I think you already found improvements by changing filter topology (DFI vs DF2). If you have enough MIPs, you can rewrite the algorithm with double precision math with your 16 bit processor or move to a higher precision processor. -- Al Clark Danville Signal Processing, Inc. -------------------------------------------------------------------- Purveyors of Fine DSP Hardware and other Cool Stuff Available at http://www.danvillesignal.com
Reply by ●February 17, 20062006-02-17
>"rkthebad" <raviyenduri@gmail.com> wrote in >news:J8KdncyPSKDCkGveRVn-ug@giganews.com: > >>> >>>rkthebad wrote: >>> >>>> >>>> Apart from the conditions that you mentioned above, I found one more >>>> stability condition in a textbook. >>>> Condition is : |a2| < 1 and |a1| < 1 + a2. >>>> I did not venture too much into the math, but I am guessing your >>>> conditions might come down to this after simplification. >>> >>>the second one looks different, but the first is the same. >>> >>>whatever, i am convinced that the criteria i stated: >>> >>> 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 >>> >>> 2. if (a1/2)^2 < a2 then a2 < 1 >>> >>>is both necessary and sufficient. >>> >>>if it's case 1. then >>> >>> sqrt((a1/2)^2 - a2) < 1 - |a1/2| >>> >>> (a1/2)^2 - a2 < (1 - |a1/2|)^2 = 1 - |a1| + (a1/2)^2 >>> >>>which comes to >>> >>> |a1| < 1 + a2 >>> >>>so you're right, it's the same thing (except, it's a "either or" not >>>*both*). thanks for pointing that out. >>> >>>> But, wouldn't it be sufficient to see whether the poles of the >> quantized >>>> filter are inside the unit circle? >>> >>>that's precisely what i was doing. take a look at the math, that is >>>all that it is. >>> >>>r b-j >>> >>> >> Here is one strange thing that I observed. Can anyone explain why? >> >> I am trying to see the actual response of the designed 5-band >> equalizer. I put a gain of +12 dB for all the bands. Then I vary the >> sampling frequency of the system. It is observed that at a sampling >> freq. of 48 kHz, the first band (with fc = 300 Hz) does not show a >> gain of +12 dB. Instead, it only shows a gain of +9 dB. Why is this >> so? >> >> Thanks, >> ~ R K >> >> > >I think you are a victim of 16 bit precision. The low frequency bands >with high Q are the first place where the problem is likely to occur. > >This kind of problem illustrates why the Motorola 56K (24 bits) and later>the SHARC (32 bits) became so popular in high performance audio. > >I think you already found improvements by changing filter topology (DFI >vs DF2). If you have enough MIPs, you can rewrite the algorithm with >double precision math with your 16 bit processor or move to a higher >precision processor. > > > > > >-- >Al Clark >Danville Signal Processing, Inc. >-------------------------------------------------------------------- >Purveyors of Fine DSP Hardware and other Cool Stuff >Available at http://www.danvillesignal.com >Al, You are right. Because of the 16-bit quantization, I am losing precision compared to the floating point architecture. But, the above mentioned problem, I am experiencing even in the floating point implementation. The problem is the same when I tried to compute my coefficients using MATLAB or Microsoft VC++. Is 48 kHz tooo high a sampling freq. compared to the 300 Hz band? Thanks, ~ R K
Reply by ●February 17, 20062006-02-17
>>"rkthebad" <raviyenduri@gmail.com> wrote in >>news:J8KdncyPSKDCkGveRVn-ug@giganews.com: >> >>>> >>>>rkthebad wrote: >>>> >>>>> >>>>> Apart from the conditions that you mentioned above, I found onemore>>>>> stability condition in a textbook. >>>>> Condition is : |a2| < 1 and |a1| < 1 + a2. >>>>> I did not venture too much into the math, but I am guessing your >>>>> conditions might come down to this after simplification. >>>> >>>>the second one looks different, but the first is the same. >>>> >>>>whatever, i am convinced that the criteria i stated: >>>> >>>> 1. if (a1/2)^2 >= a2 then |a1/2| + sqrt((a1/2)^2 - a2) < 1 >>>> >>>> 2. if (a1/2)^2 < a2 then a2 < 1 >>>> >>>>is both necessary and sufficient. >>>> >>>>if it's case 1. then >>>> >>>> sqrt((a1/2)^2 - a2) < 1 - |a1/2| >>>> >>>> (a1/2)^2 - a2 < (1 - |a1/2|)^2 = 1 - |a1| + (a1/2)^2 >>>> >>>>which comes to >>>> >>>> |a1| < 1 + a2 >>>> >>>>so you're right, it's the same thing (except, it's a "either or" not >>>>*both*). thanks for pointing that out. >>>> >>>>> But, wouldn't it be sufficient to see whether the poles of the >>> quantized >>>>> filter are inside the unit circle? >>>> >>>>that's precisely what i was doing. take a look at the math, that is >>>>all that it is. >>>> >>>>r b-j >>>> >>>> >>> Here is one strange thing that I observed. Can anyone explain why? >>> >>> I am trying to see the actual response of the designed 5-band >>> equalizer. I put a gain of +12 dB for all the bands. Then I vary the >>> sampling frequency of the system. It is observed that at a sampling >>> freq. of 48 kHz, the first band (with fc = 300 Hz) does not show a >>> gain of +12 dB. Instead, it only shows a gain of +9 dB. Why is this >>> so? >>> >>> Thanks, >>> ~ R K >>> >>> >> >>I think you are a victim of 16 bit precision. The low frequency bands >>with high Q are the first place where the problem is likely to occur. >> >>This kind of problem illustrates why the Motorola 56K (24 bits) andlater> >>the SHARC (32 bits) became so popular in high performance audio. >> >>I think you already found improvements by changing filter topology (DFI>>vs DF2). If you have enough MIPs, you can rewrite the algorithm with >>double precision math with your 16 bit processor or move to a higher >>precision processor. >> >> >> >> >> >>-- >>Al Clark >>Danville Signal Processing, Inc. >>-------------------------------------------------------------------- >>Purveyors of Fine DSP Hardware and other Cool Stuff >>Available at http://www.danvillesignal.com >> >Al, > You are right. Because of the 16-bit quantization, I am losingprecision>compared to the floating point architecture. But, the above mentioned >problem, I am experiencing even in the floating point implementation.The>problem is the same when I tried to compute my coefficients using MATLAB >or Microsoft VC++. Is 48 kHz tooo high a sampling freq. compared to the >300 Hz band? > >Thanks, >~ R K > >Everyone, I am able to get a *decent* output through my 5-band equalizer. But, I am sacrificing the bass content till 500 Hz. Now, I know for sure that there is serious problem with a high sampling frequency and my first band (if below 500 Hz). I would have to find a way around this. Any suggestions will be definitely helpful. Thanks to everyone. ~ R K