This project has moved and is read-only. For the latest updates, please go here.

how to mix multiple mp3 files into 1 file ( not merge )

Aug 30, 2014 at 10:06 AM
hi ,
anyone please tell me how i can merge multiple mp3 files into one file such that all the mp3 songs mix with each other ( not merge at the end ).
I have tried to write the following code and getting error as noise so much in the ewquired file . i also tried to convert that file to wav format and did the same things but it made the resultant song as noise unable to hear voice.
Following is the code
 var sound1 = new Mp3FileReader(file1);
            var sound2 = new Mp3FileReader(file2);
            Stream outputStream = new FileStream(@"D:\Shan\SoundMixer\song.wav", FileMode.OpenOrCreate, FileAccess.Write);
            WaveFileWriter waveWriter = new WaveFileWriter(outputStream, WaveFormat.CreateALawFormat(32000,8));
            if ((outputStream.Position == 0) && (sound1.Id3v2Tag != null)&& (sound2.Id3v2Tag!=null))
               // outputStream.Write(sound1.Id3v2Tag.RawData, 0, sound1.Id3v2Tag.RawData.Length);
                //outputStream.Write(sound2.Id3v2Tag.RawData, 0, sound2.Id3v2Tag.RawData.Length);
            Mp3Frame frame;
            Mp3Frame frame2=null;
            //waveWriter.Position = 0;
            while ((frame = sound1.ReadNextFrame()) != null && (frame2 = sound2.ReadNextFrame())!=null)
                if (frame2!=null)
                    //outputStream.Write(frame2.RawData, 0, frame2.RawData.Length);
                    waveWriter.Write(frame2.RawData, 0, frame2.RawData.Length);
                if (frame!=null)
                    //outputStream.Write(frame.RawData, 0, frame.RawData.Length);
                    waveWriter.Write(frame.RawData, 0, frame.RawData.Length);
Sep 2, 2014 at 9:04 AM
hm, not quite sure what your actual goal is...having never worked with MP3, however, looking at your code and wikipedia (for MP3) it looks like you MUX frames in time, that is 26ms of one song, then 26ms of the other and so that what you want? I dont know but I could imagine that might lead to strange output (-: do you want to play those songs parallel? Then you have to setu a sample/wave provider chain (two input, one output) and write the output of that one into a file