DC offset tool (plug-in)

There have been request for a separate DC offset tool, so this plug-in addresses that need.
As well as being able to remove DC offset, there have also been requests for adding DC offset, to this tool addresses that need also.

The Normalization effect provides “absolute” DC-offset correction (combined with Normalization). That is, after DC offset correction, the average sample value is zero.
When this method is required the Normalization tool may be preferable because it is faster.

Other methods of DC off-set removal are possible and may be preferable in some situations.
One method that has apparently been requested by people recording brass instruments is using a low frequency high pass filter.
This method will tend to shift the phase of low frequencies that may help to “even out” positive and negative going waveforms for an asymmetric input signal.

Another method, while not strictly being “DC removal” but may be useful when working with synthetic tones or non-audio signals is to make the greatest positive peak of equal amplitude to the greatest negative going peak. I have called this method “Equal +/- Peaks”.

One drawback of high-pass filtering is that it takes a little time for an offset signal to be centred so the initial part of the selection is not corrected. To alleviate this drawback this tool also allows “absolute” DC correction, followed by high-pass filtering.

Where an absolute amount of DC offset is required, the plug-in can remove any existing DC offset, and then add the required amount of DC offset.

This effect works on stereo channels independently (I couldn’t think of any situations where a user might want it otherwise, but in an exceptional case the user could split the track).
dc-offset.ny (1.56 KB)
Current Version: dc-offset.ny
This version has Dynamic bias correction as default (rather than calculating the absolute DC offset for the entire selection it calculates a rolling average, then compensates accordingly).

Yebbut - the related issue is that the Normalize effect will still carry the DC Removal functionality :frowning:

On a related note, I see that the soundcard software on my latest Tosh laptop has a DCoffset removal feature in the Recording>Stereo Mix>Enhancements tab (default set to on) useful eh …

It also has a Disable all sound effects on that tab which could also be useful (default set to off)


If the original level is low, normalizing will make any DC offset worse unless there is an option to remove it. An insignificant amount of DC offset may become significant after normalizing, so I think that whether there is a dedicated DC offset tool or not it is a useful feature in the Normalize effect.

Yes, useful. That seems to be quite a common feature on modern Windows machines, so we should perhaps encourage users to use it (I think there is already a note about this somewhere in the documentation).

When enabled that will probably also disable the DC offset removal.

Any feedback about this plug-in anyone?

OIC - fair enough (I’m minded to agree - I may thus need to revisit the proposals in the Wiki relating to this)

I’ll look into that in the manual to see if it is sufficient or needs updating

Actually from looking at the controls on the tab the DC removal appears to be independent of the Disable Sound Effects setting.


That’s a interesting and versatile tool. I normally do not worry very much about DC offset (quite logical if you don’t see the waveform). However, the tool is a eye opener to some degree.
The equal amplitude option confused me at first. Am I right in saying that it will center the signal in regard to the 0 amp line? That is, if you have a positive peak of 0.7 and a negative of 0.6 that both will end up at (-) 0.65, right?
As far as I can see, the shifting of the sound will result in a new DC offset. Or will the signal be average zero? At least all (digital) silence will afterwards be off by the shift amount.
I could imagine an additional feature that is based on the equal peaks option. Instead of shifting the signal, the positive and negative parts could be multiplied independently to match the average peak and thus preserve all 0 value samples.
Another thing that comes to my mind is the case where you have a track that is composed from different sources. if there is a clip with a fair amount of DC offset, any attempted correction must fail, since the clean signal will be shifted to the opposite side of the offset.
I know, some say that a offset that doesn’t last the whole signal is no DC offset but I am not of this opinion and the speaker membran would surely agree with me.
I fancy that such issues via the ratio of the average peaks of the positive and negative bands of the signal could be identified and also corrected, maybe within a new plug-in.

Though it would still be important if you recorded with a sound card that had a significant amount of DC offset.
DC offset is a common reasons for clicks at edit points. Often one would try to edit at places where the audio signal is close to silence but if there is significant DC offset then “silence” will be offset from the -infinity dB line and will cause a click if it is edited next to audio that has a different amount of DC offset.

Yes that is correct.
Strictly speaking this is not DC offset removal and in some cases may create DC offset. Many waveforms are asymmetric (have peaks that are greater in one direction than the other). This may be useful if maximum amplitude is required in a situation where DC offset is unimportant.

Yes, both viewpoints are valid in my opinion. Over a short time period, very low frequency or an “offset drift” can be considered to be DC, and will burn out woofer coils in the same way that DC will. The low-frequency high-pass filter is often a good option for dealing with this type of problem.

Having looked at the proposal in the Wiki I see it already says this: Missing features - Audacity Support :blush: :blush:


I couldn’t find any reference to this in the documentation so I added a note div in several appropriate places in both the Manual and the Wiki (see Recent Changes logs).


New version.
dc-offset.ny (1.97 KB)
This version has a new method for DC offset removal which I’ve called “Dynamic” offset removal. It is a hybrid method that is designed to overcome the limitations of the conventional methods. My initial tests look good so I have made it the default.

Dynamic bias correction:
Rather than calculating the absolute DC offset for the entire selection it calculates a rolling average, then compensates accordingly.
The advantages of this method are that it can cope much better with non-constant bias than either the “absolute” method (as used in the Audacity Normalize effect) or the high pass filter method (as used by the LADSPA dcremove effect).

Steve - are you planning to punt this as a potential replacement for the existing Audacity Normalize effect’s DC removal option?


I thought you wanted a separate (additional) tool for removing DC offset.

