HydrogenAudio

Lossy Audio Compression => MP3 => MP3 - Tech => Topic started by: mezzanine on 2012-01-19 09:37:52

Title: 24 bit lossless to mp3 using lame
Post by: mezzanine on 2012-01-19 09:37:52
I want to convert a 24 bit FLAC to v0 mp3. (the source is not vinyl, I'd like to avoid that conversation)
Currently its highest peak is -9dBFS which is pretty quiet. Should I normalize the 24-bit file so that it peaks at the maximum value first?

An alternative way to word this question:
Does lame truncate 24 bits to 16 bits before encoding?

I'm also curious about dithering. Should I dither to 16 bits using a high quality algorithm like SoX and then feed that to lame to encode?

Thanks!
Title: 24 bit lossless to mp3 using lame
Post by: itisljar on 2012-01-19 10:51:37
AFAIK, mp3 doesn't really have bit-dept (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=55336&view=findpost&p=496406)h. So, you could normalize it to almost 0 dB (I would do peak normalization to -1 dB), and then just send it to encoder.
Maybe there is better way.
Title: 24 bit lossless to mp3 using lame
Post by: punkrockdude on 2012-01-19 12:12:13
I actually did tests on some encoders last week with 24 bit integer files and "an mp3 encoder" was one of very few that preserved sounds around -130dBFS just like it would sound around -13dBFS. Regards.
Title: 24 bit lossless to mp3 using lame
Post by: DVDdoug on 2012-01-19 17:52:32
Quote
An alternative way to word this question:  Does lame truncate 24 bits to 16 bits before encoding?
No.

Quote
Currently its highest peak is -9dBFS which is pretty quiet. Should I normalize the 24-bit file so that it peaks at the maximum value first?
If it "feels" too quiet, then yes I'd normalize.  Since you are probably going to crank-up the volume during playback, you might as well make it more convenient by "permanently" cranking-up the volume. 

Quote
I'm also curious about dithering. Should I dither to 16-bits using a high quality algorithm like SoX and then feed that to lame to encode?
In this case, you don't need to downsample.   

Whenever you downsample to 16-bits, it's up to you if you want to dither or what algorithm/application you want to use...  At 16-bits, the dither is somewhere around -90dB and nobody is going to know if you dithered or not, or if you used a "good" dither algorithm.
Title: 24 bit lossless to mp3 using lame
Post by: slks on 2012-01-20 01:44:12
The bit depth refers to the number of bits used to represent the amplitude of one sample, in uncompressed PCM audio. MP3 uses some kind of mathematical trickery on the audio signal (I believe it's called an FFT) so that each sample does not have to be represented individually, thus there is no bit depth in an MP3 file.

However, when your MP3 gets converted back to PCM audio during playback, it again has a bit depth. Now generally with audio editing software, and for foobar2000, they decode to 32-bit PCM internally, so you won't have any issues with the audio levels being too close to the noise floor there.

So, if you wish, you can leave the audio as-is (peaking at -9 dB) and not run into any problems. LAME accepts 24-bit PCM input directly, and the MP3s internally have no bit depth, so you won't run into any problems from the signal level being too low, unless you end up having to convert it to 16-bit PCM at some point in the future (for example, if you want to put it on a CD). Even then, the quantization noise from the lower bit depth may or may not be audible. That depends more on the average signal level, rather than the peaks.

What I always do with the audio is to normalize it so that the highest peak is at 0 dB, this way I get the maximum amount of volume. If your highest peak is at -9 dB, and you end up converting the audio to 16-bit at some point, you effectively only use 14.5 bits of resolution. (Each bit adds another 6 dB of dynamic range).