Digital BIQUAD filter calculations
TC
Posts: 1,019
in Propeller 1
Hello all,
I am building my own bluetooth headphones. I am currently working on the DSP for a 5 band EQ. I was going to make a database for the biquad coefficients. Then just look up the coefficient value. But I then realized the amount of data that would be. I am going with the tlv320aic3268 from Texas Instruments. Each coefficient is 24bits wide, and each BIQUAD need 5 coefficients. That would be 5 longs for each band of the EQ (assuming left and right use same values).
5 longs * 5 bands = 25 longs
That's not a big deal, but I want to have the option to change the gain of each EQ band from +12db to -12db, in 0.1db steps. That is about 240(ish) steps.
5 coefficients (24bits each) * 5 bands * 240 steps = 6000 longs
That's a lot of data. So I thought, maybe the Prop can do the coefficient calculations on the fly. I just put in the EQ frequency, the "Q", and the gain, and the Prop could perform the calculation, and load the coefficients. I found papers that explains the biquad calculations (EQ cookbook), and one the gives Matlab equations (Texas). But when I do the equations in excel, I get incorrect results. I am using Texas's coefficients calculator to verify my results.
I am wondering if anyone would have some advice, or if anyone would be able to help me make the prop do coefficient calculations on the fly.
Thanks
TC
I am building my own bluetooth headphones. I am currently working on the DSP for a 5 band EQ. I was going to make a database for the biquad coefficients. Then just look up the coefficient value. But I then realized the amount of data that would be. I am going with the tlv320aic3268 from Texas Instruments. Each coefficient is 24bits wide, and each BIQUAD need 5 coefficients. That would be 5 longs for each band of the EQ (assuming left and right use same values).
5 longs * 5 bands = 25 longs
That's not a big deal, but I want to have the option to change the gain of each EQ band from +12db to -12db, in 0.1db steps. That is about 240(ish) steps.
5 coefficients (24bits each) * 5 bands * 240 steps = 6000 longs
That's a lot of data. So I thought, maybe the Prop can do the coefficient calculations on the fly. I just put in the EQ frequency, the "Q", and the gain, and the Prop could perform the calculation, and load the coefficients. I found papers that explains the biquad calculations (EQ cookbook), and one the gives Matlab equations (Texas). But when I do the equations in excel, I get incorrect results. I am using Texas's coefficients calculator to verify my results.
I am wondering if anyone would have some advice, or if anyone would be able to help me make the prop do coefficient calculations on the fly.
Thanks
TC
Comments
I made a LPF biquad filter calculator code for the prop. This is just to see if I can get the same values as the Texas Instruments biquad calculator. The values I am getting are a little off from what the texas calculator is giving me. Could someone please take a look at it? I might of missed something, or I have something wrong.
user define values:
Low Pass Filter
sample freq = 48000 Hz
cutoff freq = 600 Hz
Q = 0.707
Values from Texas calculator
N0 = $002FD9
N1 = $002FD9
N2 = $002FD9
D1 = $78E5AB
D2 = $8D7541
Values from prop
N0 = $002FC0
N1 = $002FC0
N2 = $002FC0
D1 = $78E5D1
D2 = $8D755D
Thanks
TC
I was wondering about the precision of the prop. The only main reason i didn't want to do a table of the values is because I am lazy. But I don't think I really have any real options. At least doing a table would make sure the correct values would be loaded.
I tried this in PropGCC and it worked fine; there are some 1 bit differences from the TI calculator, but the PropGCC values agreed with what I got on my PC. On the Prop I tried with both 32 bit and 64 bit doubles, and got the same results in both cases; 32 bit doubles are a lot faster, so that would be the sensible choice. The code is pretty big though (due to printf) so you'll definitely want to use CMM mode.
values from PropGCC
N0 = $002fda
N1 = $002fda
N2 = $002fda
D1 = $78e5ab
D2 = $8d7541
Thank you ersmith. I never learned trig in school, and I am learning as I go. It makes me feel better knowing that the problem is not with my code, only the library I am using.
I'm going to do what Peter suggested, use ersmith's code and load a eeprom with the values. That would be a lot easier than me hand typing all the values.
Thank you so much for the help.
TC