Log in

View Full Version : BeSweet/OggMachine Gain


JohnMK
8th November 2002, 04:03
C:\Documents and Settings\Chad>cd C:\Documents and Settings\Chad\Desktop\In Prog
ress\sherlock\1

C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1>vorbisgain -d *.og
g

Processing directory '.':
Analyzing files...

Gain | Peak | Scale | New Peak | Track
----------+--------+-------+----------+------
+6.15 dB | 15025 | 2.03 | 30501 | 1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg


Which is close to what BeSweet OggMachine appended:

+6.94 db (post-gain/hybridgain)

Is 6.94db added to 15025 (16-bit system) still 32767 or below? How can this be calculated?

Also, isn't it better to pre-gain? Thinking about this last night, I came to the conclusion that you lessen the ability of the encoder to use its ATH model to maximum advantage if you don't feed it a volume that's approximately equal to what you'll be playing it back at. Masking would also be affected.

DSPguru
8th November 2002, 15:02
15025*10^(6.94/20)=33405.
20*log10(32767/15025)=6.77, which is somewhere between 6.94 to 6.15 .

i'm considering adding percentage postgain option.
in above case, 98% of maxgain would fit.

and don't forget that in vast majority of the time, the signal doesn't reach its peak. not even 98% of it.
wouldn't you agree ?

as for ath,
this has been discussed before in few threads.
a short answer would be - 0db spl is being evaluated before applying psychoacoustic model (like ath, masking), and therefore if you use pregain, there's a fair chance that your signal won't fall below ath.

JohnMK
8th November 2002, 15:32
This extremely small level of clipping will usually not be noticed by even a careful listener. Still, it's unfortunate. So, let's propose a scenario. :D I'm Mr. Paranoid, and want to avoid clipping at all cost. Would you suggest I use pre-gain @ 97% for the time being, until you implement your aforementioned idea?

DSPguru
8th November 2002, 22:49
yes, mr. paranoid :D.

JohnMK
11th November 2002, 07:41
This resulted in very prominent extensive clipping, volumes approaching 57,000.

So how can I avoid clipping? Clearly a file that gets outputted by OggMachine with a peak volume level of over 32767 after PostGain is not optimal.

Keep in mind what I'm talking about. I'm not talking about clipping prior to handing over to OggEnc. Rather, I'm talking about the clipping that OggEnc introduces (in fact, all lossy codecs introduce clipping to near-max signals). There has to be a way to avoid this. Perhaps encode the file, then run VorbisGain? Could you implement this instead of your current system?

DSPguru
11th November 2002, 22:09
i can implement ANYTHING. but currently don't have the time.. :(

JohnMK
12th November 2002, 05:49
Hopefully you didn't take my request the wrong way. I'm merely interested in seeing that your program can't be accused of aiding & abetting clipping. You've worked so hard to make the perfect program, and to have it output clipped files is a minor tragedy. It can be a pretty annoying artifact if you've got the proper equipment to hear it.

DSPguru
12th November 2002, 19:20
Hi JMK,
please explain:Originally posted by JohnMK
Gain | Peak | Scale | New Peak | Track
----------+--------+-------+----------+------
+6.15 dB | 15025 | 2.03 | 30501 | 1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg Originally posted by JohnMK
This resulted in very prominent extensive clipping, volumes approaching 57,000.20*log10(57000/15025)=11.5812.
so it seems you applied almost 11.6dB of gain.

ps,
if you're doubtful regading hybridgain, you can always use pregain (two-pass), this feature is stable for almost a year now.

JohnMK
12th November 2002, 21:23
Hi there,

I'm not doubtful about HybridGain. It seems to work rather well, just not perfectly. I'd like to see it never output a clipped file, as it does now. The clipping isn't evident to your program (hence there are no overflow warnings) because it only prevents clipping in the period before it's handed to OggEnc. OggEnc is what is producing clipping, because you're handing it something that's been normalized to full or close-to-full scale, and all lossy codecs will produce clipping when dealing with such close-to-full scale sources. To fix this I suggest a revised two-pass mode that works like this:

1) Encode signal with original volume information.
2) Run VorbisGain with correct switches that prevent clipping

I'm positive this is easy to implement. I'd be very willing to do it myself if I could code C or C++ reasonably well, but the fact of the matter is I'm very out of practice.

Setting Pre-Gain to 97% (what I thought would be a safe feature) resulted in a file with 57,000 maximum volume, according to VorbisGain. So far I've found it to be accurate in its determination. I'll do some more testing tomorrow after I reinstall Windows XP.

DSPguru
13th November 2002, 18:37
Originally posted by JohnMK
Setting Pre-Gain to 97% (what I thought would be a safe feature) resulted in a file with 57,000 maximum volume, according to VorbisGain.97% PreGain got nothing to do with Hybrid, and i think that a few overflows (introduced by ogg encoding/decoding) should be tolerated in the sake of loud soundtrack result.

JohnMK
13th November 2002, 19:19
VorbisGain is a commandline program available that analyzes a .ogg file and looks for its maximum volume level. I hope you didn't think I was talking about whatever you use inside of your program.

On another matter entirely, I really don't see what's so bad about what I suggest. I'm not criticizing your work or doubting that an overall loud volume file is a nice result, but to introduce clipping in the process is inexcusable. I think I'm right on that point, any audiophile will agree with me.

