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)?

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!

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/

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).

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.

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.

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...

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/

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!).

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.)

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?

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?

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.

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.

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.

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

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