Skip to content

How Does AutoEq Work?

Jaakko Pasanen edited this page May 21, 2023 · 3 revisions

AutoEq is a tool for creating equalizer settings which give a neutral sound for headphones and does this based on headphone frequency response measurements and established target curves. The idea is simple in principle: find equalizer frequency response which together with the headphones' natural frequency response matches the target curve. The thing is more complicated in practice. This article explains how AutoEq really does everything.

Aiming For Target

Target (or sometimes called compensation) is a frequency response which represents the desired or optimal for headphones. This could be a neutral target such as the ones produced at Harman by Sean Olive et al. or a "flavored" target which you prefer over neutral. AutoEq calculates an error curve by subtracting target curve from the raw measured frequency response.

$$ error = raw - target $$

The inverse of the error curve then works as the basis for equalizer frequency response target

$$ equalizer = -error $$

And so when the equalizer frequency response is added to the headphone's frequency response, we get the target

$$ raw + equalizer = raw - (raw - target) = raw - raw + target = target $$

Equalizer target curve cannot, however, be constructed this easily as there are limitations to what equalizers can and should do. AutoEq is largely about dealing with these limitations.

aim_for_target

Customizing Target

The established target curves are a very good starting point for equalizing headphones. Individual listeners' preferences differ, however, especially in the bass. In addition to bass, the upper treble is something that listeners should adjust for themselves because the measurements aren't accurate at highest frequencies. The bass and treble level adjustments are done in AutoEq by adding a low- and high-shelf IIR (parametric) filters to the target curve. Center frequency, quality and gain can be adjusted for both. Fortunately only the overall level matters beyond 10 kHz making shelf filter perfectly adequate for adjusting the upper treble.

AutoEq also gives the user to control the general tilt of the frequency response, allowing users to dial in darker or brighter sound. Even more control over the preference target can be had by creating sound signatures which allow customizing the target with an arbitrary curve.

Experimenting with all target customization options is highly encouraged!

Absolute Levels

Equalization is all about changing the balance of different frequencies and therefore what matters is not an absolute level of each frequency but how their levels compare to each other. To balance the frequency response, one is looking to amplify certain frequencies and reduce others. Similar effect could be created by amplifying or reducing all frequencies as long as the ratios stay the same but for us humans it's more intuitive to read and understand the curves when they fluctuate around 0.

Because the error, which is the basis for equalizer target curve, is the difference between the measured response and the target, it matters what are the absolute levels of the target and the measurement. Frequency responses are typically normalized at some frequency. 1 kHz is a common choise and that's what AutoEq does too. This means that both measurements and target curves are moved up or down so that the value at 1 kHz is 0 decibels. This is adequate for curves that live independet of others because the absolute levels don't matter all that much. When an equalizer target response should be created, absolute levels matter more. When equalizing, AutoEq normalizes the error curve in such a way that the average level between 100 and 10000 Hz is 0 dB. The target curve is then shifted accordingly to keep the error curve true. This ensures the equalizer target will have a balance of boosts and reductions.

absolute_levels

Smoothing

The measured frequency response won't be exactly the same as when an individual listener is wearing the headphones. Each person has unique anatomy and this affects the frequency response of the ear-headphone system, especially in the high frequencies where the wave lengths are short enough to be majorly impacted by the anatomical differences. Another factor making the measurements less accurate is the variance between different units of the same headphone model. Unless the headphone the listener is wearing is the unit that was measured (almost never the case with AutoEq) the frequency response will be different. Even more factors reduce the measurement accuracy, such as how good seal is there between the headphone and the head of the listener, placement of the heapdhone on the listener's head, etc...

Since the measurements aren't perfectly accurate, it doesn't make sense to try to equalize the headphone's frequence response perfectly precisely. AutoEq applies smoothing to the frequency response and the error curve in order to avoid fixing unreliably measured problems. Smoothing is heavier in the upper frequencies since the measurements are less accurate in that range.

smoothing

Maximum Gain