JohnMK
13th November 2002, 19:33
I was factually incorrect. It wasn't 57,000. 97% works as intended, and does not allow OggEnc to produce clipping in probably almost all circumstances.

But HybridGain does indeed allow clipped output in the end result.

DSPguru
13th November 2002, 19:40
Originally posted by JohnMK
HybridGain does indeed allow clipped output in the end result. please post all relevant info (logfiles, etc'.).

JohnMK
13th November 2002, 19:49
BeSweet.exe -core( -input C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1\1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ac3 -output C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1\1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg -logfilea C:\OggMachine\BeSweet.log ) -azid( -L -3db -c light -s stereo ) -ota( -hybridgain -d 0 ) -ogg( -q 0.200 ) -profile( The OggMachine v0.6b1 )

[00:00:00:000] +------- BeSweet -----
[00:00:00:000] | Input : C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1\1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ac3
[00:00:00:000] | Output: C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1\1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg
[00:00:00:000] | Floating-Point Process: Yes
[00:00:00:000] +-------- AZID -------
[00:00:00:000] | Input Channels Mode: 2/0, Bitrate: 192kbps
[00:00:00:000] | Output Stereo mode: Stereo
[00:00:00:000] | Total Gain: 0.000dB, Compression: Light
[00:00:00:000] | LFE levels: To LR -3.0dB, To LFE 0.0dB
[00:00:00:000] | Center mix level: BSI
[00:00:00:000] | Surround mix level: BSI
[00:00:00:000] | Dialog normalization: No
[00:00:00:000] | Rear channels filtering: No
[00:00:00:000] | Source Sample-Rate: 48.0KHz
[00:00:00:000] +-------- OGG --------
[00:00:00:000] | VBR Quality : 0.200
[00:00:00:000] +---------------------
[00:54:16:576] Gain of 6.9dB had been asserted to file.
[00:54:16:576] Conversion Completed !
[00:54:16:576] Actual Avg. Bitrate : 73kbps
[00:06:55:000] <-- Transcoding Duration
Logging ends : 11/04/02 , 18:58:34.



C:\Documents and Settings\Chad>cd C:\Documents and Settings\Chad\Desktop\In Prog
ress\sherlock\1

C:\Documents and Settings\Chad\Desktop\In Progress\sherlock\1>vorbisgain -d *.og
g

Processing directory '.':
Analyzing files...

Gain | Peak | Scale | New Peak | Track
----------+--------+-------+----------+------
+6.15 dB | 15025 | 2.03 | 30501 | 1 AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg


VorbisGain ignores the previous tag and just looks at the values in the file. -d switch means it doesn't change the file, just analyzes it.

DSPguru
13th November 2002, 19:55
15025*10^(6.9/20)=33252. >32768
0.97*33252=32254 <32768

i'm afraid we're going around in circle.

a postgain of 97% should do !

JohnMK
13th November 2002, 20:07
My point is that HybridGain as currently implemented allows OggEnc to clip when it encodes. There's a way for it not to do that, and it's to not calculate PostGain value until after the .ogg is made. Analyze the .ogg with something like VorbisGain, and then apply Gain. This will result in a file with perfect, non-clipping maximum volume.

This is how it should be. Don't confuse dynamic range and dynamic compression with clipping. You can indeed have a loud file without clipping.

DSPguru
15th November 2002, 21:35
to Be on the Safe side, use BeSafe (http://dspguru.notrace.dk/beta.html) ;)

JohnMK
16th November 2002, 04:58
OMG, am I awake?

/me pinches himself

In all honesty though, thank you. You're a true gem. When I finally start writing code again, your suggestions and requests will be the first I implement. Of course that's all hypothetical, but it's the thought that counts.

Happy Thanksgiving.:)

DSPguru
16th November 2002, 17:19
i didn't know you're a coder.. :D:D

JohnMK
16th November 2002, 20:26
I'm not really. I'd have to relearn everything I've forgotten, but there's not much to relearn, as I just barely progressed to the point where I could write GUI applications.

JohnMK
17th November 2002, 01:19
G:\in progression\cleopatra2>besafe 702.ogm
BeSafe v0.1 by DSPguru.
------------------------
Processing 702.ogm :


Stream Error. can't open file!!

DSPguru
17th November 2002, 06:01
usage : BeSafe [filename.ogg] ;)

JohnMK
17th November 2002, 06:17
:) Thanks.

JohnMK
18th November 2002, 19:58
C:\Documents and Settings\Chad\Desktop\In Progress\monty>vorbisgain *.ogg

Processing directory '.':
Analyzing files...

Gain | Peak | Scale | New Peak | Track
----------+--------+-------+----------+------
-3.68 dB | 27927 | 0.65 | 18282 | monty AC3 T01 2_0ch 192Kbps DELAY 0ms.og
g
Malformed (?) tag in 'monty AC3 T01 2_0ch 192Kbps DELAY 0ms.ogg' skipped ('Made
with BeSweet. http://DSPguru.doom9.org')

C:\Documents and Settings\Chad\Desktop\In Progress\monty>


What's that mean?

DSPguru
18th November 2002, 23:23
please please please. always when posting - post ALL relevant information.

1. what was the gain value reported by BeSafe ?
according to above info it should be 1.3885dB (20*log10(32768/27927)).
2. VorbisGain is about finding ReplayGain and not MaxGain, therefore it's not comparable.

JohnMK
19th November 2002, 03:54
Indeed you are correct. +1.39dB.