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: lower bitrates after ReplayGain (Read 8266 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

lower bitrates after ReplayGain

Hi everyone!

Yesterday i noticed something odd. I noticed how files would vary in bitrate if i applied ReplayGain before or after to their respective originals, so i decided to make a test. I took an original audio cd (electronic, 2004) and ripped the first song into a wave file. I scanned the file with ReplayGain (foobar2000) and it said it was 9.96 db above 89 db. So what i did was encoding the same wave file into another wave file again, only that i would add ReplayGain to the encoding, set onto "apply gain" + "track"-mode and "without RG info": -9.9 db. Then i encoded both wave files into mp3 (VBR V2, LAME 3.97b). The original wave file that was 9.96 db above 89 db resulted in 199 kbp/s, the second wave file that was adjusted to 89 db in 188 kbp/s. After that, i encoded the wave files again, only this time using the VBR V0 setting. The results: 242 kbp/s / 234 kbp/s. Now, to check whether or not it's quality i am losing here, i did a reverse test. I took the second wave file that was on 89 db and encoded it into a third wave file, this time, altering it with + 9.9 db (the same way i did it the first time, only the other way around). Then i encoded it into mp3 (VBR V2) and all of the sudden it had 199 kbp/s??
So how is that possible? And what is actually happening here? I mean, if i am not losing any quality here, i could just find out at what point reducing volume WOULD actually erase song information out of the file and alter the track volume to the closest point near losing actual quality. This way i could make my mp3s even smaller!? i mean, mp3 players aside, if i have a good pre amp or eq or hifi system or whatever, i can just enhance the volume, no need for volume within the file?! Or am i missing something here?
Any help appreciated. Thanks in advance!

lower bitrates after ReplayGain

Reply #1
you will be losing quality from physically lowering the volume and raising it again. The easiest way to check it to do a md5 sum on the original wav and the one that has volume reduced and raised again. compare the md5 sums and see if they match.

use this program to create a md5 http://www.quicksfv.org/

[EDIT]: Flippin typos
Who are you and how did you get in here ?
I'm a locksmith, I'm a locksmith.

lower bitrates after ReplayGain

Reply #2
It is an *expected* result that lowering the volume of a sample reduces also the bitrate needed for the encoded file. This is even true with lossless codecs.

This happens because the model can exclude some information which becomes lower than the noise threshold, and also because the huffman encoding can pack the resulting values better.

If you are interested in playing that song at the replaygain value that you set your original to, you shouldn't worry about losing quality.
Instead, if you would sometimes restore (or even increase) the volume, the original could conceivably have better quality (since post-processing with lossy codecs can show artifacts, and 9db is multiplying by around 3 the amplitude)

lower bitrates after ReplayGain

Reply #3
If you want replaygain to be a function that does no real alterations to the actual audio data you should not apply it to the wav files since then it rewrites the actual audio data to lower the volumes, instead you should apply the replaygain as tags to the encoded files.

Then when it comes to if writing to the audio data is lossless or not depends on what one's definition of lossless. There is not necessarily any data atually lost as such in most cases, but some may find that altering the audio data is a sort of loss from the original.

As for why it gets smaller... [JAZ] is absolutely correct, noise threshold and data more closely together making for easier packing.

lower bitrates after ReplayGain

Reply #4
I use a program on Windows named MP3 Gain. Apparently it adjusts the volume without re-encoding the audio by adjusting the value of the gain multiplier stored in the file header.

lower bitrates after ReplayGain

Reply #5
Quote
' date='Jan 27 2008, 11:33' post='544007']
It is an *expected* result that lowering the volume of a sample reduces also the bitrate needed for the encoded file. This is even true with lossless codecs.

This happens because the model can exclude some information which becomes lower than the noise threshold, and also because the huffman encoding can pack the resulting values better.


Isn't this more a case of the information being lost in the volume reduction process? After all, if the information is there, no lossless codec could just throw it away. (unless it was able to reconstruct it mathematically with a bit-perfect result)

lower bitrates after ReplayGain

Reply #6
The initial question was answered correctly by [JAZ] and Seiitsu - if you make an mp3 from two wave files, the same except that one has lower volume level than the other (whether by replaygain tag or hard-alteration from wavegain or some kind of normalization), the mp3 encoded from the quiter wav file will be smaller, because a greater percent of the information in the quieter wav file is below the noise threshold and ignored or encoded less "carefully" (literally, with fewer bits). I believe most or all lossy codecs work this way.

This is not a problem. mp3 is a lossy codec. the point of lossy codecs is to package what you can hear conveniently at a smaller filesize, lower bitrate than a wav file.

Plenty of people (myself included) like to apply wavegain before encoding to mp3, or use a wavegain value to scale the mp3 in the encoding process. It does mean the file is a bit more lossy (entirely in un-hearable ways except for very quiet parts of music), but it also means is smaller filesize.
If you want to make sure you keep everything possible with respect to the noise threshold, encode and apply replaygain or mp3gain after encoding. If not, then encode using the full-volume wav and then apply replaygain or mp3gain to the mp3.

Also, retro83 is correct about mp3gain. It will calculate replaygain values, but can also hard-alter the mp3 file (in 1.5dB increments) by raising or lowering the volume. foobar2000 can also do this, by choosing "apply replaygain to mp3 data".
This is useful because most hardware players (and lots of programs like WMP) don't recognize replaygain tags.
Mp3gain is also reversible - you can just raise the volume back, and it just changes the gain info on each frame of the mp3 file.
God kills a kitten every time you encode with CBR 320

lower bitrates after ReplayGain

Reply #7
OK, i understand the noise treshold and data closer together part. How about lowering the volume to a point close to where i'd be losing actual data/quality which would result in an even smaller filesize. I believe 89 db is not this point. Also, just tagging would perfectly work with foobar, but would fail with players that can't read RG info/tags. Not to mention playing this file on any hardware player (with a very few exceptions)..
And checking the volume/quality of a music-/file with a md5 sum would need further explanation..
Anyhow, thanks to everyone for their answers so far and for any more to come in advance!

lower bitrates after ReplayGain

Reply #8
OK, i understand the noise treshold and data closer together part. How about lowering the volume to a point close to where i'd be losing actual data/quality which would result in an even smaller filesize. I believe 89 db is not this point. Also, just tagging would perfectly work with foobar, but would fail with players that can't read RG info/tags. Not to mention playing this file on any hardware player (with a very few exceptions)..
And checking the volume/quality of a music-/file with a md5 sum would need further explanation..
Anyhow, thanks to everyone for their answers so far and for any more to come in advance!

If you lower the volume to as low as possible without any samples ending up too low to fit the spectrum and get dropped you wouldn't actually loose anything from the replaygain process. It would result in a smaller file which was quieter when encoded.

Exactly how much to lower it to achieve optimal results is hard to say since that depends on the track. Testing and looking in a wav editor is probably the only solution.

lower bitrates after ReplayGain

Reply #9
OK, i understand the noise treshold and data closer together part. How about lowering the volume to a point close to where i'd be losing actual data/quality which would result in an even smaller filesize. I believe 89 db is not this point.

Wouldn't it be simpler just to raise the noise threshold when encoding? Different -Vx switches specify different noise thresholds, so just use a higher -Vx to get smaller files.

lower bitrates after ReplayGain

Reply #10

OK, i understand the noise treshold and data closer together part. How about lowering the volume to a point close to where i'd be losing actual data/quality which would result in an even smaller filesize. I believe 89 db is not this point.

Wouldn't it be simpler just to raise the noise threshold when encoding? Different -Vx switches specify different noise thresholds, so just use a higher -Vx to get smaller files.


I think so. its better than a 10 k saving from RG hacks. If V2 bitrate is too crazy as it can be with some stuff, consider V3 - saving can be 50 k with similar quality.

lower bitrates after ReplayGain

Reply #11
This issue has been discussed extensively (7 pages!) in the past...

http://www.hydrogenaudio.org/forums/index....showtopic=10637

The bitrate difference has little to do with "lost quality" specifically due to lowering the volume and rounding/dithering the result. Any "lost" parts on a typical track are way below anything mp3 would ever keep anyway.

The bitrate difference also has little to do with sounds falling below the ath. The ath floats. It has to, otherwise uniformly quiet tracks (which would cause normal people to turn up the volume) would be under-encoded, and include lots of artefacts that a fixed ath would assume were inaudible. (A long time ago lame didn't have a floating ath, and had this problem. Most other codecs don't have this problem.)

The issue is simple: sfb21. Due to the compromised design of mp3 (search for sfb21 to read all about it), to maintain much information in the frequencies above 16kHz, you have to over encode all lower frequencies - i.e. store them with greater accuracy than the psychacoustic model believes is necessary. The higher the volume, the greater the "over coding", and hence the higher the bitrate. The opposite happens here.

So yes, the quality is lower, but it's nearer what it should be. If you enable -Y (or use V3, which has that by default) you'll find the effect all-but-vanishes, because -Y tells lame to handle sfb21 as if there wasn't an issue, and dump content above 16kHz if it would need to overcode lower frequencies in order to preserve it. It's not actually the content above 16k that's using most of the bitrate - it's the over coding of everything below 16k which pushes it up.

Cheers,
David.

lower bitrates after ReplayGain

Reply #12
Thanks David. I vaguely remembered that discussion, and didn't do much of a job summarizing it here.
God kills a kitten every time you encode with CBR 320

lower bitrates after ReplayGain

Reply #13
Does MP3Gain have the same effect regarding what the original poster said? Will MP3Gain change the bitrate at all?

lower bitrates after ReplayGain

Reply #14
Does MP3Gain have the same effect regarding what the original poster said? Will MP3Gain change the bitrate at all?
No. Mp3Gain is used to scan already-encoded mp3 files for replaygain values (calculation and tagging), after which you may choose to apply the Replaygain info to the mp3 data stream. I believe this is done by changing the gain tag at the beginning of each frame of the mp3 file. Does not affect the size of the file, and doesn't affect the bitrate at all.
Note that foobar2000 can do this as well.
Generally, the term replaygain is used to refer to the calculation and writing of RG-value tags on files, and mp3gain is used to refer to the modification of the mp3 file so that it plays at an altered volume even in a player that does not read the tags.
God kills a kitten every time you encode with CBR 320

lower bitrates after ReplayGain

Reply #15
Ok. I'm confused about 1 other thing. If I don't apply ReplayGain, will MP3Gain still work? Can I just directly MP3Gain them, without doing anything with ReplayGain?

lower bitrates after ReplayGain

Reply #16
Ok. I'm confused about 1 other thing. If I don't apply ReplayGain, will MP3Gain still work? Can I just directly MP3Gain them, without doing anything with ReplayGain?

The way I distinguished the terminology above, ReplayGain isn't something you "apply" - rather you simply calculate the replaygain values and the file is tagged accordingly.
Mp3Gain works by applying the calculated values to the files, in 1.5dB increments. So if a song has an RG value of -6.5 dB, Mp3Gain will lower the volume by -6 dB and will change the RG tag to say -0.5 dB.

It is not possible to use Mp3Gain without having somehow calculated a ReplayGain value first.

I think the terminology of Mp3Gain, the way people typically use it, is actually misleading. Mp3Gain the program can calculate ReplayGain values for mp3 files (and write the tags), and also apply those values to an mp3 file within 1.5-dB increments. foobar2000 can also calculate ReplayGain values for any file it can play and will store those values in tags if the files can be tagged (wav files, for example, don't support formal tags). And foobar2000 can apply ReplayGain values to mp3 files the same as Mp3Gain the program does.
God kills a kitten every time you encode with CBR 320

lower bitrates after ReplayGain

Reply #17
Ugh yeah.. @ 2Bdecided, i saw it coming.. I knew that very likely i was not the first one to have thought about this issue but searhing hydrogenaudio for "mp3gain"/"replaygain" + "lower bitrates" gives me about 500 matches.. I mean, it's like wondering about defying gravity: if i do i just ask someone who can tell me the facts fast and summarized instead of going to the library and reading all about it.. And i mean, i read alot of the stuff that was posted on the other thread You mentioned, although they talked alot about lossles.. That's the problem in my opinion, i could've gotten my answer by reading all of those 500 threads myself but most of them don't specifically talk about my question. I mean, i am sorry for askng this question a second time, but then again, that's what the forum lives of.. And there will always be newer users who're advanced enough to answer, and at the same time learn again through answering.
My apologies though.
And @ topic: i understand the above 16khz thing and i've read about -Y and the "--ns-sfb21 4" switch, too (which i both tested cause i didn't know about it).
Thanks again to everybody taking a look at this and posting their contribution!

lower bitrates after ReplayGain

Reply #18
The issue is simple: sfb21. Due to the compromised design of mp3 (search for sfb21 to read all about it), to maintain much information in the frequencies above 16kHz, you have to over encode all lower frequencies - i.e. store them with greater accuracy than the psychacoustic model believes is necessary. The higher the volume, the greater the "over coding", and hence the higher the bitrate. The opposite happens here.

Thanks.

Indeed. I encoded one particular song twice:
'lame -V0 test.wav test1.mp3'  and
'lame -V0 test.wav --scale 0.25 test2.mp3'
Second file has lesser bitrate (237 vs 283 kbps) and lesser amount of frequencies over 16kHz.

(lame -V0 -Y makes 224 kbps file). 

...And 'lame -V0 test.wav --scale 0.10' results in 241 kbps file... It also has slightly more high frequencies than encoded with '--scale 0.10' 

lower bitrates after ReplayGain

Reply #19
Ugh yeah.. @ 2Bdecided, i saw it coming.. I knew that very likely i was not the first one to have thought about this issue but searhing hydrogenaudio for "mp3gain"/"replaygain" + "lower bitrates" gives me about 500 matches..
It's OK, I found it very hard to find that thread too, and I knew it existed and vaguely remembered who posted in it (which is how I found it in the end).

Cheers,
David.