DIY Digital Parametric EQ - diyAudio
Go Back   Home > Forums > Source & Line > Digital Source

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
Reply
 
Thread Tools Search this Thread
Old 15th June 2006, 06:44 PM   #1
macboy is offline macboy  Canada
diyAudio Member
 
Join Date: Oct 2003
Location: Ottawa, Canada
Default 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 multi-band EQ with frequency, Q, and gain for each filter all adjustable on-the-fly.

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 bi-quad 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 8-bit microcontroller is not trivial. It requires 32-bit floating point math including multiply, divide, add, subtract, log, exponential, sine and cosine. All of these operations are possible to do on an 8-bit 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 fixed-point 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 hi-fi 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 bi-quad 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 all-pass 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...
  Reply With Quote
Old 21st June 2006, 02:56 AM   #2
diyAudio Member
 
Join Date: Dec 2004
Location: Reston, Virginia
Default 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 add-ins.

Doing the math in a PC is easy, but for a micro you will want to load precalculated coefficients
  Reply With Quote
Old 21st June 2006, 05:18 AM   #3
diyAudio Member
 
blu_line's Avatar
 
Join Date: Jan 2002
Location: The Netherlands
Hello Neil,

Interesting !
Unfortunatly parts of your site can not be found.

grtz

Simon
  Reply With Quote
Old 21st June 2006, 12:35 PM   #4
diyAudio Member
 
Join Date: Dec 2004
Location: Reston, Virginia
Default URL fix

remove the "dot" that is after xls in the link
  Reply With Quote
Old 21st June 2006, 02:49 PM   #5
macboy is offline macboy  Canada
diyAudio Member
 
Join Date: Oct 2003
Location: Ottawa, Canada
Default Re: TAS3004 spreadsheet

Quote:
Originally posted by Neil Davis
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...verbuilder.xls

You will need to have the analysis toolpak and the analysis VBA toolpak add-ins.

Doing the math in a PC is easy, but for a micro you will want to load precalculated coefficients
Thanks. I already have the filter coefficient equations in a spiffy spreadsheet complete with a amplitude vs. frequency plot for the filters. And as I had said, the math isn't terribly complicated, but doing it on a micro is not easy. I firmly believe however that it can (and must) be done, in real time. I am not at all interested in loading precalculated coefficients, mostly because that would limit the range of values that could be used for Fc and Q. I want this to be truly parametric, with frequency and Q adjustable in a fine granularity. I will have frequency adjustable to within 1% and at least 20 values for Q. Storing pre-canned coefficients for that many combinations would be impossible, and I also do not want to do interpolations, which results in inaccurate filters.

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*(1-alpha)
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 = Gf-1
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.
  Reply With Quote
Old 21st June 2006, 03:38 PM   #6
diyAudio Member
 
Join Date: Oct 2001
Location: .
Why prototype using a PIC when the '3103A has an onboard 8051?
  Reply With Quote
Old 21st June 2006, 04: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 32-bit 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 real-time 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 low-budget digital crossover product, but nothing concrete yet.
  Reply With Quote
Old 21st June 2006, 05: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.
  Reply With Quote
Old 21st June 2006, 08:50 PM   #9
macboy is offline macboy  Canada
diyAudio Member
 
Join Date: Oct 2003
Location: Ottawa, Canada
Quote:
Originally posted by Neil Davis
Then I don't understand what you are trying to do. The coefficients MUST be calculated using at least 32-bit arithmetic, and if you have that capability why bother using a TAS3004? ...
I fail to see your point. Are you suggesting that if I am able to calculate the coefficients on processor X then I should be able to do the DSP on processor X as well, and skip the TAS? Then you really don't understand what I am trying to do. I am trying to make a system to control the TAS chip in a useful way, rather than just loading a preset EQ set.

Quote:
... Just upgrade the processor to a DSP processor and do the biquads in real-time in the DSP. I don't understand why you want to do complex math in a microcontroller...
Part of the reason is, because it is a challenge (but frankly not that big of one). Part of the reason is, because I do not need to, nor do I want to implement something as simple as an EQ on a general purpose DSP, which is way overkill for that application. The final device will be based on the TAS3103 which maintains 48 bits of resolution for samples, and has a 72 bit accumulator. That kind of accuracy is not readily available on inexpensive general purpose DSP chips. Besides, I already know for fact that I can calculate the Biquad coefficients on the PIC in real time (on the order of milliseconds) so switching to a DSP for that task is entirely unecessary.

Quote:
...There is a more complete version of that spreadsheet that generates the EEPROM file for the TAS3004,...
Useless for two reasons: 1. The '3004 is for prototyping only and will be trashed in favour of a TAS3103, and 2. A static coefficient set is not what I want. I want a realtime user-adjustable parametric EQ.

Quote:
...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...
That all still requires a PC. Again it is outside the scope of what I am trying to accompish.

Quote:
...There are some discussions to make the USB/microcontroller/TAS3004 into a low-budget digital crossover product, but nothing concrete yet.
Well perhaps the PC/USB part of that will become unecessary soon.


Quote:
Originally posted by excetara2
Totally agree with Neil Davis no need to use that microcontroller would be a lot smarter to upgrade to a DSP chip.
Define "smarter". Would it be "smarter" to go out and spend hundreds of dollars (at least) on development tools for general purpose DSPs? To learn new development environments and languages? To write all the DSP code necessary to perform the necessary filters and other functions which are "free" on the TAS3xxx (only need to load coefficients... no code whatsoever). As an engineer, I find it offensive when people think that they can solve a problem "better" or "smarter" by throwing more powerful hardware at the problem. A smarter solution is always less complex, and less costly, not more.
  Reply With Quote
Old 21st June 2006, 08:53 PM   #10
macboy is offline macboy  Canada
diyAudio Member
 
Join Date: Oct 2003
Location: Ottawa, Canada
Quote:
Originally posted by rfbrw
Why prototype using a PIC when the '3103A has an onboard 8051?
The internal micro is used to control various functions inside the DSP. It is not reprogrammable or in any way accessible to the end user. The DSP must be interfaced to another device to load up the coefficients and other operating parameters via the I2C bus.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parametric Schematic punchpeanut Parts 11 7th March 2011 12:04 AM
semi parametric eq reap461 Parts 5 4th December 2008 08:56 PM
Parametric Q Calculation--help, please tocs100 Multi-Way 3 2nd January 2006 12:21 PM
parametric equalizers stupid m0nkey Everything Else 7 16th February 2005 04:49 AM
Parametric EQ as mox sidekick JensRasmussen Solid State 16 13th September 2004 09:58 PM


New To Site? Need Help?

All times are GMT. The time now is 10:32 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2