• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Prevent DSP caused digital clipping best practices

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
I use REW and Rephase to create FIR filters for room correction and use the Convolver plug in with Foobar 2000. The Convolver Plug in has "automatic level control" which I assumed would prevent digital clipping. The other day I ran a 0 dB sweep and was surprised to hear several frequencies with strong digital clipping. I lowered the Convolver plug-in level by an extra 3 dB and it eliminated the obvious audible clipping when sweeping. Then yesterday I was using the Foobar 2000 "downmix to mono" DSP plug-in on some old stereo Jazz recordings and started to hear "digital crackling" and sure enough the "summed mono" DSP was causing digital clipping by adding 3 dB to the signal when summed.

Rather than running 0 dB sweeps and "listening for digital clipping" is there some other way to test for "digital clipping" more objectively and easily without disturbing the household? When creating FIR filters in Rephase and REW is there a way to know what level to create them at to prevent digital clipping and not rely on the Convolver Plug-in? Do I need to make level adjustments every time I add in a DSP plug in like the "sum to mono" plug in? Any ideas on "best practices" appreciated.

I am starting to think digital clipping is more common than you would think when using DSP room corrections. I am also surprised how much DSP eats up gain... I had to add an analog pre-amp to my system when I use DSP room correction in order to have enough voltage to drive my amps to full power.
 

DVDdoug

Major Contributor
Joined
May 27, 2021
Messages
3,038
Likes
4,005
I can't answer your "real question"...

This is one area where analog has an advantage... An analog equalizer can have a LOT of headroom, whereas there is often NO headroom in digital audio...*

I am starting to think digital clipping is more common than you would think when using DSP room corrections.
Of course, any boosting can cause clipping, and even cutting can cause (slight) clipping because some filters have "ripple" (bumps & dips in the pass-band frequency response.)

Most recordings are 0dB peak-normalized so if you boost at all and send the full-volume digital signal to the DAC, it will clip. If you are using digital volume control (reducing the digital level into the DAC) this is less-likely to happen. Streaming audio is usually loudness normalized so you are more likely to have headroom, but not with every recording.

I am also surprised how much DSP eats up gain... I had to add an analog pre-amp to my system when I use DSP room correction in order to have enough voltage to drive my amps to full power.
Are you boosting the bass? If you boost the bass, of course you have to reduce the overall volume to prevent clipping. Since your hearing is less-sensitive at low frequencies this will often be perceived as a reduction in overall volume.




* DSP is normally done in floating-point which for all practical purposes has no upper (or lower) limit and it won't clip. But DACs are usually integer-based and hard-limited to 0dB.
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
You bring up some good points for those of us using DSP. I think in particular the fact that summing two channels results in 6 dB of boost (assuming identical input signals) is probably something most people do not consider.

Personally I make a frequency response measurement of the DAC output with no DSP applied (at some lower level, like -20 dBFS) and then make the same measurement with DSP applied. By comparing the two I can see how much net boost I have. I then adjust the DSP so that it will never clip by subtracting the net boost from each channel and usually cut another 1-2 dB for good measure. Measurements are not required if you have a good understanding of what you are doing with boosts / cuts and channel summing but I always like to do them for confirmation.

I do take slight exception to the headroom comments. If you do as I describe above and cut so that your DSP will not clip you will still be capable of sending full output voltage from your DAC. Depending on what your DSP looks like you may want to listen at a higher volume but assuming you have decent DAC output voltage the issue then becomes if you have enough amplifier to do so. In my setup as my volume control is downstream of my DSP I always like the ability to drive my amps beyond clipping. I really like the pairing of a DAC with 4 V output with amplifiers like the Hypex NC252MP which have an input sensitivity of 1.7 V. With a setup like this I know that I have the possibility of clipping the amplifier if I listen above a volume setting of -8 dB (20 x log(4/1.7) = 7.4 dB) but I am usually only at a volume setting that high if I am listening to something that is nowhere near 0 dBFS in level.

Michael
 

KSTR

Major Contributor
Joined
Sep 6, 2018
Messages
2,799
Likes
6,263
Location
Berlin, Germany
The technical fail-safe scaling factor to 100% avoid clipping is the sum of the absolute values of all the sample values in the convolution kernel. I'm not aware of any software that can calculate this directly but some C or Python code could be written for this.

