Parametric Equalization in Pipewire
Introduction
I just wanted to share what I have learned by manually setting up parametric equalization in Pipewire. I found some sources of information on this, but nothing that describes exactly what you need to do to have it just work.
There are easier ways to enable parametric equalization and many other audio effects than what I am about to describe. If you want the easy way, just install EasyEffects. However, the downside of EasyEffects is that it isn’t exactly a lightweight application when the capability to do equalization already exists natively in Pipewire. If you just want a set it and forget it approach, then follow along.
Parametric Equalization
First of all, what is parametric equalization and why would you want to do it?
Most people are familiar with the concept of an equalizer. They are present on many higher end stereos and audio players. The one most people think of is called a graphic equalizer. It has a series of fixed frequency bands where you can control the gain of each. This is implemented as a bank of filters where each filter controls a band.
A parametric equalizer is a more advanced equalizer where you can define the exact parameters of each filter. The main parameters you can control are filter type, center frequency, bandwidth, and gain. These filters are then chained together and the signal sent through them. Of course in the digital domain, digital signal processing techniques are used rather than physical filters. This offers much more control over the resulting equalization applied to the audio signal.
So why would one want to do this? One common use case is applying an equalization correction to a set of headphones to have them match a target frequency response curve. A common target is the Harman curve.
The Harman Target Curve
The Harman target curve is designed to allow headphones to more accurately reproduce the acoustical properties of a high quality loudspeaker system in a semi-reflective room—typical of a recording studio where the music you listen to was originally mixed and mastered. It stands to reason that reproducing said music in a similar environment with a set of similarly performing speakers might result in better sound quality for the listener, because it was in this setting where the artist and audio engineers decided what sounded good.
To allow headphones to achieve this, the Harman curve was created. The Harman curve is based on measurements done in a semi-reflective room with a calibrated high-quality loudspeaker system inside (the Harman Reference Room). The frequency response of this speaker system was measured using a model of a human head with a microphone embedded inside of an artificial ear canal. This artificial head is intended to mimic how our physical structure and composition alters the sound waves as they enter our auditory system. The Harman target is based on this frequency response curve.
Now if you can get a set of headphones to match this curve when placed over a similar artificial head test rig, then the headphones should be accurately reproducing the sound of this semi-reflective room environment in terms of frequency response as heard by you. Well not exactly as heard by you, because your head, ears, and ear canal are unique and thus will effect how you hear the sound, but for a standardized statistically average person, then yes.
Equalization Correction
Okay so how do you get a set of headphones to match this curve? Well if the headphones already match, then nothing, but most do not. This is where you can apply an equalization correction to the audio signal before sending it to the headphones.
To figure out what equalization settings should be applied, the frequency response of the headphones must be measured using a lab grade head and ear simulator using a microphone embedded in an artificial ear canal as described above. Obviously, this equipment is incredibly expensive and isn’t going to be done by you at home. Fortunately, there are people with access to such equipment who make these measurements and provide the data to the community. This means that your specific model of headphones will need to have been measured in order for you to know what equalization correction should be applied to match the Harman curve.
So how do you get this data? Well there is an easy website which collects it for each model of headphones and uses algorithms to suggest equalization settings which will match the headphones to a target curve. That website is AutoEq and by default it uses the “Harman over-ear 2018” target.
Obtaining Equalization Settings
To get the equalization settings, go to AutoEq, enter your model of headphones, select EasyEffects for the equalizer app, and download the text file. Both Pipewire and EasyEffects can directly use this file.
This file will look something like this:
Preamp: -5.0 dB
Filter 1: ON PK Fc 52 Hz Gain -6.2 dB Q 0.70
Filter 2: ON LSC Fc 105 Hz Gain 5.5 dB Q 0.71
Filter 3: ON PK Fc 130 Hz Gain -1.2 dB Q 1.50
Filter 4: ON PK Fc 235 Hz Gain 2.1 dB Q 2.00
Filter 5: ON PK Fc 2950 Hz Gain -2.8 dB Q 3.00
Filter 6: ON HSC Fc 3000 Hz Gain -2.0 dB Q 0.71
Filter 7: ON PK Fc 4570 Hz Gain -4.0 dB Q 5.00
Filter 8: ON PK Fc 6670 Hz Gain -3.7 dB Q 3.00
Filter 9: ON HSC Fc 10000 Hz Gain 4.0 dB Q 0.71
Filter 10: ON PK Fc 11200 Hz Gain -3.0 dB Q 7.00
Another source for equalization settings come from the r/oratory1990 subreddit. oratory1990 is an audio engineer who is able to take headphone measurements in his company’s acoustics lab during his free time. Many of the headphone measurements on AutoEq come from him. In addition to the headphone measurement data, he also provides suggested equalization settings to match a set of headphones to the Harman target. If you wish to use his settings, you can download the PDF for your model of headphones from the subreddit’s wiki. The PDF has a table with the equalization settings which you can manually input into a text file using the format shown above. In my case, this is what I did for my headphones.
Configure Pipewire With A Parametric Equalization Filter
Follow these steps to configure a parametric equalization filter in Pipewire. Make sure you run all of the following commands using your normal user account and not root.
-
Put the file with the equalization settings obtained above in a well known location (e.g. “~/.config/pipewire/eq/<HEADPHONE_MODEL>.txt”).
-
Next, configure Pipewire with the filter. Create a file at “~/.config/pipewire/pipewire.conf.d/parm-eq-filter.conf” with the following contents:
context.modules = [{ name = libpipewire-module-parametric-equalizer args = { node.name = "param-eq-filter" node.description = "Parametric Equalizer Filter" equalizer.filepath = "/home/<USER>/.config/pipewire/eq/<HEADPHONE_MODEL>.txt" capture.props = { filter.smart = true } } }]The
equalizer.filepathsetting should point to the location of your equalizer settings which you created above for your particular model of headphones. Pipewire appears to only accept absolute paths with no support for “~” or “$HOME”.The key to making this work seamlessly is the
filter.smart = truesetting. This instructs Wireplumber to transparently insert the filter between your apps and the sink for your sound device. Otherwise, you would have to set the filter as the default sink in order for apps to use it by default. The downside of this is the volume controls in your desktop environment will control the volume of the filter and not your sound device output which is confusing, so leaving your sound device as the default sink is best. -
Restart Pipewire:
$ systemctl --user restart pipewire.service -
Start some music in the background to test the sound server.
-
Verify Pipewire logs are clean:
$ journalctl --user-unit pipewire.service --since -1h -
Verify Wireplumber is properly inserting your filter:
$ pw-link -lYou should see the app output connected to the input of the parametric equalization filter:
Amberol:output_FL |-> input.param-eq-filter:playback_1 Amberol:output_FR |-> input.param-eq-filter:playback_2And you should see the parametric equalization filter output connected to the sink for your audio device:
output.param-eq-filter:output_1 |-> alsa_output.pci-0000_0b_00.4.analog-stereo:playback_FL output.param-eq-filter:output_2 |-> alsa_output.pci-0000_0b_00.4.analog-stereo:playback_FR -
Done.
Conclusion
Double blind testing done by Harman shows most people prefer the Harman target curve for headphones over other target curves. However as stated above, the physical structure of your head, ear, and ear canal are unique which will effect how you hear the sound, so making adjustments to the equalization settings are valid.
Overall, making this adjustment will ensure your headphones are accurately reproducing music as intended. I have noticed a marked improvement of my Sony MDR-7506s. They sound less harsh and more balanced allowing the listening experience to be more enjoyable over long periods of time.
Manually configuring Pipewire with a parametric equalization filter ensures it applies desktop wide, is always enabled, and uses minimum system resources.
###