DC offset trickery
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
DC offset trickery
There are sometimes claims that the type of DC offset correction used by the Normalize effect in Audacity can cause DC offset errors with asymmetric waveforms. I previously believed this was true, but have since been unable to find any real evidence to support this claim. This post looks at one possible explanation for how this misconception might come about.
Asymmetric waveforms are common when recording real instruments and are often said to be particularly common to brass, woodwind and string instrument recordings. For demonstration purposes, this audio sample is a crude synthesized "bassoon" type sound. A close-up of the waveform reveals that it is asymmetric (higher above the 0.0 horizontal line than below) Zoomed out we can see that the waveform is asymmetric, but there appears to be no "DC offset" Now let's see what happens when we apply the Audacity Normalize effect and correct for DC offset: Oops, that shouldn't happen should it?
Or should it?
What has gone wrong here?
Asymmetric waveforms are common when recording real instruments and are often said to be particularly common to brass, woodwind and string instrument recordings. For demonstration purposes, this audio sample is a crude synthesized "bassoon" type sound. A close-up of the waveform reveals that it is asymmetric (higher above the 0.0 horizontal line than below) Zoomed out we can see that the waveform is asymmetric, but there appears to be no "DC offset" Now let's see what happens when we apply the Audacity Normalize effect and correct for DC offset: Oops, that shouldn't happen should it?
Or should it?
What has gone wrong here?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
kozikowski
- Forum Staff
- Posts: 69372
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: DC offset trickery
I'm not sure how you got the original waves. To get DC offset in the original show, the coil, diaphragm or ribbon would have to leave the microphone and slowly walk toward or away from the performer. There was and may still be a school exercise where you created a theoretically perfect music system that responded down to DC. You could put a gust of wind in and the gust of wind would come out on playback. The system would also suck on command.
That's the only way you can get "DC" in a music system barring something actually being broken.
So even though the digital system can do that, the analog system ahead of it can't. You also have to be careful not to pick a non-representative subset of sound. You have to select enough music so that a complete 1Hz of music would be supported.
I wish I had kept it, but I listened to a radio show where the presenter and the guest both had aggressively non-symmetrical voices -- in opposite directions. The timeline looked like a badly damaged square wave, but I'm sure if I analyzed it, it would all come out zero.
Koz
That's the only way you can get "DC" in a music system barring something actually being broken.
So even though the digital system can do that, the analog system ahead of it can't. You also have to be careful not to pick a non-representative subset of sound. You have to select enough music so that a complete 1Hz of music would be supported.
I wish I had kept it, but I listened to a radio show where the presenter and the guest both had aggressively non-symmetrical voices -- in opposite directions. The timeline looked like a badly damaged square wave, but I'm sure if I analyzed it, it would all come out zero.
Koz
Re: DC offset trickery
Here's a nice "real world" asymmetric waveform, it's a trumpet note by Miles Davis, aptly from “So What” (Kind of Blue, CD 460603 2)

