Using 3 or more sound outputs\ or multiple sound devices

Largoh

New member
Joined
Jul 21, 2011
Messages
2
Programming Experience
1-3
I'm creating an application that will have 3 streams of audio.
I can get 2 streams playing easy enough using DirectX AudioVideoPlayback and setting the balance for each Audio Instance.
However, I need a 3rd Audio instance to play out of another output such as the Rear or Centre.
An alternative would be to be able to select a different sound device in the machine to play the 3rd audio stream.

I've been searching the net for 2 days now trying to find a solution, but have so far been unsuccessful. I've tried a few alternative libs such as DirectShow.Net, DirectSound, BASS.Net, QuickTime and OpenTK.
Some of them do what I need to do, but they are either too difficult to use and therefore impractical or they are missing some other essential features such as Events which are required to make the rest of the application work.

I'd very much appreciate some assistance on this. The project is kind of stuck until I can get this key feature working.

Cheers.

P.S. Would anyone oppose to me posting this same thread on other forums? As I need an answer as soon as I can, I'd like to spread my question out there so that I can improve my chances of getting an answer.
I will of course post a solution if one is found elsewhere without advertising external websites.
 
Just a little update.
I've decided that the easiest way would be to use 2 sound cards.
In theory, one soundcard (The system primary card) will play 2 mp3 files using AudioVideoPlayback. One audio instance will be panned to the right, the other to the left.
To play the 3rd stream, I will use DirectSound and select the secondary SC as the device. Obviously this means I can only use WAV files, but that's not an issue since they are small files.


I do have it kind of working, but not with the full functionality that I need.
Basically, it will get a command from another application via TCP/IP along with which file needs to be played. So lets say the file is "file1.wav", it should find that file in a specified Directory and play it.
This is where I'm getting the issue. DirectSound just won't play the sound unless I use OpenFileDialog to select it.


I've tried a few things, here are some attempts to get it working but have failed.


All of these methods either don't play anything, or give a System.IO.IOException error.


VB.NET:
Dim _dev As Device
        Dim _buffer As SecondaryBuffer
        Dim FS As New FileStream(s_ContentLocation & "Waves\" & filename, FileMode.Open)


        _dev = New Device(m_Device.DriverGuid)
        _dev.SetCooperativeLevel(Me.Handle, CooperativeLevel.Priority)


        _buffer = New SecondaryBuffer(FS.Name, _dev)




        If Not _buffer Is Nothing Then
            _buffer.Play(0, BufferPlayFlags.Default)
        End If
And ...


VB.NET:
        Dim m_WaveDev As Device
        Dim m_WaveBuffer As SecondaryBuffer


        Dim l_Wave As String = s_ContentLocation & "Waves\" & filename
        If File.Exists(l_Wave) Then


            If m_WaveBuffer IsNot Nothing AndAlso m_WaveBuffer.Status.Playing = True Then
                m_WaveBuffer.Stop()
            End If


            m_WaveDev = Nothing
            m_WaveBuffer = Nothing


            m_WaveDev = New Device


            m_WaveDev.SetCooperativeLevel(Me.Handle, CooperativeLevel.Priority)


            m_WaveBuffer = New SecondaryBuffer(l_Wave, m_WaveDev)


            If Not m_WaveBuffer Is Nothing Then
                m_WaveBuffer.Play(0, BufferPlayFlags.Default)
            End If


        End If


I've also tried a few variations of those but nothing seems to work.
The way I can get it to work is using OFD and passing OFD.FileName to SecondaryBuffer, but as I said, this is not the required functionality. End users shouldn't be interacting with the actual app, just the remote app which sends the commands.


Any pointers anyone can give me? Thanks very much.
 
Back
Top