I've personally used some extreme "loudness war" type of test tracks like Metallica's Death Magnetic or similar (and add some gain to drive it even further into clipping), do a test convolution in Adobe Audition (in floating point mode) and look for the highest peak (absolute value), add some safety margin and then hope it won't clip with anything else when using this scale factor.
Other checks (same procedure) with full scale (0dBFS) square wave sweeps, 0dBFS sine sweeps or heavily clipped white noise are indicative as well.
 
OP
L

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
I do take slight exception to the headroom comments.
I struggle with this when I try to think about it. My system is tri-amped with 250 Watt amps on the Woofers and 60 Watt amps on the Mids and Tweeters. The gain on the Woofer amp is 26 dB and the gain on the other 2 amps is 20 dB. I use analog active crossovers which have some adjustable gain to match the amp/drivers to deliver measured flat response. I am using an unbalanced 2 Volt DAC. So taking a simple example of a DSP room correction consisting of only a +7 dB @ 120 Hz then 0dB = 2 volt at 120 Hz and for all the other frequencies 0dB would be 0.89 volts. A 7 dB cut certainly sounds less loud but as you say that may be all that the system can deliver without clipping at 120 Hz in the analog domain but it really gets complicated with the 3 different amps with different gains and the active crossover with variable gain. I am not even sure how I could measure this as it seems like would I have to measure the 3 amps outputs while connected to the drivers with a 0 dB sweep but then I still wouldn't know the level each driver/amp combination clips at because of the different characteristics of each driver/ amp combination. That is why I just try to avoid digital clipping and use extra analog gain which I seldom if ever use. One thing for sure digital clipping sounds bad instantly while analog clipping is more forgiving.
 
OP
L

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
I'm not aware of any software that can calculate this directly.
That is what I was hoping for but I have not found anything. It seems like sound reinforcement people would need something like this but I don't' know.
 

AnalogSteph

Major Contributor
Joined
Nov 6, 2018
Messages
3,397
Likes
3,350
Location
.de
This all seems unnecessarily complicated. You are generating your EQ in REW, so you should know your maximum gain seen in frequency domain, let's call it +X dB. Then use -X dB as your pre-gain, and you should never see clipping where there wasn't any before. You may not ever need that much with practical signals and consequently be wasting some dynamic range (say you have a boost at 10 kHz, how often do you encounter 10 kHz full-scale in real life?), but this approach will always work and has been used literally for decades.

The maximum gain a stereo to mono downmix may provide is +6 dB, when both channels are being added in phase (1 + 1 = 2 = +6 dB). However, in practice listening to things on just one speaker or - worse yet - headphone driver tends to be highly aggravating, so you'd generally be using the "Convert mono to stereo" DSP as well, which promptly tends to undo the gain. Though I just tried it, and at least in Foobar200 v1.5.7 both DSPs seem to be compensating for level already.

BTW, if you have stereo rips of mono LPs, foo_dsp_centercut is the best thing since sliced bread. It removes crackling and distortion way more effectively than a simple downmix.
 

amirm

Founder/Admin
Staff Member
CFO (Chief Fun Officer)
Joined
Feb 13, 2016
Messages
44,722
Likes
241,578
Location
Seattle Area
A computed headroom will waste too much dynamic range. I personally start with the 3 dB headroom and then play a suite of bass heavy tracks. If there is clipping, I progressively add more headroom until it goes away.
 

MakeMineVinyl

Major Contributor
Joined
Jun 5, 2020
Messages
3,558
Likes
5,875
Location
Santa Fe, NM
I recently bought a MiniDSP 4x10HD to try in my system. The headroom issue was the reason I just went back to the purely analog crossover / EQ. It was next to impossible to keep from clipping, and when levels were lowered sufficiently, noise was audible with the efficient horns. What I eventually did was to use the MiniDSP strictly for the subwoofer channel where I could keep levels low enough to avoid clipping and the noise was not audible through the subs.

As far as the OP, I don't have any specific recommendations other than perhaps patching Audacity into the chain to look at levels or perhaps Voicemeeter.
 
