This project has moved. For the latest updates, please go here.

Play an MP3 file through a specific audio device

Oct 16, 2014 at 5:18 PM
Hello guys! :)
Please help me finish this project, is very important for me!

So, I need to create an application (written in VB.net) that can play MP3 files, through a specific audio device.

Let me give you a little more details.
I use Virtual Audio Cable to create (for example) 5 Playback audio devices.
Then, I need my program to list all that available devices.
After this, I need to be able to play a playlist through all these playback audio devices.

For example, let's say that I have 5 list boxes, called playlist_1, playlist_2, playlist_3, and so on (each with different MP3 audio files), and I want to play each playlist through different playback audio devices all at the same time.

I appreciate all the help I can get.
Thank you!

Here is my code so far:
Imports NAudio
 
    Private Sub PlaySound(ByVal soundfilelocation As String)
        Dim reader As NAudio.Wave.WaveFileReader = New NAudio.Wave.WaveFileReader(soundfilelocation)
        Dim wavechannel As NAudio.Wave.WaveChannel32 = New NAudio.Wave.WaveChannel32(reader)
        Dim player As NAudio.Wave.DirectSoundOut = New NAudio.Wave.DirectSoundOut
        Try
            player.Init(wavechannel)
            If System.IO.File.Exists(soundfilelocation) Then
                player.Play()
            End If
            player.Dispose()
        Catch
        End Try
    End Sub
But I don't know how to play through a specific device.

I also tried to list each available sound device with DirectSound:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectSound
 
Public Class Form1
 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        '
        Dim iIdx As Integer
        Dim _Devs As New Microsoft.DirectX.DirectSound.DevicesCollection
        '
        For iIdx = 0 To _Devs.Count - 1
            ListBox1.Items.Add(_Devs(iIdx).Description.ToString)
        Next
        '
    End Sub
 
End Class
Still no luck.. :(