Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Conmand Line remove DC offset (Read 10655 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Conmand Line remove DC offset

Hi,

I'm looking for a Windows command line program that can remove DC Offset from a 44.1 KHz, 16-bit Wav file before normalizing it to 0dB (I use https://neon1.net/prog/normalizer.html for that).

I haven't found a good candidate other than WaveGain, but I can't get WaveGain to normalize to 0dB, which leaves me the option to nomalize a seconds time with normalizer,
but I'm not sure whether the sound quality will suffer from that.

Does anyone know of a freeware/open source command line, that simply removes DC offset from a file?

Regards,

Fred

Conmand Line remove DC offset

Reply #1
Try Sox
.halverhahn

Conmand Line remove DC offset

Reply #2
Wouldn't it make more sense to adjust the offset to make the maximum positive and negative values equal? Then when you normalize you get the maximum possible amplitude without clipping.

Conmand Line remove DC offset

Reply #3
Wouldn't it make more sense to adjust the offset to make the maximum positive and negative values equal? Then when you normalize you get the maximum possible amplitude without clipping.


Sure thing - but how do I do that?

I have looked at SoX, but how would I use the dcshift command in order to obtain equal max negative and positive values?

/Fred

Conmand Line remove DC offset

Reply #4
NOTE - I've never used SOX.

Quote
I have looked at SoX, but how would I use the dcshift command in order to obtain equal max negative and positive values?
You generally should NOT do that!  You can end-up introducing a constant DC offset.  When you do that, you are creating an offset that includes any  beginning/ending silence and you can get a "tick" at the beginning/end of the file.  So, you should only use offset correction when there is truly a DC offset, not for "correcting" asymmetrical waveforms.

Sometimes a high-pass filter (with a cutoff somewhere below 20Hz) does a reasonable job of "balancing" asymmetric waveforms, but it won't guarantee that your +/- peaks are exactly equal.

Conmand Line remove DC offset

Reply #5
You generally should NOT do that! You can end-up introducing a constant DC offset.  When you do that, you are creating an offset that includes any  beginning/ending silence and you can get a "tick" at the beginning/end of the file.  So, you should only use offset correction when there is truly a DC offset, not for "correcting" asymmetrical waveforms.

Yes, I see your point. That is not the way to go. SoX dcshift doesn't seems to be the right way to go. I guess I will have to use wavegain, that does some gaining and removes DC Offset and then normalizing it to 0dB with normalizer. I hope gaining twice doesn't have an impact on the audio quality.
After this I encode the wav file to AAC - but I don't know whether DC Offset can be a problem after transcoding to AAC...?

/Fred

Conmand Line remove DC offset

Reply #6
Nobody has asked so I will. Why do you need to remove DC offset?

Be aware that if you remove DC offset from a full-scale digital signal, you are likely to introduce clipping. From your proposed processing order, it sounds like you understand this.

Conmand Line remove DC offset

Reply #7
Nobody has asked so I will. Why do you need to remove DC offset?

Be aware that if you remove DC offset from a full-scale digital signal, you are likely to introduce clipping. From your proposed processing order, it sounds like you understand this.


Well I get audio from various sources - and none are close to 0dB, so removing whatever offset there might be before normalizing just seems like a good thing to do. I'm sure that in most cases it does not make any difference but since I batch transcode alot of audio, it just seemed like a good extra step to include - or?

Fred

Conmand Line remove DC offset

Reply #8
Well, I don't think it will hurt anything. Offset will usually be removed by playback equipment. Offset can be an actual problem if you're editing together pieces that have different offsets. Normalizing does not improve audio quality and it does not equalize loudness.

Conmand Line remove DC offset

Reply #9
Hi,

I'm looking for a Windows command line program that can remove DC Offset from a 44.1 KHz, 16-bit Wav file before normalizing it to 0dB (I use https://neon1.net/prog/normalizer.html for that).

I haven't found a good candidate other than WaveGain, but I can't get WaveGain to normalize to 0dB, which leaves me the option to nomalize a seconds time with normalizer,
but I'm not sure whether the sound quality will suffer from that.

Does anyone know of a freeware/open source command line, that simply removes DC offset from a file?

Regards,

Fred


You can use WaveGain to have a gain=0dB during execution. To do this:

example: (use WaveGain v1.2.6 Compiled Nov 25 2005.)
1) WaveGain.exe 01.wav
  Analyzing...

    Gain  |  Peak  | Scale | New Peak |Left DC|Right DC| Track
          |        |      |          |Offset | Offset | Track
--------------------------------------------------------------
  -9.91 dB |  32392 |  0.32 |    10350 |  -23  |  -23  | 01.wav

2) WaveGain.exe -g 9.91 -y 01.wav
    where: 9.91 = 0 - (-9.91)
Analyzing...

    Gain  |  Peak  | Scale | New Peak |Left DC|Right DC| Track
          |        |      |          |Offset | Offset | Track
--------------------------------------------------------------
  -0.00 dB |  32392 |  1.00 |    32392 |  -23  |  -23  | 01.wav

Applying Gain of -0.00 dB to file: 01.wav
This file 100% done    All files  99% done
WaveGain Processing completed normally

3) WaveGain.exe 01.wav
Analyzing...

    Gain  |  Peak  | Scale | New Peak |Left DC|Right DC| Track
          |        |      |          |Offset | Offset | Track
--------------------------------------------------------------
  -9.91 dB |  32416 |  0.32 |    10358 |    0  |    0  | 01.wav

 

Conmand Line remove DC offset

Reply #10
Wouldn't it make more sense to adjust the offset to make the maximum positive and negative values equal? Then when you normalize you get the maximum possible amplitude without clipping.


Audio waveforms are often asymmetrical.  Doing what you suggest might introduce a DC offset that would result in a pop if you shortened the wave or tried to splice a piece of it into some other wave form.