Skip to main content

Topic: Wavegain vs. MP3Gain (Read 152267 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Yes, I know that MP3Gain is lossless. No, I am not talking about how MP3Gain is limited to 1.5dB steps (though this is another reason).
What I am thinking is this:

Psychoacoustic models tend to encode louder signals with more bits, right? This is why remasters (compressed) tend to use higher bitrates than older versions. Correct?

If we are then encoding a VERY LOUD album with LAME -aps for instance, then normalizing it down say 10.5dB (for a really bad one), aren't we wasting bits? Wouldn't we be able to save some bits by normalizing it down to 89dB FIRST, then encoding it?

I know wavegain is NOT LOSSLESS, but I am (incorrectly) assuming that this is just a theoretical lossiness, not a perceptible one. If this is the case, couldn't we argue that wavegained tracks will be of lower bitrates while still maintaining transparency (the goal, afterall, of -aps)?


---------------------------------
| UPDATE (May 21st, 2005) |
---------------------------------

The discussion below basically concludes that running a wavegain analysis, then applying the recommended scalefactor to lame (via the --scale switch) will save bits due to high-frequency bloat inherent in the mp3 format. Lots of people have since chosen to use this method over mp3gain, and in fact it can be automated now from within EAC using Wack, or my own Omni Encoder. Read on!
  • Last Edit: 18 July, 2006, 09:05:35 AM by Jebus

  • Garf
  • [*][*][*][*][*]
  • Developer (Donating)
Wavegain vs. MP3Gain
Reply #1
Why not test the theory?

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #2
Doing that right now... ETA 5min on the encode

  • Echizen
  • [*][*]
Wavegain vs. MP3Gain
Reply #3
*lol* a new way to save bits. first decrease the volume, encode and then increase with mp3gain

  • john33
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #4
The theory does work in practice, although I don't believe the difference was huge. But then you wouldn't expect it to be that large would you? I should be quoting numbers here, but I don't have any to hand without retesting!
John
----------------------------------------------------------------
My compiles and utilities are at http://www.rarewares.org/

  • M
  • [*][*][*][*][*]
Wavegain vs. MP3Gain
Reply #5
Hmmm... I'll hazard a simple guess and say "yes," since I know that you can save bits by first using WaveGain and then compressing with a lossless algorithm (tested extensively for FLAC, Shorten and WavPack, although I suspect Monkey's audio and the rest would exhibit similar behavior).

    - M.

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #6
Here are the exciting results:

"Mer De Noms" by "A Perfect Circle"

MP3Gain wanted to do a -9dB adjustment, so this albums is pretty loud, though not the loudest by any means.

The files repaygained after the fact (MP3Gain) totalled 70.6MB
The files replaygained before encoding (Wavegain) totalled 63.4MB

So, using --alt-preset standard, you end up with about a 10% savings for a relatively loud modern recording. I assume the savings will be less for older recordings and more for hypercompressed drivel like they release today.

I think this is pretty significant...
My only thought it, are the files ABXable against eachother? I don't have the ears to do the test unfortunately... Anyone care to try? I certainly hope they are indistinguishable.

  • HansHeijden
  • [*][*][*]
Wavegain vs. MP3Gain
Reply #7
For mp3, it would be an idea if wavegain could pass on just the replaygain value to lame's --scale, thereby avoiding the rounding to 16 bits.

  • Canar
  • [*][*][*][*][*]
  • Global Moderator
  • Your mom's favourite moderator
Wavegain vs. MP3Gain
Reply #8
Quote
Psychoacoustic models tend to encode louder signals with more bits, right? This is why remasters (compressed) tend to use higher bitrates than older versions. Correct?

I believe that assertion may be false. If I understand correctly, the overall loudness of a track should have little effect on the encoding. The total amount of perceptible detail in a track is what affects bitrate. The remastered bitrates are probably like that because the process of compression brings previously inaudible details up to the level of audibility.

By decreasing the volume level, you decrease the amount of detail available overall, with some small-amplitude details being obliterated by the noise floor. Thus, saved bits.

Edit: This is my theory, anyhow... Any knowledgeable rebuttals?
  • Last Edit: 21 June, 2003, 05:25:35 PM by Canar
1. Attack the argument, not the arguer.
2. Assume good faith.

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #9
Quote
For mp3, it would be an idea if wavegain could pass on just the replaygain value to lame's --scale, thereby avoiding the rounding to 16 bits.