Last edited:

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
I struggle with this when I try to think about it. My system is tri-amped with 250 Watt amps on the Woofers and 60 Watt amps on the Mids and Tweeters. The gain on the Woofer amp is 26 dB and the gain on the other 2 amps is 20 dB. I use analog active crossovers which have some adjustable gain to match the amp/drivers to deliver measured flat response. I am using an unbalanced 2 Volt DAC. So taking a simple example of a DSP room correction consisting of only a +7 dB @ 120 Hz then 0dB = 2 volt at 120 Hz and for all the other frequencies 0dB would be 0.89 volts. A 7 dB cut certainly sounds less loud but as you say that may be all that the system can deliver without clipping at 120 Hz in the analog domain but it really gets complicated with the 3 different amps with different gains and the active crossover with variable gain. I am not even sure how I could measure this as it seems like would I have to measure the 3 amps outputs while connected to the drivers with a 0 dB sweep but then I still wouldn't know the level each driver/amp combination clips at because of the different characteristics of each driver/ amp combination. That is why I just try to avoid digital clipping and use extra analog gain which I seldom if ever use. One thing for sure digital clipping sounds bad instantly while analog clipping is more forgiving.

At the end of the day I think we are using similar approaches, I use a DAC with a bit more output and you use a pre-amp to get the extra gain. Measuring the DAC output would still allow you to avoid digital clipping regardless of what amplifiers you are using. Figuring out which amplifier is limiting is a bit more challenging when using amplifiers with different power ratings / gain but at the end of the day I am much less worried about clipping an amplifier.

Michael
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
I recently bought a MiniDSP 4x10HD to try in my system. The headroom issue was the reason I just went back to the purely analog crossover / EQ. It was next to impossible to keep from clipping, and when levels were lowered sufficiently, noise was audible with the efficient horns. What I eventually did was to use the MiniDSP strictly for the subwoofer channel where I could keep levels low enough to avoid clipping and the noise was not audible through the subs.

As far as the OP, I don't have any specific recommendations other than perhaps patching Audacity into the chain to look at levels.
Were you using the 4X10HD volume control? How much boost were you using? I can understand the noise issue but when using the 4X10HD volume control I figured you would not have clipping.

Michael
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
That is what I was hoping for but I have not found anything. It seems like sound reinforcement people would need something like this but I don't' know.

A nice feature of CamillaDSP is that it will show you if you are experiencing digital clipping.

IMG_7333.jpeg


Michael
 

MakeMineVinyl

Major Contributor
Joined
Jun 5, 2020
Messages
3,558
Likes
5,875
Location
Santa Fe, NM
Were you using the 4X10HD volume control? How much boost were you using? I can understand the noise issue but when using the 4X10HD volume control I figured you would not have clipping.

Michael
My system is very atypical. The signal chain is mostly my own design/build and the gain structure is such that the preamplifier supplies almost all of the voltage gain in this actively crossed over system. The HF power amplifier (SET tube) is operating at almost unity voltage gain and the LF amps close to that. So all the levels post-preamp are really slammed far beyond the capability of the MiniDSP. Since I have a mixture of purely analog (vinyl and R2R tape) and digital from an SMSL M400 DAC, there is really no solution. All of these procedures are necessary because my horns are 107dB/watt efficient in the HF and 101dB/watt in the LF and any excess noise at all originating in the power amps would be audible.

That's all OK though because I have no complaints on the sound I'm getting.
 

storing

Active Member
Forum Donor
Joined
Aug 27, 2021
Messages
226
Likes
220
DSP is normally done in floating-point which for all practical purposes has no upper (or lower) limit and it won't clip. But DACs are usually integer-based and hard-limited to 0dB

Even if a DAC takes floating point values at its input, it still has to hard-limit a certain range out of those values and clip anything beyond that. It still cannot produce analog voltages larger than its analog supply voltage (likewise the 'analog equalizer has an advantage' feels a bit misguiding wrt to the topic)
 

enricoclaudio

Major Contributor
Audio Company
Joined
Jan 7, 2021
Messages
1,109
Likes
2,195
Location
Houston, TX - USA
Roon does a really good job keeping digital clipping under control. I have Volume Leveling set on AUTO + Headroom Management under DSP turned ON set at -2dB. Also the clipping indicator is turned ON and I haven't see it going into RED for a long time, not even when switching to my DCA Aeon 2 Noire headphones with a LOT of boosted bass :)

Screen Shot 2021-12-13 at 12.15.37 PM (2).png


Screen Shot 2021-12-13 at 12.15.57 PM (2).png
 