(image from: http://www.audiomisc.co.uk/asymmetry/asym.html)
I'd bet that this would come out "all zeros" too.

(image from: http://www.audiomisc.co.uk/asymmetry/asym.html)
I'd bet that this would come out "all zeros" too.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: DC offset trickery
This little Nyquist script allows us to see the offset (bias) for each 1/4 of a second of the audio track (mono only).steve wrote:Oops, that shouldn't happen should it?
Or should it?
What has gone wrong here?
Code: Select all
(setq step (round (/ *sound-srate* 4))) ; 1/4 second in samples
(force-srate *sound-srate*
(snd-avg s step step op-average))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: DC offset trickery
Q. That audio sample is not a real recording - you synthesized it to have this problem. Does this ever happen with real audio recordings?
A. Yes I cheated
but yes this can occur (though not usually as badly) if a strongly asymmetric waveform is recorded through a sound card that has very poor linearity. It can also occur is a strongly asymmetric waveform is clipped or peak limited.
It may also occur if audio that has DC offset is gated or subject to some "noise suppression" or "recording enhancement" effects.
(All of which amounts to the same thing: non-linear gain).
Q. Is there a solution?
A. The best solution is to use better recording equipment.
If that is not an option, (for example with audio that has already been recorded), use this Nyquist DC offset tool with the options:
[UPDATE: See here for the updated version of the DC offset tool: http://forum.audacityteam.org/viewtopic ... 96#p193996 ]
The results can be checked using the code snippet in my previous post.
Note: The Nyquist Nyquist DC offset tool should perform better in cases like this than the LASPA dcremove effect.
A. Yes I cheated
It may also occur if audio that has DC offset is gated or subject to some "noise suppression" or "recording enhancement" effects.
(All of which amounts to the same thing: non-linear gain).
Q. Is there a solution?
A. The best solution is to use better recording equipment.
If that is not an option, (for example with audio that has already been recorded), use this Nyquist DC offset tool with the options:
- Remove DC offset
- Abs + Filter
[UPDATE: See here for the updated version of the DC offset tool: http://forum.audacityteam.org/viewtopic ... 96#p193996 ]
The results can be checked using the code snippet in my previous post.
Note: The Nyquist Nyquist DC offset tool should perform better in cases like this than the LASPA dcremove effect.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
kozikowski
- Forum Staff
- Posts: 69372
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: DC offset trickery
I have three now, StarTech ICUSBAudio devices.
http://www.startech.com/Cards-Adapters/ ... ICUSBAUDIO
Apparently, I got one that is just broken. It produces significant DC Offset in the recorded signal. It's going out in the rubbish.
Koz
http://www.startech.com/Cards-Adapters/ ... ICUSBAUDIO
Apparently, I got one that is just broken. It produces significant DC Offset in the recorded signal. It's going out in the rubbish.
Koz
Re: DC offset trickery
Before you trash it, could you post some (uncorrected) audio sample pleasekozikowski wrote:It's going out in the rubbish.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: DC offset trickery
There is now an updated version of the DC Offset tool: http://forum.audacityteam.org/viewtopic ... 13#p195713steve wrote:A. The best solution is to use better recording equipment.
If that is not an option, (for example with audio that has already been recorded), use this Nyquist DC offset tool with the options:
Remove DC offset
Abs + Filter
The new "Dynamic bias adjustment" is likely to produce the best results whenever there is a non-constant DC bias.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: DC offset trickery
There's a lot of interesting detail about "DC bias" in this topic: http://forum.audacityteam.org/viewtopic ... 39&t=65190
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: DC offset trickery
Doesn't the contribution by edgar-rft to the thread referenced above expain what is going on? Surely the asymmetry of peaks above and below the axis is irrelevant to whether there is DC offset? What matters is whether the integral of the waveform over a reasonable length of time is nonzero - think of it in terms of finding the cos nt component in the spectrum when n is zero.
Steve's artifical example in his first graph clearly has more area between the axis and the part of the waveform below the axis than between the axis and the part of the waveform above the axis, despite the above-axis peaks being larger than the below-axis peaks. So the DC offset is negative.
The second graph, over a longer time period, shows patches of a waveform with DC offset mixed with some zero-offset silence, a combination I would be surprised to see in reality in the absence of clipping of a waveform like the Miles Davis example. No surprise at all that applying DC offset correction moves the waveform up not down.
Steve's artifical example in his first graph clearly has more area between the axis and the part of the waveform below the axis than between the axis and the part of the waveform above the axis, despite the above-axis peaks being larger than the below-axis peaks. So the DC offset is negative.
The second graph, over a longer time period, shows patches of a waveform with DC offset mixed with some zero-offset silence, a combination I would be surprised to see in reality in the absence of clipping of a waveform like the Miles Davis example. No surprise at all that applying DC offset correction moves the waveform up not down.