Dude, that is a wonderful idea! Any LAME/wavegain developers listening?? This would be SO AWSOME!

  • john33
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #10
Quote
For mp3, it would be an idea if wavegain could pass on just the replaygain value to lame's --scale, thereby avoiding the rounding to 16 bits.

You can do that manually by just having the gain calculated.
John
----------------------------------------------------------------
My compiles and utilities are at http://www.rarewares.org/

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #11
Quote
Quote
For mp3, it would be an idea if wavegain could pass on just the replaygain value to lame's --scale, thereby avoiding the rounding to 16 bits.

You can do that manually by just having the gain calculated.

yeh but what a pain! And AFAIK, replaygain won't display an album --scale value, so I'd have to calculate it manually, then apply this with --scale to every encoded MP3 i do. That's pretty time consuming...
  • Last Edit: 21 June, 2003, 06:06:20 PM by Jebus

  • john33
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #12
Quote
Quote
Quote
For mp3, it would be an idea if wavegain could pass on just the replaygain value to lame's --scale, thereby avoiding the rounding to 16 bits.

You can do that manually by just having the gain calculated.

yeh but what a pain! And AFAIK, replaygain won't display an album --scale value, so I'd have to calculate it manually, then apply this with --scale to every encoded MP3 i do. That's pretty time consuming...

WaveGain will display the Album Gain value in calculation mode and if you have it write the log file, all the values will be saved in the log file for future reference.

BTW, I am the author of WaveGain.
John
----------------------------------------------------------------
My compiles and utilities are at http://www.rarewares.org/

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #13
ah but i need to manually calculate scalefactor from that number right?

AFAIKT, this is simply 10E(replaygain * 0.05)

am I correct? So an album with a recommended gain adjustment of -10.02dB should have a --scale applied to lame that is 3.17? Seems to be roughly 10x too large. I'm going to write a script to automate this process now (once i figure this calc out), since I think this is all-around preferable to using MP3Gain.

EDIT: Nevermind, got it. I forgot to make the replaygain value negative (duh!).
  • Last Edit: 21 June, 2003, 08:05:14 PM by Jebus

  • mrosscook
  • [*][*]
Wavegain vs. MP3Gain
Reply #14
Jebus,

In a problem like yours it can help to consider the asymptotic case, i.e., take the process to its logical conclusion.  Suppose that we first wavegain the file to zero volume (digital silence).  Then it takes only 1 bit to encode it. (Or is it 0 bits? Anyhow, it is a pretty good savings in file size). But if we try to gain back the volume of the encoded file, we find that we've lost all the information.

It's reasonable to expect that for intermediate amounts of wavegain, we should get intermediate savings in file size, and also lose intermediate amounts of information.  (Of course, there's no guarantee that the process is linear or even monotonic; but we know where it has to start and end, so it has to pass through the points in between.)

  • westgroveg
  • [*][*][*][*][*]
Wavegain vs. MP3Gain
Reply #15
The question of whether wavgain artifacts are perceptible still remains

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #16
Well as it stands, I have just ripped a couple of trial albums...

As recommended, what I did was extract using EAC, then run a wavegain ANALYSIS ONLY on the album. From the resulting suggested album gain adjustment I did 10E(gain * 0.05) to get the scalefactor, then ran LAME using:

lame --alt-preset standard --scale 0.3155 (for example - this is By The Way by the Red Hot Chili Peppers)

The resulting files are 10% smaller than if I had used MP3Gain after the encode, there is no theoretically lossy wavegaining being done, and I get much better than 1.5dB per step precision (the above files are 0.02dB over the ideal as set by replaygain).

I can't think of any reason why this is not the best possible way to encode MP3s. Not even much more work. Anyone have comments?

  • mrosscook
  • [*][*]
Wavegain vs. MP3Gain
Reply #17
Westgroveq,  I think it might be better to say that the question is not whether wavgain artifacts are perceptible, but when they become perceptible. 

If we wavgained all the way to silence, anybody could ABX that as an artifact.  But of course practical values of wavegain are going to lose much less information, and it wouldn't surprise me if 99.9% of all actual wavgain applications were impossible to ABX, by even the battiest of bat-ears on the forum.

