audacity / audacity

Audio Editor
https://wiki.audacityteam.org/wiki/For_Developers
Other
12.28k stars 2.25k forks source link

Add DC Offset removal effect #2408

Open petersampsonaudacity opened 2 years ago

petersampsonaudacity commented 2 years ago

Describe the bug DC offset removal is only bundled in the Normalize effect. This leads to DC offset not being done at all, or being done too late as a final editing step in Normalize.

DC on the signal should be removed early in the editing process but it is often overlooked by users as it is "hidden" in an effect normally used late in the editing process. Note that DC offset is not audible (so may not be corrected by the user) but reduces headroom for subsequent processing

This was originally logged as a Proposal in 2011 in the Audacity Wiki.

To Reproduce Steps to reproduce the behavior:

  1. Look for a command in the menus for DC Offset Removal
  2. Observe: you won't find one

Expected behavior

  1. Create a new command for Remove DC offset
  2. arguable as to whether it should be in the Effect menu or the Tools menu
  3. remove the DC offset option from the Normalize effect

Screenshots image

image

Additional information (please complete the following information):

Additional context Could be automatically invoked immediately post-capture, or post import, if Audacity detects significant DC (to nudge the user into optionally dealing with it).

werame commented 2 years ago

Can you clarify what you mean by the first two algorithms "dynamic bias adjust" and "absolute offset"?

SuperCollider only does the 3rd one IIRC, as LeakDC. Some useful discussion (in that context) regarding algorithms here: https://scsynth.org/t/why-leakdc-and-not-a-standard-hpf-for-dc-removal/4780/

SteveDaulton commented 2 years ago

Can you clarify what you mean by the first two algorithms "dynamic bias adjust" and "absolute offset"?

That came from some experiments that I tried over a decade ago. (The original posts are somewhere on the Audacity forum).

If I recall correctly, "dynamic bias adjust" measured the amount DC bias over the first part of the selection, and applied compensation. It would then repeat the process on blocks of data, updating the bias correction as it went - in effect, a very low frequency high-pass filter, but with the advantage that it looked ahead to determine the required bias correction, so no click at the start.

"Absolute offset" was (probably) adjusting the DC offset so that the highest positive peak is equal to the lowest negative peak. This does not necessarily remove DC (in fact it may introduce DC offset), but it allows maximum amplification before clipping.

werame commented 2 years ago

That's what I thought about the last para. Basically global vs local offset in a certain time window. Sane audio hardware compensates for the later with some output caps anyway. Fairly easy to measure with an oscope or even a voltage meter with memory or at least fast updates if it's a digital VM. Have done this for my own hardware out of curiosity in the past.

I'll check out the forum for details on the rest.

SteveDaulton commented 2 years ago

Sane audio hardware compensates for the later with some output caps anyway.

Caps leak. Cheap caps can leak significantly. High quality audio interfaces often use dual power rails and high quality "audio" caps to minimise DC offset.

I'll check out the forum for details on the rest.

This is probably the most relevant topic: https://forum.audacityteam.org/viewtopic.php?f=42&t=68463 (not quite a decade ago ;-)

JC3 commented 1 year ago

Rather than implementing this as a new effect, does it make more sense to include one of the DC Offset Nyquist plugins on the forum in the standard distribution?

petersampsonaudacity commented 1 year ago

Personally I'd prefer it as a new effect - so that way it gets more prominence, is more "discoverable"

JC3 commented 1 year ago

@petersampsonaudacity For the correction / removal operation, would you prefer "correct DC offset to X dB" (default X=0), or simply "remove DC offset"? The former allows specification of the new target offset, the latter hard codes the target to 0 but is a simpler UI choice.

The code should end up virtually the same either way, it's just a UI choice: simplicity vs. flexibility. I prefer the former option, but I don't know the user base well.

petersampsonaudacity commented 1 year ago

@JC3 I guess it depends of one wants to have a command that also creates DC offset as well as removing it.

For my money I would have:

a) simple DC Offset Removal with "Remove DC offset"

b) then if we wanted a tool to create DC offset (for testing or other purposes) a Nyquist plugin could be written for that, provided as an optional plugin that users can add if and when required - as it is somewhat of a niche piece of functionality.

ygoe commented 1 year ago

I'd rather like to see a manual DC offset setting. It completely fails for me now. There's a slight positive offset in a file I have, but it's not removed at all. I need to tell it how to offset the samples to make it work.