Best way to remove distortion from bad 24/16bit conversion.

I have a recording that was done with a 24bit firewire recording system. Although 16bit INT WAV was choosen as the recording file format the software (Ardour) does not seem to have handled the 24bit / 16bit conversion well: Audiolevels exceeding the 16bit value range appear at the “other side” of the curve again - see attached screenshot. Is there any plugin that can detect and eliminate this form of distortion easily ? Currently I go through the samples and use “Repair” - a very laborious task.
clipping.png

The range of 24-bit integer audio is identical to the range of 16-bit integer audio. In both cases, sample values ‘should’ be normalized to a range of +/- 1. This is (should be) achieved by dividing the integer value of the sample by half the maximum value of the integer format, thus “full range”, whether 8, 16, 24 or 32 bit integer, should always be +1 to -1 (in most implementations there is very slightly less than +1 because there is one less positive integer than negative).

So, in short, there is something very wrong with how those 24-bit values have been converted.

There is an experimental version of “Clip Fix” that can repair this type of “overflow inversion”. It’s not ideal in this case because, from your screenshot, it appears that the peaks are perfectly preserved, just that they have “wrapped around”. I’ll see if I can find it (it’s a post somewhere on this forum), but really you need to be looking into fixing the cause of the problem, which I’m guessing is a matter of changing the recording settings in Ardour.

It’s here: Clipfix (see waveform pic) - plugins available? - #72 by steve
Please read the text in that post as it indicates important limitations of the effect.

ESP Clip Fix saved my day :smiley: ! As it says in the quoted post it is not HiFi, but my recording is a voice recording so I am more than satisfied with the outcome. The Plug-In has a tendency to crash Audacity when the selected region is too long (even with 16Gb of RAM), but that is still much more than the 128 samples limitation of “Repair”.
Thanks a lot!

That’s the main reason that it is still buried away on the forum rather than with the “published” plug-in on the Audacity wiki.

Glad it was useful :slight_smile:

You might want to check with the Ardour community to see if they have a fix. It looks like there’s enough “information” in waveform that a programmer could write an algorithm to repair it.

I kind-of know how that’s happening and I don’t think it’s related to the 24-to-16 bit conversion… That shouldn’t be happening and it’s a serious bug! It could be a defective driver, or it could be Ardour. It probably won’t happen if you keep your levels below 0dB. It probably happened in Ardour after recording when you were editing, adjusting levels, mixing, or applying effects, etc. Did you do any of that in Ardour? Did you use any “amateur” 3rd party effect plug-ins?



\

Signed integers are stored in binary as [u]two’s compliment[/u] where the most significant bit is the sign bit.

So for example, if you make a “dumb” integer-counter program that “counts-up forever”, at some point the counter overflows and “rolls over”, the sign-bit becomes one (indicating a negative) and it starts with the maximum negative number and starts counting-down* with a negative sign (technically it’s counting-up, getting less negative). When it gets back to zero the cycle starts-over.


That’s exactly what you’re seeing… Binary roll-over… With audio, this can happen if you digitally boost the gain, or boost the bass, or mix, or do anything that pushes the levels above the maximum (0dBFS). But, the programmer should be careful about how “overflow” is handled.

Audio software should not “roll over”, but it should [u]clip[/u]. Clipping is undesirable too, but it doesn’t sound as bad as roll-over.

Note that Audacity (like most audio editors) uses floating-point internally so Audacity itself won’t clip or roll-over. But, “regular” WAV files, your ADC, and your DAC will all clip at 0dB.



\

  • If it were “normal” one’s compliment, the sign bit would flip to 1, and it would start counting negative numbers “up” from “negative zero”.

I have created a post in the Ardour forum - lets see if this is known to them. The rollover happens in or before Ardour records because I can see the strange waveforms alredy when I zoom in on Ardour.

If you could post a short sample in WAV format, I may be able to provide a better quality way to fix it.
See here for how to attach an audio sample (must be WAV format in this case, not MP3) https://forum.audacityteam.org/t/how-to-post-an-audio-sample/29851/1