Mixing two MP3 files

Protomixer

New member
Hi -- I am a noob, so please excuse my noobiness. I have two MP3 files (Windows), and I want to mix them by writing software. Do I have to first convert them to wave, or is there a better way to mix MP3? To convert to wave and back, I need a codec. Can anyone refer me to a basic C++ codec - greatly appreciated.

If this is the wrong question for this forum, I would appreciate to know where I can find a forum for codecs?

Thanks and any and all comments greatly appreciated.

Bromium
 
If you're trying to make a self-contained executable, it's going to need to include a codec no matter what you do - or at least have the ability to import one.
LAME is probably the best-known publicly usable library for processing MP3s

That said... does it need to be C++? You could do it all with FFMPEG and SoX pretty easily. (And with WSL on Windows, it's easily enough portable to all hardware)
 
Thinking about the other topic that was explained a little differently, I'm wondering if you've missed the point about mp3 files - For your purpose you probablt have no need for codecs and conversion, just a way to process the data stream header to leave the sync word intact and the other data the header contains, then the maths bit to creat the audio data stream, then you end up with a new mp3 containing the merged sources. That scares me totally as coding is something I know nothing about. You could convert the mp3 at some point, but why?

I don't think I've ever found a forum for people who want to do this for fun? It seems a huge amount of effort when you could just do it in a DAW. I understand that maybe for you writing the code is the enjoyment element, but you would be an internet forum with just one member I suspect? The task is so easy to do with free software, that apart from the satisfaction of success, what is the point? I don't think any of our members have ever expressed any interest in this kind of thing - maybe an electronics/coding forum would be the better place to find people with this kind of interest. They'd not be recordists in the usual sense.
 
Maybe someone who works with the Audacity project would be a better source for this type of conversion. Audacity will load in MP3 files and let you mix them, adjusting volume and effects. It almost sounds as if the OP is looking to do what a stripped down version of Audacity would do. The code is all open source, so a good coder may be able to strip out the pertinent sections of code. Audacity source code is available here: https://www.audacityteam.org/download/source/ You need a C++ compiler, so it sounds as if it's what the OP wants. It's available for Linux, WIndows and Mac.
 
  • Like
Reactions: TAE
You don't have individual samples in an mp3 so you can't simply combine samples. You will need to decode the mp3 files into LPCM and then sum the individual samples. You may have more success asking on the KVR DSP forum although I would suggest doing some basic reading up on the mp3 format first.


You can get the source code for LAME at


which is probably the best mp3 codec around.
 
Maybe someone who works with the Audacity project would be a better source for this type of conversion. Audacity will load in MP3 files and let you mix them, adjusting volume and effects. It almost sounds as if the OP is looking to do what a stripped down version of Audacity would do. The code is all open source, so a good coder may be able to strip out the pertinent sections of code. Audacity source code is available here: https://www.audacityteam.org/download/source/ You need a C++ compiler, so it sounds as if it's what the OP wants. It's available for Linux, WIndows and Mac.
Exactly what I was thinking ...pretty certain Audacity could mix two mp3's together though I have never tried
 
You don't have individual samples in an mp3 so you can't simply combine samples. You will need to decode the mp3 files into LPCM and then sum the individual samples. You may have more success asking on the KVR DSP forum although I would suggest doing some basic reading up on the mp3 format first.


You can get the source code for LAME at


which is probably the best mp3 codec around.
This is the correct answer. The actual data in an mp3 file is several steps removed from simple sample data that can be additively combined. It must be decoded to raw audio to work with it meaningfully
If you're trying to build a c++ executable to do it, LAME is probably the simplest starting point.

Reading OP's other thread, it seems like they don't even understand how file formats work* and are going to be way out of their depth trying to create an mp3 converter.

*e.g. even if you have .wav files, you still can't just add one file to the other, you have to strip out the metadata, header information, etc.
 
Back
Top