
Home  Forums  Rules  Articles  The diyAudio Store  Gallery  Blogs  Register  Donations  FAQ  Calendar  Search  Today's Posts  Mark Forums Read  Search 
Digital Source Digital Players and Recorders: CD , SACD , Tape, Memory Card, etc. 

Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving 

Thread Tools  Search this Thread 
15th June 2006, 07:44 PM  #1 
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

DIY Digital Parametric EQ
I have found mention of a few projects using TI's TAS3xxx series audio DSPs here, but none that implement an actual fully parametric EQ. I am thinking a multiband EQ with frequency, Q, and gain for each filter all adjustable onthefly.
Typically, the filter coefficients for these DSPs are calculated using an offline tool like MATLAB, or the filterbuilder tool from TI, based on a previously determined desired filter response. But that doesn't allow the filter response to be changed at will. That would of course require a user interface (input controls and a display) but more importantly, it would require a method of calculating the biquad filter coefficients in real time, from those 3 familar parameters: frequency, Q, and gain. Of course the real trick to such a system is calculating those coefficients. Though the math itself isn't terribly complicated, implementing it on an 8bit microcontroller is not trivial. It requires 32bit floating point math including multiply, divide, add, subtract, log, exponential, sine and cosine. All of these operations are possible to do on an 8bit microcontroller, and various code libraries are freely available on the 'net. And of course you also need the equations to calculate the biquad coefficients. And you need an algorithm to convert the floating point results into the fixedpoint format used by the DSPs. And... you get the idea. There is a lot of work involved in converting a twist of a rotary encoder into a new filter with the corresponding response. And, it all must happen quickly enough that it seems instantaneous to the user, otherwise the EQ cannot be adjusted "by ear". I am currently building a prototype consisting of a PIC microcontroller, an LCD, a few pushbuttons, and a TAS3004 DSP, which was chosen for ease of prototyping rather than for audio quality. I plan to build a final version with TAS3103's for use in my hifi system. I estimate that required cacluations can be performed in a few ms, plenty fast enough. Of course there is no reason to limit oneself to EQ filters; a biquad can emulate virtually any analog filter: low pass, high pass, bandpass, shelving, notch (bandstop), EQ, allpass (phase change only). This broadens the possible applications to include adjustable digital crossovers and speaker correction systems. Even the rather complicated Linkwitz Orion crossover/EQ could be 100% implemented digitally (including the allpass phase correction sections) with excellent accuracy. If anyone else has built such a project, or is interested in such a project, or interested in the math involved, or any other part of the implementation, join the discussion... 
21st June 2006, 03:56 AM  #2 
diyAudio Member
Join Date: Dec 2004
Location: Reston, Virginia

TAS3004 spreadsheet
Apogee has an app note that provides all of the filter equations. TI's filterbuilder has the floating point to hex conversions. I put together these pieces in the spreadsheet at this link: http://neilrdavis.home.comcast.net/P...erbuilder.xls.
You will need to have the analysis toolpak and the analysis VBA toolpak addins. Doing the math in a PC is easy, but for a micro you will want to load precalculated coefficients 
21st June 2006, 06:18 AM  #3 
diyAudio Member
Join Date: Jan 2002
Location: The Netherlands

Hello Neil,
Interesting ! Unfortunatly parts of your site can not be found. grtz Simon 
21st June 2006, 01:35 PM  #4 
diyAudio Member
Join Date: Dec 2004
Location: Reston, Virginia

URL fix
remove the "dot" that is after xls in the link

21st June 2006, 03:49 PM  #5  
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

