Sunday 3 February 2019

Enhancing headphones or earphones with Audio Hijack 3

Long ago there was an awesome audio enhancer for Mac OS X that could improve system-wide audio in various ways. It started out as ‘OSS 3D’ by Subband Technologies, later on it was bought by Joesoft and rebranded to ‘Hear,’ and it eventually migrated to the Prosoft brand name. This program offered various effects like 3D audio, a straightforward equalizer, a virtual subwoofer, and various other things that were both useful and gimmicky. Everything was fine until the program became unable to enhance audio coming from iTunes, arguably its most important target. Prosoft was never able to fix this and eventually the program stopped working altogether with the latest major OS X updates. Rest in peace, Hear.

I have been looking for a way to simulate at least part of Hear's functionality. I especially relied on it to obtain a more natural listening experience with headphones. If you have ever listened to e.g. Beatles songs on headphones, you will have noticed first-hand that headphones do not offer the same listening experience as loudspeakers. With loudspeakers, sound from the left speaker will not only reach your left ear but your right ear as well and vice versa, both directly and indirectly through reflections. With head- or earphones however, the left and right channels are fed strictly to the respective ear only. If the music was mixed with sound coming only from either left or right (as was often the case with the first stereo recordings like from the Beatles), this offers an unnatural experience. Even today a lot of music is mixed with loudspeakers in mind and will not sound ‘right’ when listening with headphones.


A good solution is to preprocess the music before sending it to the headphones, simulating it being played on loudspeakers. The most basic way to do this is to mix a bit of the right channel into the left and vice versa. This already makes Beatles songs less awkward to listen to but it's not quite it. To add more realism, the tiny delay caused by the longer audio path from the left loudspeaker to the right ear and vice versa must also be taken into account. From my DSP courses I remember that a realistic delay is 390µs (this can be derived from the geometry of a typical stereo setup and the shape of a human head). To further increase realism, there must be some low-pass filtering as well because higher frequencies will have a harder time reaching the opposite ear. And finally to get the sensation of listening in a real room, some reverb can be added.

This idea can be implemented with Audio Hijack from Rogue Amoeba Software. It is not for free but is well worth its price for anyone who needs to do more with audio than merely playing some music. So let's see how we can implement our fancy headphone enhancer with Audio Hijack.


The above image shows the setup. The upper part is the one that simulates a room. A slight reduction in volume is applied to compensate for the fact that we will be adding a cross-mix of the channels later on. A reverb effect makes the sound less ‘dry’ by simulating it bouncing off walls, floors and ceiling. The configuration of the reverb unit is a matter of personal taste. I started out with the defaults of the Matrix Reverb and reduced the ‘large’ parameters to have a faster drop-off.

The lower part is the most important one, it represents the cross-mix between loudspeakers and ears, the extra delay due to the longer audio path, and the attenuation of high frequencies. The 390µs delay cannot be obtained with the standard effects available in Audio Hijack, a custom plug-in is needed. I've found this free sound delay audio unit from Voxengo to be adequate. You need to reboot after installing the AU plugin to make it available in Audio Hijack. Enter a value of 0.39 msec in the effect configuration. People with really fat heads might try a larger value but it should never deviate much from this.
The exact value for the low-pass filter isn't crucial. This filter has two purposes: first, simulate the actual attenuation of higher frequencies that would occur in the situation depicted above, which is difficult to quantify anyway. Second, avoid interference between trebles in the original audio and the delayed copy. Without the low-pass filtering, there would be a comb filter effect that can make some trebles sound weird. If you still notice this, you may want to use a lower frequency than the 6 kHz I used here.

After mixing everything together, there is another volume control and an equalizer. These are optional but unless you have extremely high-end headphones, a little extra EQ can get that bit of extra fidelity out of them. The reason why you may need to precede the EQ with a volume reduction is that if you need a considerable bass boost, you'll need to attenuate the input to avoid sending the audio into overdrive. You may add other effects to your liking, e.g. a dynamic range compressor in case you're listening in a noisy environment (although a lot of modern music has no dynamic range to begin with…)

No comments: