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: Ogg Vorbis & clipping ? (Read 10457 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Ogg Vorbis & clipping ?

Other formats such as Mp3 and also Mpc streamversion 7 suffer to a certain degree  of signal clipping, either in the encoding or in the decoding process.  I didn't read anything on this topic concerning Ogg Vorbis until now. Neither the encoder, nor the decoder, nor Vorbisgain report any clipping problems. My question is: Is the Ogg Vorbis format clipping-free by design, or is the problem simply ignored ?

Ogg Vorbis & clipping ?

Reply #1
Data is stored in floating point in the vorbis codec, so I don't believe that internal clipping is an issue at all.  Of course, if something is going to cause clipping on decode, then you'll need something to prevent it there, such as ReplayGain.

Ogg Vorbis & clipping ?

Reply #2
If you decode with (my)oggdec or oggdropXPd, there is clipping prevention by way of a hard limiter automatically applied. The official oggdec also has this.

Ogg Vorbis & clipping ?

Reply #3
Before I encode my music I always normalize to 98%.

I've used this method since I use MPC and for OGG I do the same, just in case.

If you normalize at 98% you can always be sure the sound is good !

Ogg Vorbis & clipping ?

Reply #4
Quote
Originally posted by Fairy
Before I encode my music I always normalize to 98%.

I've used this method since I use MPC and for OGG I do the same, just in case.

If you normalize at 98% you can always be sure the sound is good !


This is a much inferior method to ReplayGain, it degrades quality and it does not prevent clipping on playback.

Ogg Vorbis & clipping ?

Reply #5
Quote
Before I encode my music I always normalize to 98%.

I've used this method since I use MPC and for OGG I do the same, just in case.

If you normalize at 98% you can always be sure the sound is good !

That's incorrect. I'm glad you didn't say "normalizing the files to 98% makes the files equally loud", because that's a very popular misconception.

Peak level normalisation is not a good idea. If your target peak level is 98%, you can be sure that there is at least the risk of clipping. Apart from that, direct signal normalisation is irreversible, so you "damage" the signal forever.

Use MP3Gain / VorbisGain.exe / ReplayGain.exe for your MP3 / Vorbis / MPC files, that's the safest and best method.

Ogg Vorbis & clipping ?

Reply #6
Quote
Originally posted by john33
If you decode with (my)oggdec or oggdropXPd, there is clipping prevention by way of a hard limiter automatically applied. The official oggdec also has this.


I'm not sure you understand what a hard limiter means, because the official oggdec certainly hasn't got one...

--
GCP

Ogg Vorbis & clipping ?

Reply #7
Quote
I'm not sure you understand what a hard limiter means, because the official oggdec certainly hasn't got one...

This is why he wrote '(my)' - there's more than one thing out there called 'oggdec'

Ogg Vorbis & clipping ?

Reply #8
Quote
Originally posted by Jon Ingram

This is why he wrote '(my)' - there's more than one thing out there called 'oggdec'


Reread what he wrote...there is only one official oggdec

--
GCP

Ogg Vorbis & clipping ?

Reply #9
Quote
Reread what he wrote...there is only one official oggdec



I now go to take remedial reading comprehension lessons.

Ogg Vorbis & clipping ?

Reply #10
Extract from decoder_example.c:
Code: [Select]
      /* might as well guard against clipping */

     if(val>32767){

       val=32767;

       clipflag=1;

     }

     if(val<-32768){

       val=-32768;

       clipflag=1;

Extract from vorbisfile.c (ov_read):
Code: [Select]
     for(i=0;i<channels;i++) { /* It's faster in this order */

      float *src=pcm[i];

      short *dest=((short *)buffer)+i;

      for(j=0;j<samples;j++) {

 val=vorbis_ftoi(src[j]*32768.f);

 if(val>32767)val=32767;

 else if(val<-32768)val=-32768;

 *dest=val;

 dest+=channels;

      }

    }

What is this about then????

Ogg Vorbis & clipping ?

Reply #11
Quote
Originally posted by john33

What is this about then????


This is to prevent wraparound, i.e. so a sample value > 32767 doesn't get wrapped around to -32766 or so. The distortions from wraparound would make clipping look like child's play

Setting something > 32767 to = 32767 is still clipping, though.

--
GCP

Ogg Vorbis & clipping ?

Reply #12
>>Peak level normalisation is not a good idea. If your target peak level is 98%, you >>can be sure that there is at least the risk of clipping.

I'm not sure there is a risk. When you use EAC and normalize to 98% - EAC first reads (or remembers from ripping the wav) the file to determines the maximum integer value. It then figures out the difference between the max value and 98% of (2^16)/2 and then raises (+/- relative to x axis (=0)) all values by that much (Bad thing: raises the noise floor, too). How could clipping occur?

Xenno
No one can be told what Ogg Vorbis is...you have to hear it for yourself
- Morpheus

Ogg Vorbis & clipping ?

Reply #13
Quote
Originally posted by Xenno
>>Peak level normalisation is not a good idea. If your target peak level is 98%, you >>can be sure that there is at least the risk of clipping.

I'm not sure there is a risk. When you use EAC and normalize to 98% - EAC first reads (or remembers from ripping the wav) the file to determines the maximum integer value. It then figures out the difference between the max value and 98% of (2^16)/2 and then raises (+/- relative to x axis (=0)) all values by that much (Bad thing: raises the noise floor, too). How could clipping occur?


Because encoding to ogg changes those peak values. On playback you may have peaks bigger than 98% (or 100% even, in which case you'll clip).

This is why normalizing is pointless when you're encoding to a lossy format. It accomplishes *nothing*.

--
GCP

Ogg Vorbis & clipping ?

Reply #14
Garf

>>Because encoding to ogg changes those peak values. On playback you may have >>peaks bigger than 98% (or 100% even, in which case you'll clip).

What if you have a hot (high level) recording right off a CD (@98% peak). With a digital rip you really don't have control over this (well, I suppose you could normalize downward - say 95% using EAC). I would think any encoder (especially a great one like ogg) would keep peaks to no greater than they were originally and if anything tone them down. Songs encoded may sound brighter but maybe that's because lower freq's were tossed.

Xenno
No one can be told what Ogg Vorbis is...you have to hear it for yourself
- Morpheus

Ogg Vorbis & clipping ?

Reply #15
Quote
Originally posted by Xenno

What if you have a hot (high level) recording right off a CD (@98% peak). With a digital rip you really don't have control over this (well, I suppose you could normalize downward - say 95% using EAC). I would think any encoder (especially a great one like ogg) would keep peaks to no greater than they were originally and if anything tone them down. Songs encoded may sound brighter but maybe that's because lower freq's were tossed.


The problem is that if you remove inaudible frequencies, the peaks may *get bigger*.

All lossy encoders have the exact same problem. The solution is to use ReplayGain.

--
GCP

Ogg Vorbis & clipping ?

Reply #16
Quote
Originally posted by Volcano
Apart from that, direct signal normalisation is irreversible, so you "damage" the signal forever.


If I'm not wrong, I have read something regarding this, it seems that the very little numerical rounding due to up(down) normalization can "create" and put false high-freq signals that, of course, wasn't at all present in orginal content (and distort the original).

Think isn't a problem for hearing ,
but how much can it trouble the encoder efficiency? (bit allocation)
"Taking a jazz approach and concentrating on live playing, I wanted to use several different rhythm sections and vintage instruments and amps to create a timeless sound that's geared more around musicality and vibe than sonic perfection. The key was to write with specific rhythm sections in mind, yet leave open spaces for soloing." Lee Ritenour

Ogg Vorbis & clipping ?

Reply #17
Quote
Originally posted by Garf
This is why normalizing is pointless when you're encoding to a lossy format. It accomplishes *nothing*.


Yes, waiting ogg2ogg-gain.exe[/b]

(sorry, I haven't the (little needed) skill to make such tool )
"Taking a jazz approach and concentrating on live playing, I wanted to use several different rhythm sections and vintage instruments and amps to create a timeless sound that's geared more around musicality and vibe than sonic perfection. The key was to write with specific rhythm sections in mind, yet leave open spaces for soloing." Lee Ritenour

Ogg Vorbis & clipping ?

Reply #18
Quote
Originally posted by unplugged


Yes, waiting ogg2ogg-gain.exe


(sorry, I haven't the (little needed) skill to make such tool )


Already exists and is called Vorbisgain.

--
GCP

Ogg Vorbis & clipping ?

Reply #19
Quote
Originally posted by Garf
Already exists and is called Vorbisgain.


Oh yes, but normalization isn't really hardcoded in the stream? ??? (the track itself remain unchanged)
I know it changes only a factor (by tag...?), maybe not all Vorbis (hardware) players will consider that information...
"Taking a jazz approach and concentrating on live playing, I wanted to use several different rhythm sections and vintage instruments and amps to create a timeless sound that's geared more around musicality and vibe than sonic perfection. The key was to write with specific rhythm sections in mind, yet leave open spaces for soloing." Lee Ritenour

Ogg Vorbis & clipping ?

Reply #20
Yes. There's no way to change to volume inside the ogg itself.

Edit: 15-03-2003: It looks like it may be possible after all, but its extremely complicated. Maybe for the future I'll give it a shot - in any case, for full ReplayGain functionality you still need the tags.

Ogg Vorbis & clipping ?

Reply #21
1.) So ANY kind (or level) of normalization before encoding is not good? I have a Berlin CD (Pleasure Victim) that EAC reports peaking at 46%. It plays back at 1/2 to 3/4 the volume of every other CD I have (well, one song hits 93%).


2.) Wouldn't it be possible to check an encoded file for it peak integer value to see if it might clip? I realize that the digital values may not correlate exactly to it's decoded analog counterpart. But it seems like you would then have some unit of measure to adjust normalization to.


3.) Related to 1.) is the hot CD (I know, I mentioned in a earlier post). I've ripped CD's (w/ EAC & no normalization) that are at the 98% level. What do you do there? I suppose you could decode them into a wave file and then analyze it (see if it any peak clipped).
No one can be told what Ogg Vorbis is...you have to hear it for yourself
- Morpheus

Ogg Vorbis & clipping ?

Reply #22
I think it's NOT a problem (at all) for hearing . No no.

There could be argumentation for the encoder (ogg, mp3... any), I don't know exactly where are located the added frequencies due to normalization, don't now if and how affect the encoder bit allocation... if these added noise is treat as part of (original) signal.

One very basical  thing is sure: normalizing by multiplicating for integer factors (x2 x3 x4...) is lossless so you can *exactly* duplicate, triplicate, quadruplicate etc.. (if there is room of course) the sound without any other unwanted alteration.

So you get perfect identical sound when you normalize the exact peak of 45,11% to 90,22% (factor is 2x)

and you get rounding stuff (again, not for hearing) when you normalize peak 66%  to 99% (the factor is 1.5x)
"Taking a jazz approach and concentrating on live playing, I wanted to use several different rhythm sections and vintage instruments and amps to create a timeless sound that's geared more around musicality and vibe than sonic perfection. The key was to write with specific rhythm sections in mind, yet leave open spaces for soloing." Lee Ritenour

Ogg Vorbis & clipping ?

Reply #23
Is it possible to use vorbisgain to prevent clipping in ogg files? What commands do you use in vorbisgain to analyze and apply a "max no-clip gain" like in mp3gain?

Ogg Vorbis & clipping ?

Reply #24
Quote
Is it possible to use vorbisgain to prevent clipping in ogg files? What commands do you use in vorbisgain to analyze and apply a "max no-clip gain" like in mp3gain?

Vorbisgain will automatically add that information when you run it over an ogg file.

But you need a player that supports ReplayGain (e.g. WinAmp) to make use of it.