Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mix / overlay two mp3 audio file into one mp3 file (not concatenate)

I want to merge two mp3 files into one mp3 file.for example if 1st file is 1min and 2nd file is 30 sec then the output should be one min. In that one min it should play both the files.

like image 640
sandeep Avatar asked Mar 27 '13 05:03

sandeep


People also ask

Can I merge two audio together?

When you need to merge several songs into a single composition, the easiest way is to use our Online Audio Joiner application. It works in a browser window and you can join MP3 and other format files without installing the software on your computer. Open Online Audio Joiner website.


1 Answers

First of all, in order to mix two audio files you need to manipulate their raw representation; since an MP3 file is compressed, you don't have a direct access to the signal's raw representation. You need to decode the compressed MP3 stream in order to "understand" the wave form of your audio signals and then you will be able to mix them.

Thus, in order to mix two compressed audio file into a single compressed audio file, the following steps are required:

  1. decode the compressed file using a decoder to obtain the raw data (NO PUBLIC SYSTEM API available for this, you need to do it manually!).
  2. mix the two raw uncompressed data streams (applying audio clipping if necessary). For this, you need to consider the raw data format obtained with your decoder (PCM)
  3. encode the raw mixed data into a compressed MP3 file (as per the decoder, you need to do it manually using an encoder)

More info aboud MP3 decoders can be found here.

like image 159
bonnyz Avatar answered Oct 01 '22 20:10

bonnyz