DIY Digital Parametric EQ

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
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...
 
Member
Joined 2004
Paid Member
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/Plate_amps/crossoverbuilder.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
 
Re: TAS3004 spreadsheet

Neil Davis said:
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/Plate_amps/crossoverbuilder.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.
 
Member
Joined 2004
Paid Member
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.
 
Neil Davis said:
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.

... 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.

...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.

...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.

...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.


excetara2 said:
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.
 
rfbrw said:
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.
 
I've been following this thread with interest, have been toying with the idea of trying these TAS3xxx chips myself - after all you can develop your s/w on something as simple as a PIC and don't have to outlay $100s on DSP eval boards with licenses locked to that board - can't give it away to friends then build another!

Just out of interest, it looks like TI have another audio processor in the TASxxxx family about to be released:

Download their "Performance Audio Quick Reference Guide 2Q 2006" (slyb122.pdf) and look on page 2 for the TAS3108.

Still unreleased, but the specs are 8 channels, 25 biquads per channel, and TSSOP-38 package (small but usable for prototyping - not BGA!!)

I'll give my TI rep a call tomorrow and try to get some more info on this beast, and when it's likely to be released. If this is truly an 8 channel device then that's a complete crossover on a chip! Hopefully they've included some delay memory as I want to time-align some horns - but hey one thing at a time.

Would be great to have a digital xover design done here, we have some very clever people contributing. Anyway it's late, will post again when I've heard back from TI.

regards,

Len.
 
Member
Joined 2004
Paid Member
macboy said:
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.

You're right--I didn't quite understand what you were trying to do, and it just looked odd to be doing all of that complex arithmetic in a PIC. I assumed that it required a fairly large amount of memory and development tools to get the precision that was needed, so it seemed to make more sense to just run some simple biquad code in one of the new low-cost DSP's. But that freeware code for 32-bit floating point looks promising--if you can use it to calculate the coefficients then it looks like a good way to use the power of these biquad chips.

That math precision is important. For low frequency 2-pole filters, the A2 coefficient is very close to "1", with values like .9999x. A2 < 1 is a stability criterion, so roundoff errors can be a problem.

The spreadsheet that I posted includes a math model of the TAS3004, but it can be adapted to model a TAS3103 or the AD1954 (which is a nice chip!). It also lets you ingest loudspeaker measurements (FRD or Laud) and view the results of the various filter types in building a crossover or doing EQ on a system. So it may help you in setting up your equalizer by visualizing the results, or help in verifying your design. I pointed out these features of the spreadsheet because your original post was a general request for information on what other people had done with the TAS3004, and I was simply trying to provide some helpful information per your request. To be honest with you, I didn't expect a point-for-point rebuttal and harsh evaluations like "useless".
 
Member
Joined 2004
Paid Member
len_scanlan said:

Still unreleased, but the specs are 8 channels, 25 biquads per channel, and TSSOP-38 package (small but usable for prototyping - not BGA!!)


Wow--that looks great. The AD1954 is also nice for certain applications, such as stereo or bi-amped speakers.

I've been trying to get info on availability of the STA328--it looks ideal for a small 2-channel plate amp for computer speakers. Not too many biquads, but 2 80W digital amps and a 4-pole crossover on one small chip is pretty cool! Like the TI amps, it requires a regulated power, but I think I've got a good solution for that already prototyped. This is fun stuff.
 
Neil Davis said:


You're right--I didn't quite understand what you were trying to do, and it just looked odd to be doing all of that complex arithmetic in a PIC. I assumed that it required a fairly large amount of memory and development tools to get the precision that was needed, so it seemed to make more sense to just run some simple biquad code in one of the new low-cost DSP's. But that freeware code for 32-bit floating point looks promising--if you can use it to calculate the coefficients then it looks like a good way to use the power of these biquad chips.

That math precision is important. For low frequency 2-pole filters, the A2 coefficient is very close to "1", with values like .9999x. A2 < 1 is a stability criterion, so roundoff errors can be a problem.

The spreadsheet that I posted includes a math model of the TAS3004, but it can be adapted to model a TAS3103 or the AD1954 (which is a nice chip!). It also lets you ingest loudspeaker measurements (FRD or Laud) and view the results of the various filter types in building a crossover or doing EQ on a system. So it may help you in setting up your equalizer by visualizing the results, or help in verifying your design. I pointed out these features of the spreadsheet because your original post was a general request for information on what other people had done with the TAS3004, and I was simply trying to provide some helpful information per your request. To be honest with you, I didn't expect a point-for-point rebuttal and harsh evaluations like "useless".


Ok, "useless" really was way too harsh. The spreadsheet actually sounds quite useful... just not in this particular application. And it is interesting to see that other DIY'ers really are using these devices.

The accuracy of the coefficient calculation should not be an issue. Microchip claims that their 32 bit math library is within +-0.5 LSB the majority of the time and +-1 LSB worst case. Consider that the TAS3103 uses a 5.23 fixed-point format (23 bits following the decimal point, er, radix point), and IEEE float has a 23 bit mantissa (fractional part) with 1 additional implied "1" at the beginning, for 24 significant bits. After converting it to the 5.23 format, we will actually need to drop one of those significant bits (in the case of ~=0.99). For any coefficient less than |0.5|, we will drop 2 or more significant bits. The TAS3004 uses 4.20 format fixed point, so we will drop even more significant bits from the 32 bit FP result. Of course when I say drop I mean round off.
 
