Hello!
I've created a program that uses a 8 channel external audio card to play audio through waveOut. I was wondering how would it be possible to create several instances of audio. I would prefer if these additional streams could be created indefinitely, so I don't have to manually program it for each channel.
Right now everything works fine until I have to stop the audio. If I select two different devices and play, everything is OK, but stopping them messes everything up.
I currently have this (in VB.Net):
Private Function CreateInputStream(ByVal fileName As String) As WaveStream Dim inputStream As WaveChannel32 If fileName.EndsWith(".mp3") Then Dim mp3Reader As New Mp3FileReader(fileName) inputStream = New WaveChannel32(mp3Reader) ElseIf fileName.EndsWith(".wav") Then Dim wavReader As New WaveFileReader(fileName) inputStream = New WaveChannel32(wavReader) Else Throw New InvalidOperationException("Unsupported extension") End If volumeStream = inputStream Return volumeStream End Function Private Function PlayAudio(ByVal file As String, ByVal devNo As Integer) waveOutDevice = New WaveOut mainOutputStream = CreateInputStream(file) waveOutDevice.DeviceNumber = devNo waveOutDevice.Init(mainOutputStream) waveOutDevice.Play() Return waveOutDevice.PlaybackState End Function Private Function StopAudio() If Not waveOutDevice Is Nothing Then waveOutDevice.Stop() End If If Not mainOutputStream Is Nothing Then volumeStream.Close() volumeStream = Nothing mainOutputStream.Close() mainOutputStream = Nothing End If If Not waveOutDevice Is Nothing Then waveOutDevice.Dispose() waveOutDevice = Nothing End If Return Nothing End Function
Here's a picture of my UI work in progress to clarify.
http://www.upload.ee/image/1970564/ap.jpg
Any tips would be appreciated.