Re: TAS3004 spreadsheet
Quote:
Apogee's calculations for a EQ filter are very different than mine. Theirs are much simpler in that they do not use any trig math (sin/cos/tan) and they are the same for both boost and cut. Mine use cos() and tan() and there is a difference between boost and cut. They don't say what method they used to derive their equations, but they seem to be using a few assumptions and approximations to make the calculations simpler. I just plugged the Apogee equations into my spreadsheet to compare the response curves. At low frequencies, the boost curve is similar to mine, but the cut curve is very different. The cut (using the Apogee method) is highly assymetric to the boost. As the amount of cut is increased, the filter becomes narrower and narrower, so the Q is not accurate any longer. Also as the frequency approaches Nyquist (fs/2) there is a significant amount of frequency error introduced. For example, a filter at 20 kHz (with 48 kHz fs) will actually be centered at 13.9 kHz! My equations will result in accurate frequencies (however the shape of the filter's 'bell' is distorted at very high frequencies due to this effect... this is unavoidable). My equations are: b0 = 1+((1+alpha)*H/2) b1 = d*(1alpha) b2 = (alpha((1+alpha)*H/2)) a0 = 1 a1 = b1 a2 = alpha where: alpha = (tan(wc/2)Gf)/(tan(wc/2)+Gf) for Gf<1, OR alpha = (tan(wc/2)1)/(tan(wc/2)+1) for Gf>=1 H = Gf1 d = cos(wc) Gf = 10^(G/20) (Gain Factor, linear) wc = 2*Pi*fc/fs G is gain of filter in dB fc is center frequency of filter fs is sampling frequency Q is filter Q (quality) factor The trig functions are necessary to compensate for the frequency distortion which occurs as fc approaches Nyquist. Feel free to plug the above into your spreadsheet to compare the magnitude response to that derived using Apogee's method. You will see that when playing with gain and frequency using my method, you get what you expect, but using Apogee's method, you can get some strange results. The float to hex conversions in Ti's filterbuilder actually convert a decimal number to the Hex format needed. It does not operate on hexadecimal floating point data directly, and so is not suitable for use on the micro. A more suitable algorithm is required, and I have devised one. 

21st June 2006, 04:38 PM  #6 
diyAudio Member
Join Date: Oct 2001
Location: .

Why prototype using a PIC when the '3103A has an onboard 8051?

21st June 2006, 05:45 PM  #7 
diyAudio Member
Join Date: Dec 2004
Location: Reston, Virginia

Then I don't understand what you are trying to do. The coefficients MUST be calculated using at least 32bit arithmetic, and if you have that capability why bother using a TAS3004? Just upgrade the processor to a DSP processor and do the biquads in realtime in the DSP. I don't understand why you want to do complex math in a microcontroller.
There is a more complete version of that spreadsheet that generates the EEPROM file for the TAS3004, and I'm trying to finish off the version that writes directly to the I2C bus from the parallel port (requires a small board on the parallel port, which I have). After that, I will work on a USB version. With the USB version, you could implement the GUI and coefficient calculation in the PC and interact with the TAS3004/microcontroller via USB. There are some discussions to make the USB/microcontroller/TAS3004 into a lowbudget digital crossover product, but nothing concrete yet. 
21st June 2006, 06:32 PM  #8 
diyAudio Member
Join Date: Jun 2006

Totally agree with Neil Davis no need to use that microcontroller would be a lot smarter to upgrade to a DSP chip.

21st June 2006, 09:50 PM  #9  
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

Quote:
Quote:
Quote:
Quote:
Quote:
Quote:


21st June 2006, 09:53 PM  #10  
diyAudio Member
Join Date: Oct 2003
Location: Ottawa, Canada

Quote:


Thread Tools  Search this Thread 


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Parametric Schematic  punchpeanut  Parts  11  7th March 2011 01:04 AM 
semi parametric eq  reap461  Parts  5  4th December 2008 09:56 PM 
Parametric Q Calculationhelp, please  tocs100  MultiWay  3  2nd January 2006 01:21 PM 
parametric equalizers  stupid m0nkey  Everything Else  7  16th February 2005 05:49 AM 
Parametric EQ as mox sidekick  JensRasmussen  Solid State  16  13th September 2004 10:58 PM 
New To Site?  Need Help? 