-1

Help me, please. I have 3 wav file. 1.wav file plays with 0-10 seconds, 2.wav file playing with 3-7 second, and 3.wav file playing from 5 - 8.25 second. Tracks are playing simultaneously.

How to mixing or combine in C# code them into one file to get a wav file length of 10 seconds?

Target platform Windows Phone or Windows 8 Store App without the use of third-party libraries. All files are identical: 16 bit, 44100, stereo.

How to mix files to correctly position the time in c# code?

arsenium
  • 571
  • 1
  • 7
  • 20
  • 1
    What platform are you targetting? Console, Winforms, WPF, Phone or Store? – Rowland Shaw Mar 25 '14 at 15:39
  • It is desirable to Windows Phone, but it is possible and for Windows 8 Store. Preferably without the use of third-party libraries. How can I do this by reading the files in stream? I realized that I had to leave one header file, and somehow connect "data" all three files, but I do not understand ... – arsenium Mar 25 '14 at 15:44
  • This may help you: http://stackoverflow.com/questions/6777340/how-to-join-2-or-more-wav-files-together-programatically – Shai Aharoni Mar 25 '14 at 15:47
  • Take a look at http://naudio.codeplex.com/ – Matthew Layton Mar 25 '14 at 15:47
  • Please, do not include information about a language used in a question title unless it wouldn't make sense without it. Tags serve this purpose. – Ondrej Janacek Mar 25 '14 at 16:06
  • It appears you've asked this [three](http://stackoverflow.com/q/22633443/50447) [times](http://stackoverflow.com/q/21725920/50447) already this afternoon - it would be better to focus this all down as a single question with all the information, rather than include snippets here, there, and everywhere. – Rowland Shaw Mar 25 '14 at 16:45
  • I want to understand how to mix wav files to c#. What I did wrong? – arsenium Mar 25 '14 at 18:51

1 Answers1

2

There are several ways to do it.

My recommendation is to write a custom wave class which can read and write wave files, because unlike some other music files, the main info of a wave file is stored in its header.

Here's the detailed wave file format specification. https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Another way to bypass the painful decoding is using a third party library, such as NAudio.

Kuree
  • 118
  • 7
  • Thank you for your example, but it is an example of concatenation. And I need it to mix files. I read about wav format, but I did not understand how to do it ... You can explain in more detail to me? All files are identical: 16 bit, 44100, mono. I read the title of the first file, and then what to do? data from all three files how to mixing? – arsenium Mar 25 '14 at 15:54
  • 1
    You need a [BinaryReader](http://msdn.microsoft.com/en-us/library/system.io.binaryreader(v=vs.100).aspx) to read input stream. In terms of mix, here is a simple algorithm. Please see this answer [here](http://stackoverflow.com/a/823905/3373428) – Kuree Mar 25 '14 at 17:07
  • Begin to understand a little, but now it is not clear how to mixing all the same so that 1.wav file plays with 0-10 seconds, 2.wav file playing with 3-7 second, and 3.wav file playing from 5 - 8.25 second? Add silence? – arsenium Mar 25 '14 at 17:35
  • 1
    After you read all the samples from three wave files, given the byte sample rate and sample rate, you can create a new list. By adding data either from raw wav files or from mixed data, you can create the new samples. Silence is just dead 0, and how long the silence depends on how many consecutive 0 you put into the samples. – Kuree Mar 25 '14 at 18:03