A little time ago, I needed to join .wavs together. I couldn't find a simple solution on the internet so i decided to create one. Credit to Inferrd for helping me out. Anyway, the code is below and it is very simple. The .wav files are in resources in the example but they could be anywhere you like. The magic happens in the sub Join() and it plays the concatenated sound to prove it works. All you need is a form with a button called Button2.
vb.net Code:
  1. Public Class Form1
  2.  
  3.     Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
  4.         Dim wav1 As List(Of Byte) = IO.File.ReadAllBytes("h.wav").ToList
  5.         Dim wav2 As List(Of Byte) = IO.File.ReadAllBytes("e.wav").ToList
  6.  
  7.         wav1 = Join(wav1, wav2)
  8.         wav1 = Join(wav1, IO.File.ReadAllBytes("l.wav").ToList)
  9.         wav1 = Join(wav1, IO.File.ReadAllBytes("ow.wav").ToList)
  10.  
  11.         Using ms As New System.IO.MemoryStream(wav1.ToArray)
  12.             Using snd As New System.Media.SoundPlayer(ms)
  13.                 snd.Play()
  14.             End Using
  15.         End Using
  16.     End Sub
  17.  
  18. Private Function Join(ByVal wavBytes As List(Of Byte), ByVal wav2 As List(Of Byte)) As List(Of Byte)
  19.  
  20.         '   add on the second file excluding its header bytes
  21.         wavBytes.AddRange(wav2.Skip(44).Take(wav2.Count - 44))
  22.  
  23.  
  24.         '   rewrite the ChunkSize and Subchunk2Size fields of the Header
  25.         Dim chunkSize As Integer = wavBytes.Count - 8
  26.         Dim subChunk2Size As Integer = wavBytes.Count - 44
  27.  
  28.         Dim chunkSizeBytes() As Byte = BitConverter.GetBytes(chunkSize)
  29.         Dim subChunk2SizeBytes() As Byte = BitConverter.GetBytes(subChunk2Size)
  30.         For i = 0 To 3
  31.             wavBytes(4 + i) = chunkSizeBytes(i)
  32.             wavBytes(40 + i) = subChunk2SizeBytes(i)
  33.         Next
  34.  
  35.         Return wavBytes
  36.     End Function
  37.  
  38.     ' <summary>
  39.     ' Function to save byte array to a file
  40.     ' </summary>
  41.     ' <param name="_FileName">File name to save byte array</param>
  42.     ' <param name="_ByteArray">Byte array to save to external file</param>
  43.     ' <returns>Return true if byte array save successfully, if not return false</returns>
  44.     Public Sub ByteArrayToFile(ByVal _FileName As String, ByVal _ByteArray() As Byte)
  45.         If System.IO.File.Exists("temp.wav") = True Then
  46.             System.IO.File.Delete("temp.wav")
  47.         End If
  48.         Try
  49.             ' Open file for reading
  50.             Dim _FileStream As New System.IO.FileStream(_FileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write)
  51.             ' Writes a block of bytes to this stream using data from a byte array.
  52.             _FileStream.Write(_ByteArray, 0, _ByteArray.Length)
  53.             ' close file stream
  54.             _FileStream.Close()
  55.  
  56.         Catch _Exception As Exception
  57.             ' Error
  58.             Console.WriteLine("Exception caught in process: {0}", _Exception.ToString())
  59.         End Try
  60.  
  61.     End Sub
  62. End Class