MP3 encoding using Lame

This is just a general question about MP3 encoding (perhaps I’m on the wrong forum but there’s no harm in asking eh?)

Ok, here goes:

There are many programs (including Audacity) that use the Lame MP3 encoder to create one mp3 file from several audio files (mixdowns).
I would be every grateful for some information on how this is achieved.

From studying the Lame documentation, I can only find a reference to the conversion of single files, e.g. from the command prompt, Lame can be used to encode one file to another:

lame [options] <infile> [outfile]

Is it possible to encode multiple files into one file from the command line? How does Audacity use Lame to produce a single mp3 file from multiple wav/mp3 files.

Any information would really be appreciated.

Thanks for reading.


In Audacity, mix down the audio into one track first.
Then “Export” as mp3.

You shouldn’t need to mix into a single stereo track - the Export from Audacity should atomatically do the mix as part of the export.

No harm in doing the mix though (unless you want to go back to work on the tracks separately later.



thanks for both of your replies, but I’m afraid that you have misunderstood my question - which is my fault, I just read it back and realized that i should have been clearer.

I am trying to write a simple program that will convert 8 mp3 files into one mp3 file, accounting for parameters such as volume and pan for each mp3 file.
It’s for a uni project that I’m struggling with a little. We can use any language but I’m not sure where to start.

Does anyone know how this can be achieved. All DAWs use this similar programs to mixdown. I’m just trying to write a similar function.

Any advice would really be appreciated.

LAME is an encoding engine. It has nothing to do with mixing multiple audio files or joining them end to end, it just receives a single, continuous stream of sample and encodes them. For a simple command-line application that can be used to join and mix audio files, see As far as your program goes you either call SOX to do the work (if that’s allowed), or read the data into arrays in memory, and do the mixing yourself - multiply each channel by the necessary gain, then add them up to get the sum (taking care to avoid clipping (overflow) if your values get too large, and noise (loss of precision) if they get too small).