# Equalizing frequency response in software

I'm playing audio through a speaker which I know to have a non-flat frequency response, with particularly poor response in the low ($<1\textrm{ kHz}$) ranges. My plan to get around this problem is to write a script which processes each audio file before passing it on to the speaker such that the energy is boosted in the ranges where the speaker's response is poor.

I know that it is possible to create a filter which does this (e.g. using the firwin2 function in Scipy), but I can't help but feel that this approach is overly naive, and that I will wind up accidentally introducing unwanted artifacts into the signal when I actually play it through the speaker.

• So, is this approach doomed to failure?
• If not, then why isn't it something that all speaker manufacturers do already?

It's not exactly doomed to failure, but it doesn't completely solve the problem. An appropriate inverse filter might be effective at correcting some aspects of the speaker response. Just how effective this approach is will be limited by the nature of the loudspeaker behaviour.

If the speaker was a perfect linear system, then an inverse filter as you describe would contribute to a flat magnitude response. The reality is that loudspeakers are typically complicated non-linear systems and a linear correction is unlikely to suffice.

Whilst I am not well versed in Scipy, or how the firwin2 function works that you have quoted, this is a very complicated problem that you propose, and there is a lot more to think about than you may realise.

There is one very important component of how sound is radiated by a loudspeaker that is quite often overlooked (especially in marketing specifications for loudspeakers). Directivity. You state that your loudspeaker has a particularly poor response below 1 kHz. I assume that means a “non-linear” response on-axis. What about off-axis? This off-axis energy is what interacts with your room, i.e. reflections, and the frequency response in these off-axis directions most likely have a response different to your perfect on-axis response. If you correct just the on-axis loudspeaker response what has that inverse filtering done to the other positions off-axis? Will you always listen, with one ear, at the intersection of your loudspeaker on-axis directions?

Some loudspeaker manufacturers do actually use technology that attempts to apply “correction” (Genelec, Bose etc…) to overcome room anomalies and positional errors in loudspeaker placement. Whilst the methods employed are very smart, we have to remember that these are just best approximations. It is also not uncommon to use some form of linear phase FIR filters to correct for minimum-phase anomalies in loudspeaker response for mid-high frequencies, and alternative approaches can be applied for lower frequencies. Some of these techniques can be better understood by reading text such as: Immersive Audio Signal Processing

Other things to consider: Just how much time data do you window in creating your corrective filter? And where should you make your measurement? Will you always listen in that position? What I’m emphasising here is that temporal and spatial variation of the soundfield need to be considered also.

So what you are attempting to do isn’t exactly “doomed to failure”, it’s just very complicated, and at the end of the day, the desired result is going to be that which suits your subjective tastes. I hope that some of the questions I have raised have been helpful, I have raised them simply to remind you that it’s not as simple as inverting a single omnidirectional measurement of a loudspeaker at some point in a room… Otherwise, yes, every loudspeaker manufacturer would have already done this. Good luck on your endeavour!

I’ll leave a random selection of some references to technical literature related to research in this topic space that you may find helpful:

Combined Quasi-Anechoic and In-Room Equalization of Loudspeaker Responses

Invertibility of a room impulse response

Equalization of loudspeaker response using balanced model truncation

Equalization in an acoustic reverberant environment: robustness results