This project has moved. For the latest updates, please go here.

Merge/mix several wav files into one

May 22, 2012 at 4:42 AM

Hi,

 

I have several wav files (for instance, 60 files) that I need to mix into one WAV file, but not by concatenating the wav files, but instead, every wav file must be placed on a specific position like in a movie timeline. I hope I explained clearly.

 

Is this possible ? Is there a demo that I can take a look ?

 

TIA

 

 

Coordinator
May 22, 2012 at 3:32 PM

yes, you can do this with NAudio, but I'm afraid there is no demo.

You build an audio graph like this:

1) each WAV file is converted into a 32 bit floating point stream
2) you then use a WaveStream/WaveProvider that can prepend silence to position your inputs relative to one another
3) you use a mixer stream to mix them together
4) you optionally go back down to 16 bit audio

NAudio has WaveChannel32 for steps 1&2, WaveMixerStream32 for step 3 and Wave32To16Stream for step 4, so you can use them.

You can also do this with ISampleProvider based classes, but you have to make a class to do step 2 yourself.

Mark

May 22, 2012 at 6:54 PM

Thank you for your answer.

 

Some of the wav files overlaps, that is to say, maybe the position of a wav file is between the start and end position of another wav file. Point 2) needs some modification, because there is no silence ?

 

TIA

 

Coordinator
May 22, 2012 at 7:00 PM

that is not a problem. the amount of silence is measured from the start of the mixed WAV. it doesn't matter if there are overlaps, since everything will be mixed