Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Go Back  Xtreme Visual Basic Talk > > > Choose between different sound cards for playback in VB.net


Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2017, 12:04 AM
jcvamp jcvamp is offline
Newcomer
 
Join Date: Jun 2009
Posts: 1
Default Choose between different sound cards for playback in VB.net


Edit by Moderator: Re: Choose between different sound cards for playback in VB.net
I just came across this. I'm working on a voice control system for home automation, and I wanted to have the ability to route different audio to different devices depending on where I'm controlling the program from.

I had to modify some of the code to get it to work for me (and had to overcome a lockload error), but the method works.

Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectSound
Imports System.IO
Imports System.Speech
Imports System.Speech.AudioFormat

Public Class Form1
    Dim synth As New Synthesis.SpeechSynthesizer
    Dim DsDevice As DirectSound.Device, mydevices As New DevicesCollection

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each dev As DeviceInformation In mydevices
            lstDevices.Items.Add(dev.Description)
        Next
    End Sub

    Private Sub lstDevices_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstDevices.SelectedIndexChanged
        If lstDevices.SelectedIndex = -1 Then Exit Sub
        DsDevice = New Device(mydevices(lstDevices.SelectedIndex).DriverGuid)
        DsDevice.SetCooperativeLevel(Me, CooperativeLevel.Priority)
        Dim bufferDesc As New Microsoft.DirectX.DirectSound.BufferDescription
        With bufferDesc
            .GlobalFocus = True
            .ControlVolume = True
            .ControlPan = True
            .ControlFrequency = True
        End With

        Dim VoiceStream As Stream = New MemoryStream()
        Dim sinfo As New SpeechAudioFormatInfo(128, AudioBitsPerSample.Eight, AudioChannel.Stereo)
        synth.SetOutputToWaveStream(VoiceStream)

        synth.Speak("Test")
        VoiceStream.Position = 0
        Dim _buffer As New SecondaryBuffer(VoiceStream, bufferDesc, DsDevice)
        _buffer.Play(0, BufferPlayFlags.Default)
    End Sub
To test, I have it saying 'test' over the selected audio device.

Thanks for the work you put in.

Last edited by Cerian Knight; 02-23-2017 at 10:28 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
 
Choose between different sound cards for playback in VB.net
Choose between different sound cards for playback in VB.net
 
-->