It would be interesting to know when the information loss in wavgain becomes great enough to ABX, and it probably depends on the style of music, degree of compression and clipping in the original file, dynamic range of the music, etc.  Any volunteers?

Jebus,  Are you sure that --scale isn't lossy in itself?  You could in principle use it to reduce the volume to zero, couldn't you, just as wavgain could do?

  • Canar
  • [*][*][*][*][*]
  • Global Moderator
  • Your mom's favourite moderator
Wavegain vs. MP3Gain
Reply #18
Quote
As recommended, what I did was extract using EAC, then run a wavegain ANALYSIS ONLY on the album. From the resulting suggested album gain adjustment I did 10E(gain * 0.05) to get the scalefactor, then ran LAME using:

lame --alt-preset standard --scale 0.3155 (for example - this is By The Way by the Red Hot Chili Peppers)

So, just to be absolutely certain, you are not altering the source WAV file in any way, yet are getting smaller file sizes?

There should be no difference between the MP3 files, or very, very little at most, if my understanding is correct.
  • Last Edit: 22 June, 2003, 12:15:08 AM by Canar
1. Attack the argument, not the arguer.
2. Assume good faith.

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #19
Quote
Quote
As recommended, what I did was extract using EAC, then run a wavegain ANALYSIS ONLY on the album. From the resulting suggested album gain adjustment I did 10E(gain * 0.05) to get the scalefactor, then ran LAME using:

lame --alt-preset standard --scale 0.3155 (for example - this is By The Way by the Red Hot Chili Peppers)

So, just to be absolutely certain, you are not altering the source WAV file in any way, yet are getting smaller file sizes?

There should be no difference between the MP3 files, or very, very little at most, if my understanding is correct.

Yes that is correct. No modification of the source wave. They are quite a bit smaller. I've done a number of albums now from the last 10 years and they are coming out an average of 10% smaller.
  • Last Edit: 22 June, 2003, 12:34:46 AM by Jebus

  • Jebus
  • [*][*][*][*][*]
  • Developer
Wavegain vs. MP3Gain
Reply #20
Quote
Jebus,  Are you sure that --scale isn't lossy in itself?  You could in principle use it to reduce the volume to zero, couldn't you, just as wavgain could do?

--scale is absolutely lossy, as is the entire encoding/quantization process during which it is set to a particular --scale anyhow (doesn't --aps use a scalefactor of 0.98 anyhow?). By using wavegain you are introducing an extra lossy step which involves additional dithering. This cuts that step out.

  • indybrett
  • [*][*][*][*][*]
  • Members (Donating)
Wavegain vs. MP3Gain
Reply #21
Geez...

Does this mean I have to re-encode everything again 
flac>fb2k>kernel streaming>audiophile 2496>magni>dt990 pro

  • Garf
  • [*][*][*][*][*]
  • Developer (Donating)
Wavegain vs. MP3Gain
Reply #22
Quote
(doesn't --aps use a scalefactor of 0.98 anyhow?).

No, only the CBR presets.

  • tigre
  • [*][*][*][*][*]
Wavegain vs. MP3Gain
Reply #23
- to avoid loss due to applying wavegain (= lowering volume at 16 bit res.) you could use fb2k's diskwriter @ 24 bit and encode the resulting .wav files with lame

- in my MP3 vs. MPC vs. Ogg: Low volume test I got similar results, but I focussed on quality problems not on bitrate.

- I *think* messing with lame ATH settings could have the same effect (--althlower switch with negative values).
Let's suppose that rain washes out a picnic. Who is feeling negative? The rain? Or YOU? What's causing the negative feeling? The rain or your reaction? - Anthony De Mello

  • Hanky
  • [*][*][*][*][*]
  • Members (Donating)
Wavegain vs. MP3Gain
Reply #24
It does not surprise me that files get lower bitrates when encoding to mp3 after first wavgaining them.
The simple fact that I throw away something like 0.5 to 1.0  bit of digital resolution could explain the lower bitrate easiliy.
For example a full range 16 bit signal scaled with let's say a 0.7 factor gives ~15.48 bits digital resolution left.
In general the loss of bits can be expressed as:
Code: [Select]
n=-2log(scalefactor)


Where n = the loss of bit depth of the signal, 2log is the 2 based logarithm

Of course this effect could be avoided by first resampling to 24 bit wav as mentioned  in another post
  • Last Edit: 22 June, 2003, 06:21:38 AM by Hanky