When a digital equalizer boosts some frequencies, there is a risk that the samples in the audio signal would go beyond the minimum and maximum levels of -1.0 and 1.0. When this happens, the device or operating system typically clips the signal between the minimum and maximum values leaving a distorted signal that can sound quite unpleasant. This is avoided with equalizers by applying a negative gain to the signal before any equalizing happens. The downside of this is that he volume is reduced and without a sufficient headphone amplifier, the listener can be left hoping for more volume. AutoEq mitigates this issue by allowing the user to limit the maximum gain in the equalizer. The caveat is of course that some frequencies won't be boosted as much as they ideally would but typically getting enough volume is a higher priority for the listening experience.

max_gain

Avoiding Spikes

Just like in real world, avoiding spikes is a good idea with headphone frequency responses. This applies to heaphone's own frequency response and the equalizer frequency response. AutoEq tries not to create narrow tall spikes in the equalizer frequency response because these can be heard as ringing. The spikes in the headphone frequency responses are fixed without too much reservation because in the equalizer these are notches and notches typically don't cause ringing.

The way AutoEq does this is it first traverses the naive equalizer target curve left to right while limiting the steepness of the slope, then does the same right to left and finally combines the two by taking the smaller of the two values at each frequency. A small smoothing is applied at the end to round of the hard kinks left by combining the two limited curves.

avoiding_spikes

This gives us the target curve for equalizers. The actual equalizer presets try to implement this. For convolution equalizers this is easy since the finite impulse response (FIR) filters can implement arbitrary frequency responses. Parametric and graphic equalizers require more design.

Parametric Eq Optimization

Parametric equalizers offer a lot of flexibility but can be tricky to work with since the different filters can interfere with each other. There's also no single solution to implementing certain frequency response with parametric equalizers but instead the same end result can be achieved with any number of filter combinations. Since AutoEq does everything automatically, there also needs to be a way to find the filter parameters automatically. This is where the parametric eq optimizer comes in.

The optimizer works by iteratively minimizing an objective function (sometimes called loss function). In AutoEq's case, the objective function is a difference between the equalizer target and the frequency response the current iteration of filter parameters implement. The optimizer then tunes the filter parameters to move the frequency response closer to the equalizer target. Many optimization algorithms were tested for AutoEq and most of them fail miserably in the task. Originally AutoEq had a custom Tensorflow implementation for the optimization but due to Python dependency issues (Tensorflow is very picky about Python version and other things) and the long time it took to find the optimal filter parameters, a new optimization algorithm was explored. The current one is fmin_slsqp from Scipy library with a custom objective function.

Simply calculating the equalizer frequency response from the filter parameters and calculating mean squared error (MSE) with the target response leaves room for unwanted behavior. The optimizer is a very clever creature when it comes to minimizing the function, but very stupid at the same time. Only minimizing for MSE can lead to the optimizer producing high quality high gain filters which cause ringing, even when the equalizer target has been regularized by limiting the maximum slope steepness. AutoEq uses an additional penalty in the objective function for the high Q high gain filters. The penalty is based on the maximum slope steepness of the individual filters and is in practice calculated with linear regression instead of true differential for faster computations.

Finally the parametric eq optimizer will treat the > 10 kHz range as a single average value. This matches with human perception and encourages the optimizer to use the filters in the frequency range where they matter the most. The > 10 kHz range often contains a lot of variability and without any guidance the optimizer would put majority of the filters in this range.

The optimizer can be configured flexibly to accommodate for different equalizer app. Different apps have different minimum and maximum values for frequencies, qualities and gains and the optimizer needs keep these parameters in the ranges allowed by the eq app.

parametric_eq_optimizer

Graphic Equalizers

Graphic equalizers can be though of as a special case of parametric equalizer with fixed filter frequencies and qualities. The filters themselves are similar infinite impulse response (IIR) filters as parametric equalizers use. AutoEq can optimize the filter gains for graphic equalizer with the same parametric eq optimizer. The optimizer allows to fix any parameter of any filter in advance so this is done for center frequency and quality of all filters when optimizing graphic equalizer.