Combining WAV files in C #

I have 2 wav files that I want to make / merge / merge into a single file with two audio tracks.

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

Thank you for help.:)

+4
source share
5 answers

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

Consider that you hear a click or pop between two clips, as there will be no mixing. You can probably get around this by fading (gradually decreasing the values ​​for the last few ms to the center value).

+3
source

Sorry, I was a bit unclear. I do not want to combine them so that they play synchronously. I want to add tracks to the end of each other so that they play one and one after another in one file.

But I think I found the answer in this thread.

It works great and uses the Jon B technique mentioned earlier.

+4
source

If you need to do this only once, it is best to use some kind of software specifically for this task. Praat or audacity will do this (merge or merge two tracks).

Praat can also be a script, so you can script Praat and then call Praat and script from a .Net application.

Rob

+2
source

An easy way would be to interpret the headers of the wav files, extract the samples, and alternate the samples from both files into a new stream of examples that you write to the new wav file. You can also add approximate values ​​of both source wav files according to the model in order to β€œmix” both files into one track. The format of the WAV file is not so complicated, so writing this code is not so difficult. In addition, there are many open source projects that contain code for reading and writing wav files. Note that things can be a little more complicated than the original wav files have different sampling rates. Check this out for a description of the wav format.

0
source

Yes, you can simply add the data of the second wav (excluding its headers) as sais Jon B, but you must also change the title of the first file to indicate the new length, otherwise some audio players will stop at the end of the first part.

For dynamic concatenation, since you do not know the size of the full wav at the beginning, you can put a fake length in the header of the first file, for example, put 10 hours.

Then the audio player should just wait until you have added all the data. It works only for ffmpeg

0
source

All Articles