Sunday, March 5, 2017

Clipping Distortion and Digital Bass Management

This is your audio on bass management. (source)

I recently posted a discussion of my experience with digital bass management somehow introducing distortion when listening to music. It was determined that enabling the receiver's bass management process reliably led to audible distortion with some recordings. I had been listening to music with bass management for years without any trouble. But when listening to Landscape In Portrait by Marihiko Hara, it was immediately apparent that something was extremely wrong. Now I know why.

An audio signal processor's bass management system is a set of digital filters with selectable crossover points. This means that instead of sending the main speaker channels the full bandwidth signal, the receiver filters out the bass that is sent to the speakers (high-pass filter) and redirects the bass signal to the subwoofer (low-pass filter). This is not a brickwall filter where all content below the crossover point is redirected to the subwoofer; instead, the bass is gently "rolled off" on a slope to allow for a smooth transition between the speakers and sub.

Crudely drawn illustration of a crossover filter slope by the author

In the last few months, I have been applying high-pass filters to digital audio recordings in order to properly compare them to vinyl rips (i.e. needledrops). It was immediately apparent that I needed to attenuate the signal before applying the filter. The whole point of comparing vinyl rips with filtered versions of retail digital releases was to demonstrate the "false peaks" that resulted in more dynamic-looking waveforms. So if I ran the filter without first creating headroom, those newly created "peaks" with run up against the -0dBFS ceiling and be clipped.

While listening to an album in Direct mode (no bass management) last night, it occurred to me that the very same "peaks" I encountered in my filtering tests could be the source of the bass management distortion problem. After all, the bass management process is not unlike what I was doing in the digital audio workstation, except that the receiver isn't compensating for the potential clipping issues that may result in filtering.

As soon as I thought this could be the issue I was experiencing, I was certain it was indeed the case. But a hunch will not suffice: A good pretend scientist must make an experiment! Using the track "Yoru Ga Mita Keshiki" from Landscape In Portrait, let's take a look at some waveforms.

"Yoru Ga Mita Keshiki"
As we can see, this minimalist piano music is mastered in such a way that it often peaks near the digital maximum. Played in Direct mode or through headphones, it sounds perfectly clean. It is only when the bass management filter is applied that distortion becomes an issue.

"Yoru Ga Mita Keshiki" high-pass filter applied at 80Hz
Those alarming red lines are Audacity's way of telling me that the software is detecting clipped samples. This is effectively what is being routed to the amplifiers for the main stereo channels during bass management (another signal that is low-pass filtered is routed to the sub at line level). When I play this file with my receiver in Direct mode, I hear the exact same 'tearing' distortion sound that I encountered with bass management. Problem: Identified! But before going further, let's take a look at what the filtering looks like for this song if I "turn it down" first:

Same song, attenuated by 4dB

High-pass filter at 80Hz after attenuation

We can see now that the filtering results in peaks higher than what was represented in the attenuated file. These were clipped in the version above with all the red lines. This clipping is precisely what is happening when the "full volume" digital audio is hitting the receiver's processor and the bass management filters are being applied. When I listen to my filtered version in Direct mode, the distortion is audible during the same passages as when listening to the unaltered file with bass management enabled.

Let's zoom in to see what's happening in a little more detail:

Before filtering...

...after filtering

When we apply the filter to the unaltered file, we can clearly see the red lines indicating clipping. We now have square waveform tops in place of smooth curves. Squares do not sound very good when your speakers try to reproduce them. Some recordings are intentionally clipped, but this one wasn't.

Attenuated before filtering...
...after filtering
If we lower the volume of the file before applying the filter, we are creating enough headroom to allow for the peaks to resolve. There are no square wave tops or red lines in the filtered version above, and thus no distortion. 

Update: Listen for yourself with the clips below. They were recorded from my Oppo UDP-203 playing the FLAC file of "Yoru Ga Mita Keshiki" using the stereo analog outputs of the player. I've bypassed the receiver, but the results are the same. One clip is the audio played full range, and the other is with the players bass management system enabled (front left/right channels set to "Small"; crossover at 80Hz).

Merely by using the bass management ubiquitous in home theatre receivers, we are potentially adding a not insignificant amount of audible clipping distortion. This will potentially occur in any digital recording without sufficient headroom for peaks to resolve after filtering. In reality, this is happening all the time. It just took this special case with minimalist piano music mastered in such a way that some peaks ran into the digital ceiling after bass management filters were applied. There were a few times in other recordings where I thought I'd heard something similar, but couldn't be sure. Whenever I went looking for the offending sections monitoring carefully in headphones, I couldn't find them. Now I know why: No filters are applied with the headphone output.

So what's the solution? I mostly play music directly from my computer via optical cable connected to my Onkyo TX-SR706. Given that all is required here is a bit of headroom in the recording before it hits the receiver's processor, I should be able to create it by adjusting the output volume in my music playback software. Sure enough, by turning down the volume in foobar the recording sounds perfectly clean in a bass managed configuration. It doesn't take much, -6dB should be plenty if you want to play it safe. It's that simple. (Of course, this means you are sacrificing 1 bit of resolution. Given this filtering-causing-clipping thing is only an issue because digital audio is mastered at such high levels, I wouldn't worry too much about effectively elevating the noise floor from -96dB to -90dB.)

But what about playing a disc or file from a non-personal computer source? I have a standalone Pioneer CD/DVD-Audio/SACD player for playing various music discs. To my knowledge, there is no way to adjust the volume of the the digital output before it reaches the receiver. Therefore, any audio signals that peak near -0dBFS will potentially be subject to clipping distortion due to bass management filtering. The same goes for bitstreaming Dolby or DTS-encoded audio (lossless or otherwise) from Blu-rays via my Playstation 4. I think the PS4 has a volume option, though it would require decoding everything to LPCM before sending it to the receiver digitally for bass management. Though movies tend to be mastered with plenty of headroom compared to most music, so the likelihood of encountering clipping due to bass management filtering is much lower.

There is also the option of some players like those available from Oppo which have volume controls on their analog outputs. They also feature bass management on their analog outputs, which could be sent to a capable receiver and run in Analog Direct mode. However, there's no guarantee the Oppo's filters wouldn't clip the audio. (Update: I have since purchased the Oppo UDP-203 and yes, using the player's bass management system for analog output also results in distortion.) One might choose to send use the Oppo's analog output without bass management and lower the volume before it hits the receiver for bass management, but the receiver would then need to do an analog-to-digital conversion before its processor could apply the filter. It wouldn't be an ideal solution, but it's a workable one if you don't mind the extra conversion.

It must be so obvious to the engineers designing this equipment that bass management is a source of potential distortion. Ideally, the receiver would have an option for lowering the level of a given digital input prior to processing the signal. My receiver doesn't have this option, though I'm not sure if more recent models have some equivalent feature for avoiding the issue.

Given how loud modern recordings are, it's a wonder why this problem never required my attention sooner. The simple reason for this is that the distortion is masked by the music and would only be noticeable during quiet passages. But quiet passages don't usually contain peaks near -0dBFS... unless all the music is quiet and is therefore allowed to be mastered that way. A quick Google search about this issue doesn't seem to come back with many discussions of the problem, and what few results there are tend to specifically deal with subwoofer clipping. That's not the issue I encountered: The distortion is present in the main channels. Hopefully this post will be helpful those those who like to listen to their music in a "2.1" bass managed stereo configuration like me:

If you are encountering clipping distortion when using digital bass management, the solution is to lower the volume of the player's output before it reaches the receiver's processor for filtering.