Help - Search - Members - Calendar
Full Version: lame 32-bit float input
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - Tech
ZinCh
I need a help to find (and check) program wich can be used with lame to make mp3 from 32 bit float wav.

LAME by default do not support floating point input, but it is possible with libmp3lame

lame+libsndfile accept input, but generate silence mp3 (this build by john@rarewares)

projects with libmp3lame, wich accept float, but I dont know what format they feed to library (float or int) :
ffmpeg
sox

sox web cvs /sox/sox/src/mp3.c
CODE
    /* NOTE: This logic assumes that "short int" is 16-bits
     * on all platforms.  It happens to be for all that I know
     * about.
     *
     * Lame ultimately wants data scaled to 16-bit samples
     * and assumes for the majority of cases that your passing
     * in something scaled based on passed in datatype
     * (16, 32, 64, and float).
     *
     * If we used long buffers then this means it expects
     * different scalling between 32-bit and 64-bit CPU's.
     *
     * We might as well scale it ourselfs to 16-bit to allow
     * lsx_malloc()'ing a smaller buffer and call a consistent
     * interface.
     */

does that mean it is using 16 bit internally? can someone who understand read part of code?

ffmpeg-0.5.tar.bz2 /ffmpeg/libavcodec/libmp3lame.c
I dont know where to look, but this file is very old (2002) and almost everything in source is int
john33
Sorry for the late reply but I only just picked this up from the lame-dev lists!

If you're using my Rarewares compiles I have to assume that you're on Windows? If so, you can use lamedropXPd3, that definitely accepts and correctly processes 32 bit float input. I'll take a look at the libsndfile compile which, as you say, accepts the input but encodes silence.
lvqcl
QUOTE (john33)
lamedropXPd3, that definitely accepts and correctly processes 32 bit float input


...and does it incorrectly, if input is greater than 1.0 (or less than -1.0) sad.gif For example, 1.1 becomes -0.9, etc.
john33
QUOTE (lvqcl @ Oct 22 2009, 21:52) *
QUOTE (john33)
lamedropXPd3, that definitely accepts and correctly processes 32 bit float input


...and does it incorrectly, if input is greater than 1.0 (or less than -1.0) sad.gif For example, 1.1 becomes -0.9, etc.

That can be taken care of simply enough, but to be within spec isn't float input supposed to be within the range of +1.0 to -1.0?
neelX
QUOTE (john33 @ Oct 22 2009, 23:42) *
...isn't float input supposed to be within the range of +1.0 to -1.0?


Float's range is ±3.4028234 × 10^38 (±(2^24 - 1) * 2^104 = ±340282346638528859811704183484516925440) ≈ 770.636788382 dB. ±1.0 is just nominal 0 dB and you'd better stay under 0 dB when you're going to convert to integer (for example for playback, doesn't matter if it is 8, 16 or 24 bit) otherwise clipping will occure. But in floating world you can happily enjoy the extended range if it's useful for something (I doubt).

It is possible that mp3 (and other lossy DFT formats) can handle a few (maybe just tenths) dB above 0, but in mp3's case it could worsen the sfb21 issue and in extreme cases even other sfbs can have issues too I'm affraid. sad.gif
But I think lame (nor any other implementations) aren't fully tested for such cases. Their implementation can be very well limited to 0 dB.
lvqcl
I made several changes to LAME source that allow it to encode 32-bit float WAVs. I can upload commandline encoder somewhere.

QUOTE (john33)
but to be within spec isn't float input supposed to be within the range of +1.0 to -1.0?

Maybe, but at least foobar2000 and Adobe Audition can make files where sample values lie outside that range.
ZinCh
thanks for feedback, I will be checking any solutions, looks like problem is not complicated

lvqcl, it will be good solution, this patch will not limit features of lame? --scale switch can be used?
lvqcl
QUOTE (ZinCh @ Oct 25 2009, 02:06) *
lvqcl, it will be good solution, this patch will not limit features of lame? --scale switch can be used?

Yes it can. I attached the patch (original, patched files and diff file) to this post.
It was tested on Win32 (MSVS compiler) with 16-, 24-, 32-bit int and 32-bit float WAV files.
ZinCh
thanks, can you post binaries too? (if you need file hosting suggestion: http://files.mail.ru/eng )
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.