views:

2798

answers:

4

Hi, I have 2 wav files that I want to make/combine/merge into one file with the two sound tracks.

Is there any api for that task or some built inn commands in .NET that can I can use in som genius way to make this task possible?

Many thanks for the help. :)

+1  A: 

If I'm not mistaken, you can just append the bytes from the second file to the end of the first. If there is any header data, you'll want to exclude that (see here)

Be advised that you may hear a click or pop between the two clips, as there will be no blending. You could probably get around this by fading (gradually reducing the values for the last few ms to the center value).

Jon B
A: 

The straightforward way would be to interpret the wav file headers, extract the samples and interleave the samples from both files into a new sample stream which you write to a new wav file. You could also add the sample values of both source wav files sample by sample to 'mix' both files into a single track. The wav file format is not that complicated so it should not be too difficult to write this code. Also, there are lots of open source projects containing code to read and write wav files. Note that things can get somewhat trickier of both source wav files have different sample rates. Check this for a description of the wav format.

Han
+1  A: 

If you only need to do this once then your best bet is to use some software specifically for the task. Praat or audacity will do this (join or merge two tracks).

Praat can also be scripted so it is possible to script Praat and then call Praat and the script from within a .Net application.

Rob

RobS
hum :) Yes, I know that, the problem is that I have like 60 files files that need to be combined into 15 minutes files. And most likely do I have to do this more than once. I have had a look at sox and mancoder as an example of what you are telling but they don't seem to to the trick.
suxSX
+2  A: 

Sorry, I was maybe a little unclear. I don't want to merge them so they play synchronously. I want to append the tracks to the end of each other so they play one and one after each other in the same file.

But I think I found the answer in this thread.

It works perfectly and it are using the technique Jon B mentioned earlier.

suxSX