DC offset removal

Effects, Recipes, Interfacing with other software, etc.
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
Post Reply
steve
Site Admin
Posts: 80677
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

DC offset removal

Post by steve » Fri May 29, 2009 4:28 pm

The "Normalize" effect provides an option for "DC Offset" correction, but does this do what we expect?

DC Offset occurs when the recorded signal is incorrectly biased so that it is not centred on the 0.0 centre line. This may be caused by faulty hardware allowing a DC voltage to leak into the signal or other factors and DC Offset correction is designed to repair this.

It appears that inside Audacity the DC Offset correction does exactly as described on the interface: "centre on 0.0 vertically"
That is, it adjusts the waveform vertically so that the average sample value is zero.
It does not necessarily set silent parts to 0.0

In this image we see the waveform of a drum beat. Notice how the initial peak is the largest and is negative.
screenshot.png
drum beats
screenshot.png (15.47 KiB) Viewed 8081 times
Zooming in we can see that the silence between drum beats is at 0.0
screenshot.png
zoom in before DC off-set correction
screenshot.png (19.52 KiB) Viewed 8081 times
However the fact that the initial peak is consistently the highest amplitude and negative causes the average sample value to be negative, so if we apply DC Off-set correction then the silence becomes shifted upward to compensate (as can be seen in this image)
screenshot.png
after DC off-set correction
screenshot.png (19.1 KiB) Viewed 8075 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

kozikowski
Forum Staff
Posts: 68901
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: DC offset removal

Post by kozikowski » Fri May 29, 2009 7:47 pm

Yes, we do need to be careful of our expectations. Square waves of appropriate frequencies will go through a sound system successfully. It's one of the audio tests. Waves need not be symmetrical, either. There is one announcer on KPCC that I can pick out in the middle of an hour show because her voice patterns go negative. unlike everybody else.

After a great deal of arithmetic we also know that you can't tell the DC is missing until you look at a full second or more of the show. Microscopic analysis of a small fraction of a second will tell you nothing, or worse make you come to bad conclusions.

Even more science fiction oddness can be had by knowing you will get what you probably expected all along by applying a filter that deletes everything below audibility -- probably around 15 Hz or so, clearly not DC or battery voltage. That filter will, or should give you the drum tracks that settle with "zero" between them no matter what the rest of the sound channel is doing.

This is why sound channels that go beyond audibility, 20 Hz to 20,000 Hz in either direction are extraordinarily dangerous. Shows that contain battery voltages are just as damaging as ones that contain interference from the local radio station.

Koz

steve
Site Admin
Posts: 80677
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: DC offset removal

Post by steve » Sat May 30, 2009 10:47 am

kozikowski wrote:Even more science fiction oddness can be had by knowing you will get what you probably expected all along by applying a filter that deletes everything below audibility -- probably around 15 Hz
Yes that provides a good alternative to DC Off-Set removal in such cases, though it leaves a bit of a wiggle at the very beginning of the track so it should be applied before trimming silence from the beginning of the recording.

A simple way to apply a low frequency "high pass filter" for anyone that does not have the high-pass filter plug-in is to use the Nyquist prompt. Select the track, then choose "Nyquist prompt" from the effects menu and enter the following command:

Code: Select all

(hp s 20)
This applies a high-pass filter to the sound (mono or stereo) at a frequency of 20Hz.

Filtering out ultra high frequencies can be done a similar way with

Code: Select all

(lp s 16000)
(low-pass filter at 16kHz). Of course, the sampling rate itself imposes a restriction on the upper frequency (the highest frequency possible at a given sample rate is less than half of the sampling frequency), but the real problems that occur from picking up RF are not from recording those ultra high frequencies, but weird types of modulation that they can cause in the recorded audio.

Whether we are looking at frequencies above or below the audio band, it is far better to eliminate them from the source rather than trying to correct them later.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply