Skip to main content
Topic: Ogg: Lossy compression - a weapon against hard clipping? (Read 1017 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Ogg: Lossy compression - a weapon against hard clipping?

Hi all,
 
I've recently bought an album (Scarab - Martyrs of the Storm) and noticed extreme clipping in the mastered audio.
 
This is nothing particularly new - especially rock songs suffer from loud, compressed mastering a lot ("Death Magnetic"), but this was the worst case I've heard, yet.
 
To my knowledge, there is no real way to fix this type of distortion, since it isn't caused by my software or audio equipment, but written into the actual audio data. I got very upset, because I like the music a lot, but the constant scratching quite ruined the experience and my in-ear headphones made the clipping sound even worse, almost unlistenable.
 
Then I remembered that I once heard a song on Youtube that I know had clipping at one point and was surprised that I almost couldn't hear it online, I assumed because of the lossy compression at 480p. Unfortunately, I can't remember which exact song that was.
 
I thought it was at least a bit logical to just try it out and sure enough: As I re-encoded the album in Ogg Vorbis -q 4, the clipping got much less pronounced.
 
There is a noticeable degradation in quality as well, especially in the high-end, but the music is at least listenable, especially on my headphones, which I took as the determining factor for me.
 
I've also tried encoding the album as MP3s, but with lower bitrates, the sound just got progessively worse without actually diminishing the clipping and just introducing more audible artifacts.
 
Currently, I'm trying different quality levels to find out where the sweet spot between the subjectively unlistenable FLACs and Vorbis is. I wonder if this could be related to the lowpass that Vorbis introduces at -q 6, which also already seems to reduce the scratching a bit, compared to the lossless versions.
 
I've also dug out some other albums that have always annoyed me because of their clipping sound (Arch Enemy - Stigmata & Nile - In Their Darkened Shrines) and am testing different quality levels, but I'm still unsure what actually works and where my ears might just trick me.
 
Has anybody else tried using lossy compression in this way before?
 
I haven't tried out Opus yet, because I've never used it, but I also want to look into it. Could that work even better?
 
Also, this is a very subjective list, of course. Is someone in a similar situation and would be willing to do some tests with their selection of songs or post them for me to try? I'd be interested in the results.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #1
Didn't notice that when I was using Vorbis. Also I don't see any reasons why would it genuinely "fix" the clipping instead of just adding more (different) noise or distortion. 
I agree, sometimes there's audible distortion from clipping, but it's a bit more involved to actually improve this and requires manual editing. (and the result still isn't going to be very good, sometimes it can be even worse than original)
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #2
Hi Magicgoose,
 
Also I don't see any reasons why would it genuinely "fix" the clipping instead of just adding more (different) noise or distortion.

I think that's exactly what happens. Sorry if I've been a little vague or too euphoric in my descriptions, but I think you're right. My (layman's) assumption is that because of the lowered frequency range and available bitrate, the algorithm tries to find new spaces for what's left of the clipped signal and, as a result, spaces it out more, thereby reducing the perceived severity of it. It can't really "fix" the signal in the literal sense, it just happens to have a beneficial effect on the harshness of the distortion.
 
 
I agree, sometimes there's audible distortion from clipping, but it's a bit more involved to actually improve this and requires manual editing. (and the result still isn't going to be very good, sometimes it can be even worse than original)

 
I understand that. The results can't really be tweaked manually, so it can be a matter of hit and miss. However, I've tried it with the aforementioned examples and so far, I've had great results. The effect is very subjective and there is definitely a loss of clarity involved, but to me, that is a fair trade-off for audibly reduced clipping in my ears, especially when the source is not a perfect, crystal-clear production, anyway. Also, the reduced bitrate does not really have that bad of an impact with Vorbis, I have to say.
 
I'm thinking about making a little comparison clip later to show the difference where it's most perceptible.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #3
Try a good dedicated declipper tool: Stereo Tool, Izotope RX, or Acon Digital. Set the threshold such that only the clipped samples are affected. Lossy compression will kinda spread the distortion in time, but it is still there, and the whole signal gets degraded.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #4
please be aware that Stereo Tool is extremely hard to configure and also it adds unavoidable changes to good segments as well. (so, it could easily do more harm than good)
Izotope has a different drawback - the restoration doesn't seem to respect the condition that restored amplitude must not be smaller than original, and because of that it sometimes does the opposite (amplifies distortion even more). This can be somewhat countered by additional processing when you take the original and processed files and replace samples with original samples where the "restoration" produced incorrect values, but this isn't a truly good solution even with this workaround.

(haven't tried Acon, can't say anything about it)
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #5
upd.: Acon seems to suffer from the same issue as Izotope, so, I suppose there isn't a truly good software which could do this
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)


Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #7
Hey, so I just quickly put together a couple of samples and attached them. The first one is always the original lossless FLAC ripped from the CD and the second pass is a Vorbis at Q4. I also normalized all of the tracks (not individually), so it's a bit quiet.
 
Now, the clipping is not entirely gone all the time and the sound is still somewhat crunched from the compression, but the distortion is much less harsh in certain spots and on the length of a whole song, the Vorbisses are much more listenable. Especially, as I mentioned, with bad headphones that basically just output high-frequency static otherwise.
 
This was just a quick Q4-encode and I haven't played around with any parameters at all, so maybe there's more to get out of that, considering Q5+ is supposed to be transparent, mostly. I don't know were to start, though. Maybe with the lowpass?
 
 
Would using clip_fix in Audacity work in this context? https://manual.audacityteam.org/man/clip_fix.html


When I cut together the clips in Audacity, I quickly tried it on the FLACs, but it actually just made it worse.
 
Maybe I've used it wrong, but the distortion was still very audible and it just introduced more artifacts for me, there isn't really much to set up in the plugin.
 
 
Try a good dedicated declipper tool: Stereo Tool, Izotope RX, or Acon Digital. Set the threshold such that only the clipped samples are affected.

Well, those are all quite expensive pieces of software.
 
I suppose it could be worth it, but without knowing which one works best and having to spend the money and time to learn how to use them correctly seems a bit excessive to "fix someone else's mistakes", in a way.
 
Also, since it's not just one small part, but the whole song, even album, I don't know how difficult that would get if it needs to be edited manually.
 
Re-encoding them as Ogg Vorbis is a super quick improvement already, to me, which takes less than a minute.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #8
Another, perhaps unpopular option, is to listen to... some different music :)
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #9
Yes, I did expect this comment.. It is too late for me, child.
 
Just be glad that I tried to leave out the vocal parts, although those also have an impact on the perceived quality. Anyway, that's what was available and has been bothering me for a while. I don't know which other genres suffer similar issues.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #10
Looks like Acon came later and copied Izotope. They both restore distortion on tonal segments, such as vocals, where there are multiple short, repeated cycles, but do nothing to restore bass.

Stereo Tool does also restore bass with a couple clipped cycles, which may result in too much bass. Such extremely distorted clips usually can't be restored satisfactory. It is meant to be set up once and left alone to work automatically at a radio station, and detect clipping at various levels. To prevent it from acting on signal below the clipping threshold, set the Sample Not Clipped If Below (in Advanced Operating Mode) to slightly below the clipping. The other thresholds are linear, relative to detected peak level. It will change the samples surrounding repaired regions because it runs the signal through an inverse fourier transform, but the change is less than from a lossy codec. Also switch the Tilt Detection off. No manual editing is required apart from adjusting the threshold if the clipping level changes. You can evaluate the demo version.

Another option worth considering is CoolEditPro / Adobe Audition. This tool is very old. I don't have much experience with it. It seemed to perform worse a few times I tried it.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #11
It will change the samples surrounding repaired regions because it runs the signal through an inverse fourier transform, but the change is less than from a lossy codec.
this is exactly what I was talking about. so there's no way to disable that, right?
(are you the developer of this tool?)
theoretically it could do something simple like: copy non clipped samples as is from the original version... because the plugin surely "knows" which samples it considered not clipped

Another option worth considering is CoolEditPro / Adobe Audition. This tool is very old. I don't have much experience with it. It seemed to perform worse a few times I tried it.

it's terrible, yeah. IIRC what it does is to insert a (quadratic?) smooth ramp, sometimes with inappropriate sizes. it doesn't restore HF "interruptions" on long clipped regions, and very often produces results that sound worse than original.
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #12
I went ahead and passed that sample file you supplied through my Stereo Tool settings. I do have Auto EQ enabled, so that might change the sound a bit too much for you.
Anyway, the first track still has something annoying going on, but the other two sound okay to me. It's kind of hard to be sure without a little longer sample of the worst sounding sections.
Processed audio in java and python.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #13
Quote
When I cut together the clips in Audacity, I quickly tried it on the FLACs, but it actually just made it worse.
I've tried Audacity's Clip Fix a couple of times on "distorted" CDs.   It made the waveform look better but it didn't improve the sound.  (But it my case didn't make it worse either.)    

Of course, you do have to reduce the amplitude to make headroom for the "restored" peaks. 

I assume the "big problem" is that it's not simply clean-clipping.   There is probably tons of compression & limiting and possibly multiband compression and maybe excessive compression/limiting on the individual tracks before mixing.   Even with clean clipping there is no way to know the original height or shape of the original-unclipped waveform.

...I just tried an experiment.   I generated a 1kHz 0dB sine wave , amplified it by 6dB and exported as WAV to make a badly clipped wave.     Clip Fix restored the wave to look exactly like the un-amplified original!    But when I tried a sawtooth wave the "restored" wave looked like an attenuated sine wave (not what I was expecting). 


 
Maybe I've used it wrong, but the distortion was still very audible and it just introduced more artifacts for me, there isn't really much to set up in the plugin.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #14
Quote
It made the waveform look better but it didn't improve the sound.  (But in my case didn't make it worse either.)    
Yeah, I kind of agree. For the most part, if you don't notice the clipping while it's present, a good declipper will just make it so that there is less noise at louder volumes. As in: I've found that songs tend to sound more clear after being declipped, but mostly only when I turn them up really loud. (I may be hearing that because I want to hear an improvement.) So far I have not run across any songs that sound worse with it.

With Stereo Tool, there is the ability to tune the declipper so that it does the best it can for one album, but that does not mean it will do the same great job on another. And yeah, there are several clips that are unrecoverable. I know I don't have the time to go tuning for each album I own. I just tuned it for the main offenders and let it run on everything. The main offenders still sound distorted, but not quite as bad.
Processed audio in java and python.

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #15
I know I don't have the time to go tuning for each album I own. I just tuned it for the main offenders and let it run on everything. The main offenders still sound distorted, but not quite as bad.
You have a very high chance to unnecessarily ruin recordings which are good to begin with. (This thing is always going to have some false positives, because it has to "guess" where is clipping and it's not so simple, unless you aim only for the absolutely straight lines...)
A better strategy is to, at least, process the "offending" stuff ahead of time and turn it off for everything else.
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: Ogg: Lossy compression - a weapon against hard clipping?

Reply #16
I was worried about that at first. I ran it on the best recordings I have, and can not tell any difference.
Processed audio in java and python.

 
SimplePortal 1.0.0 RC1 © 2008-2020