Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating Wav files

Status
Not open for further replies.

pjwraith

Technical User
May 17, 2002
12
GB
I have recently started playing with .net for its usefulness in performing functions for an application I use.

I am in need of an ability to join 2 wav files to produce a third singular wav file which contains the other two files added together. Ideally I would like to be able to join more than two but I can always repeat the function.

Does anyone know of a method of performing this action ?

Thanks in advance
 
I suppose you could read both files in a stream and then save it. Don't ask me how, just something to look into.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
What Chrissie is suggesting should be possible. Im not familiar with the .WAV format, but it appears to have no end of file marker, so it should just be a case of adding the Data Blocks together. You'll need to google WAV File Format to find more info on the format type of the file.
To read a file from a stream
Code:
Public Function zGetFileasByteArray(ByVal sFileName As String) As Byte()

Dim fs As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read)
Dim b() As Byte = New Byte(CInt(fs.Length)) {}
fs.Read(b, 0, CInt(fs.Length))
fs.Close()

Return b

End Function


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
The wav header specifies channels, average bps, sample rate and some more.
So to make a good concatination you will need to make sure those settings are the same, and then remeber to strip the header from the second file.
As SqueakinSweep said.. some googling on the wav format should be done ;)



- - - - - - - - - - - - - - - - - -
Im three apples high, Im blue, and i most certainly like that cold beer that should be every mans right after a hard days work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top