len_scanlan said:
...Would be great to have a digital xover design done here, we have some very clever people contributing. Anyway it's late, will post again when I've heard back from TI.

Please do let us in on any new information on the TAS3108. It looks like it could be very useful.

A digital crossover would be entirely possible and would not require much additional work once the EQ is functional. After all, the biquad filters are just generic 2nd order filters and they could easily do low pass and high pass functions. The calculation of the coefficients is only slightly different for any 2nd order filter. Of course you will need multiple channels. Being able to tweak the crossover on-the-fly is something that is virtually impossible to do with analog crossovers. Imagine the beast of a ganged pot you would need to adjust 2 channels with 4th order crossovers... that's 4 pots per speaker driver * 2 drivers per channel * 2 channels = a 16-gang pot, with superb tracking of course, so that your filters don't fall out of alignment. With digital, one twist of the wrist can change all those filters simutaneously, and with great accuracy. You could also experiement with slope, and filter alignment (L-W, butterworth, bessel), phase correction, time alignment, rumble filters, all without any circuit mods. And if you wanted to, once you dial in the crossover, you can build an analog version (minus time alignment) for use with your vinyl or SACD sources.
 
Digitally Controlled analog crossover

I designed a digitally controlled 2 way Linkwitz Riley(24dB/oct).All frequency determining resistors have been replaced with quad digital pots from Analog Devices,all under software control from a PicMicro,I can change crossover points with about 100 hz step resolution,the unit has been in use for about a year and I am quite pleased with the performance.I am working on a 3-way design with some additional features(Eq in the passbands).

I am also very interested with the new TI 3108 device,it looks like it's almost ready for production.

Regards
Bob C.
 

Attachments

  • crossover 001.jpg
    crossover 001.jpg
    88.3 KB · Views: 2,018
Member
Joined 2004
Paid Member
macboy said:
A digital crossover would be entirely possible ...

I've been playing with 8-pole crossovers plus EQ with the TAS3004 for quite a while. With 25 biquads you can do brick wall filters plus a LOT of EQ. Unfortunately, using the TI tools (DCT and ALE) to design the crossovers is non-intuitive and clumsy--that's why I decided to work on that "crossover builder" spreadsheet.

I assume that the TAS3108 will have versatile input switching like the TAS5518. That's another one of the limitations of the TAS3004 for multi-driver use in a single speaker. In order to use the digital inputs (SPDIF), you need some external logic to pick off either the left or right SPDIF channels (its the logic on the yellow board). The Analog Devices chip (AD1954) appears to have the same limitation.

The picture shows a "quick and dirty" plate amp based on one of the TI evaluation boards. It's just been sitting around for at least a year and a half, waiting for some better tools to configure the TAS3004. I need to retire so I can work on this stuff!!
An externally hosted image should be here but it was not working when we last tested it.
 
Just heard back from my TI rep, he's still looking for the datasheet, oh well we wait a little longer..

I was thinking that it would be very useful to be able to control an EQ / Crossover board from your PC via serial or USB. Even though many would want a 'stand alone' box (including me!) nothing beats a nice little app running on a laptop for all the initial tweaking. When I finally get around to designing a board I'm definitely going to build in this capability and hopefully someone can pick up the PC application eventually - I've got to admit it's been years since I did any programming on a PC..

I'm gonna have a look at Neil's spreadsheet over the weekend and catch up on my maths - about time I got back into this!

Thanks,

Len.
 
Hi All,

TAS3108 datasheet has appeared on the TI website over the weekend!

http://focus.ti.com/docs/prod/folders/print/tas3108.html

Its an audio DSP, similar in concept to the Analog Devices SigmaDSP parts. Looks like they've kept the IIR 'core' of the TAS3103A and added a basic CPU / sequencer.

You get 4 stereo input channels, 4 stereo output channels. Part will run with sample rates up to 192KHz, you get less instructions per audio sample as the sample rate goes up.

Again like Analog Devices there will be development software available with a graphical 'cut and paste' code generation tool.

The interesting part is that there is an on-board 8051 micro, but this time there is user code space so it may be possible to use this for your own code and eliminate the PIC. Not too many details on the preliminary datasheet yet.

This looks great for my project, but I'm going to wait for full details to be published. Still up in the air whether to wait for this part or use the Analog Devices SigmaDSP parts.

cheers,
 
Member
Joined 2004
Paid Member
len_scanlan said:
Its an audio DSP, similar in concept to the Analog Devices SigmaDSP parts. Looks like they've kept the IIR 'core' of the TAS3103A and added a basic CPU / sequencer.

Interesting, but intimidating! I'm not convinced it has the biquads, but it's hard to tell from the data sheet. Looks like you might have to buy some development tools to make this work.

I had a lot of trouble hacking the I2C interface, but things are looking much better for that spreadsheet. I can use the Excel TAS3004 model to develop crossovers, and (finally) I can write to the EEPROM from Excel and reset the TAS3004 from Excel. After reset the TAS3004 loads itself from the EEPROM, so I've got all the pieces I need now to build a smart plate amp with the TAS3004 (it's the chip on the right, in the front). Now on to the TAS3103 and digital amps instead of the LM3886's. I think I'll pass on the TAS3108 for now.

I'll document the TAS3004 plate amp project once I've got a pair of finished prototypes. One amp is built, both cabinets are done, but lots of clean-up still.

An externally hosted image should be here but it was not working when we last tested it.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.