I think that (basic) DC offset correction should be a feature of the Normalize effect. The Normalize effect should not normally amplify any DC component to the signal, so usually the DC component should be removed by Normalize. However, this is established as an option and making it an “always on” feature would probably be seen as regression, even if there is a separate bias removal tool. Also, there may be (rare) cases where Normalizing without removing DC is required (though this is likely to be with test signals rather than audio).

I don’t think that the basic DC removal offered in the Normalize effect should be the only bias correction tool available.

  1. New users are unlikely to look in “Normalize” if they want “DC offset correction”.
  2. The current DC offset correction cannot handle non-constant DC bias.
  3. High Pass filtering cannot correct the start of the selection or track.

I do, I do :sunglasses:

+1 (and my proposal in the Wiki supports this retention)

+1 to all that



there is a typo in the header of the dialog box, where it says: "DC Offst…" ( with a missing e )

and similarly in the command listed in the Effect menu :confused:

I was about to take this image as a proposed GUI in the Wiki proposal: http://wiki.audacityteam.org/wiki/Proposal_DC_Offset_removal#Details

But I will hold off until the typo is fixed.


From looking at this new effect I am failing to understand why I might want to add DC offset :confused:

What am I missing here ? :confused: :confused:


Oops :blush: Thanks.

“You” probably never would.

There are probably not many common uses for adding an offset, but as it is intended to be a “full featured” DC offset tool I decided to include it. If the feature is not included in this tool, then where would a user find it if they do want to add an offset?

One example that comes to mind is for control signals.
Some time ago someone on the forum was using Audacity to send IR remote signals. They used a square wave to drive an IR diode.
It’s easy enough to generate a square wave with the Tone generator, but (without entering Nyquist code) how would you generate a square wave that goes from 0 to +1?
Answer: Generate a square wave with an amplitude of 0.5 and then add an offset of 0.5

Here’s the updated version with the typo correction:
dc-offset.ny (2.1 KB)
And here is a simplified version that only has bias removal, no option to add DC and less removal method options:
dc-remove.ny (2.21 KB)

Haha … :laughing:

Ah, but I’ve just found a a use - I needed to add some DC with the "DC offset…" so that I could test the "DC bias removal…" :ugeek: :sunglasses:

Both appear to work ok on my tests.

I note from a comment by Gale (on the Wiki I think) that he doesn’t like the use of the nomenclature “DC bias” and I’m minded to agree - that’s one reason why I haven’t yet added the image to the DC offset removal proposal in the Wiki.

I’m guessing that you’ve done that to differentiate the two effects - but …


and I’ve probably used it more for that same reason than any other.

Re. the nomenclature:

If you say “DC offset” to any of the developers, they will immediately think “constant offset” and will be without any doubt that that is what is meant. Technically they are absolutely correct. As described in Wikipedia http://en.wikipedia.org/wiki/DC_bias:

When describing a periodic function in the frequency domain, the DC bias, DC component, DC offset, or DC coefficient is the mean value of the waveform. If the mean amplitude is zero, there is no DC offset. In contrast, various other frequencies are analogous to superimposed AC voltages or currents, hence called AC components or AC coefficients.

The practical situation is not so clear cut.

“Audio” is defined as “audible” frequencies, hence the “audio range” of 20 Hz - 20 kHz.
“Direct Current” (DC) is not necessarily a constant voltage - many (most?) DC circuits exhibit non-constant voltage. If I have a 1.5 (DC) battery and connect it to a circuit, the voltage will drop initially to a little below 1.5 volts (due to the “load” of the circuit) and then gradually diminish to 0 v as the battery goes flat. This is not AC (Alternating Current) because the current is all in one direction between the positive and negative terminals of the battery, but it is not “constant” either - it is gradually changing (in this example, diminishing).

How should we refer to a “non-constant DC offset” and distinguish it from a “constant DC component”?
For want of a better word I suggested “bias”.
Any better ideas?

Well that would depend on just what we are trying to remove/correct for the user.

Is that the constant or the non-constant variety? I’m no expert here :confused:

I do note that the the Realtek soundcard on my Tosh laptop offers (by default) to perform “DC Offset Cancellation” for the Stereo Mix on recording - and on the Mic - but I have no line-in device connected, indeed I have no line in on the laptop.


Koz has frequently stated that “DC is not audio” and that the sound card has no right to pass anything below 20 Hz.

The first statement is inarguably correct.
The second statement may be open to a little difference of opinion, but basically for “audio” recording you do not want any signal below about 20 Hz, so that includes constant DC and non-constant offset. For “audio”, unless it has an alternating frequency above 20 Hz, you don’t want it and it should be removed.

Unfortunately, although a 20 Hz high-pass filter might appear to be a simple solution, it is not a complete solution.

Some limitations of high pass filtering:

  1. There is no such thing as a “perfect” filter. All filters have a “roll-off” response. You cannot suddenly cut off frequencies at a certain point, the best that you can do is to progressively reduce frequencies below a certain point. Frequencies just above the “filter frequency” are also reduced and frequencies just below the “filter frequency” are not completely removed, just reduced a bit.

  2. When you press the record button, there may be DC offset present immediately, but filters operate in the time domain and cannot respond immediately. In non-technical description, they take a little time to settle.
    To illustrate, here is a picture of what happens in the first 1 second with a steep (48 dB per octave) 10 Hz high pass filter applied to a DC offset of 0.5

  3. Filters introduce “phase shift”. They introduce a frequency dependent delay to the signal.
    Here is a 100 Hz square wave before and after filtering with a 10 Hz filter:
    Notice how the peak amplitude is much higher after filtering, so even though the phase shift may be inaudible, it could create significant clipping.
    It also looks nothing like the waveform that we were expecting.

I think that the idea that Audacity should be doing this by default is highly questionable.