OP
L

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
Roon does a really good job keeping digital clipping under control. I have Volume Leveling set on AUTO + Headroom Management under DSP turned ON set at -2dB. Also the clipping indicator is turned ON and I haven't see it going into RED for a long time, not even when switching to my DCA Aeon 2 Noire headphones with a LOT of boosted bass :)
Interesting, while I don't have Roon I figured the "Automatic Level Control" in Foobar's convolver plug-in would take care of clipping management but I have to add an additional -3 dB of attenuation. Foobar doesn't have a digital clipping indicator like Roon unfortunately.... or maybe it does, I will have to research. If it did I would just run a 0 dB sweep and see if it clips which would be quick and easy.
 

DDF

Addicted to Fun and Learning
Joined
Dec 31, 2018
Messages
617
Likes
1,360
Digital clipping can occur even if your filter transfer function never exceeds 0 dB.

Filter Phase Response
A filter transfer function with no gain at any frequency still has phase shift that could change how the different frequencies constructively add in the audio envelope, and cause clipping. An illustration of this is here where 5 dB peaking occurred with a 1 st order high pass filter
1639437465253.png


This effect is signal dependent and I'm not aware of any study to find corner cases with real music and how much headroom is needed. In practice I've never had any issue with 4 dB headroom after trialing a few aggressive room EQ filters.

Intersample Overs
Pathological cases exist with non musical test signals where as much as 10 dB could be needed to avoid clipping due to interpolation, but Benchmark studied risky CDs and found 4 dB was a safe real-world trade off.

Some other details here
 
OP
L

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
Thank you very much everyone, I have learned a lot. In my case with a pre-amp I think I have found a reliable way to avoid digital clipping.

1. Foobar2000 has a "peak indicator" which I just had to "turn on".

2. Record a 0 dB sweep in REW.

3. In my case the Foobar convolver plug in says my FIR EQ filter has an "Impulse power" +5.2 dB. I disabled the "automatic level adjust" (which seemed dodgy) and started manually adjusting the "level adjust" starting at -5.2 dB and played back the 0 dBs sweeps and watched the "peak indicator" and adjusted the level until I no longer got digital clipping. In my case I had to go to -9.2 dB to eliminate clipping. With the pre-amp I could turn the volume way down and listen to the 0 dB sweeps and the "peak indicator" seemed very accurate to what I heard through the speakers. Without a pre-amp you would have to turn off the amp and trust the peak meters.

4. I checked out some different music with this setting and for most of my music -9.2 dB seems like overkill but then I put on a Metallic track that needed every bit of the -9.2 dB to prevent clipping.

5. DSP can solve room and speaker issues but it is not without "cost". In my case my 320 watt per channel amps with -9.2 dB of headroom removed theoretically play as loud as 38 watt per channel amps... although since I have extra analog gain available I can get some of that back at the risk of some analog clipping at a few frequencies.

6. With the popularity of room EQ I wonder how common digital clipping is. I know the way I had my system set up it must have at least occasionally digitally clipped... until I ran a 0 dB sweep I never would have know as I assumed the "automatic level control" took care of it.
 

AnalogSteph

Major Contributor
Joined
Nov 6, 2018
Messages
3,397
Likes
3,350
Location
.de
1. Foobar2000 has a "peak indicator" which I just had to "turn on".
Where? I'm aware of the "Peak Meter" viz.
4. I checked out some different music with this setting and for most of my music -9.2 dB seems like overkill but then I put on a Metallic track that needed every bit of the -9.2 dB to prevent clipping.
JFTR, what's your ReplayGain setup like? (Preferences - Playback, collection's RG scanning status) I associate Metallica more with records that are super hot than super dynamic, and RG should normally be reining those in...
 
OP
L

levimax

Major Contributor
Joined
Dec 28, 2018
Messages
2,401
Likes
3,534
Location
San Diego
Where? I'm aware of the "Peak Meter" viz.

JFTR, what's your ReplayGain setup like? (Preferences - Playback, collection's RG scanning status) I associate Metallica more with records that are super hot than super dynamic, and RG should normally be reining those in...
I was referring to the "Peak Meter". It seems to work pretty well as a clipping indicator, when the "square" at the end showed up when I did sweeps the sound changed dramatically (clipping).

I don't use ReplayGain (just figured it was more stuff in the signal path I didn't need) and yes the Metallica song is DR 4 and very loud.
 
Top Bottom