4 Replies - 258 Views - Last Post: 14 February 2018 - 04:22 PM Rate Topic: -----

#1 rderkis   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 18

Play a sound file thru a specific playback device in Windows 7

Posted 14 February 2018 - 11:39 AM

I am 71 and can not concentrate like I used to. I want to play a sound file (I can use any format necessary) thru a specified playback device. I have figured out how to get the devices. I just need to know how to play a file to the selected device.
Windows 7
VB 2010 (I know its old but so am I :-)

Thank You!
Ron Derkis

  Private Sub PopulateDeviceComboBox()
        DevicesComboBox.Items.Clear()
        ' How many wave out devices are there? WaveOutGetNumDevs API call. 
        Dim waveOutDeviceCount As Integer = waveOut.GetNumDevs()
        For i As Integer = 0 To waveOutDeviceCount - 1
            Dim caps As New WaveOutCaps
            ' Get a name - its in a WAVEOUTCAPS structure.  
            ' The name is truncated to 31 chars by the api call. You probably have to  
            ' dig around in the registry to get the full name. 
            Dim result As Integer = waveOut.GetDevCaps(i, caps, Marshal.SizeOf(caps))
            If result <> MMSYSERR.NoError Then
                Dim err As MMSYSERR = DirectCast(result, MMSYSERR)
                Throw New Win32Exception("GetDevCaps() error, Result: " & result.ToString("x8") & ", " & err.ToString)
            End If
            DevicesComboBox.Items.Add(New WaveOutDevice(i, caps))
        Next
        DevicesComboBox.SelectedIndex = 0
    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Play a sound file thru a specific playback device in Windows 7

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,460
  • Joined: 12-June 08

Re: Play a sound file thru a specific playback device in Windows 7

Posted 14 February 2018 - 11:49 AM

Which device? Does it have an SDK or some library you could tap to use?
Was This Post Helpful? 0
  • +
  • -

#3 rderkis   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 18

Re: Play a sound file thru a specific playback device in Windows 7

Posted 14 February 2018 - 01:35 PM

View Postmodi123_1, on 14 February 2018 - 11:49 AM, said:

Which device? Does it have an SDK or some library you could tap to use?


To be specific this is what I am trying to do and why I chose this route.
I have 11 security cameras that warn me, by playing (vary loudly) a file telling me which room, the motion occurred in. By design it is so loud it looses some of its clarity. I want a second file that tells Alexa "Turn on the rec room lights" (or "living room lights") etc.. This file will play rather quietly and clearly on a second set of speakers in my computer room next to a echo dot. To do this I installed a second sound device in my computer to play the alexa commands.
Now I am trying to write a program that will play the alexa commands on that second playback device. The security program will call my program with parameters. (File name to play).

As far as libraries only free ones I can reference to in VB 2010
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,460
  • Joined: 12-June 08

Re: Play a sound file thru a specific playback device in Windows 7

Posted 14 February 2018 - 02:10 PM

I am getting the room lights are network enabled, right? You maybe able to cut out the middle man of having a second speaker/specifically recorded wav file/echo dot by just trying to program against a SDK for the lights.
Was This Post Helpful? 0
  • +
  • -

#5 rderkis   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-February 18

Re: Play a sound file thru a specific playback device in Windows 7

Posted 14 February 2018 - 04:22 PM

View Postmodi123_1, on 14 February 2018 - 02:10 PM, said:

I am getting the room lights are network enabled, right? You maybe able to cut out the middle man of having a second speaker/specifically recorded wav file/echo dot by just trying to program against a SDK for the lights.
This uses Un4seen.bass dll.


A lot of people have tried that route. It is vary complicated and unreliable. The easiest most reliable way is piggybacking on all of amazon's and wemo's research & money and using it like it is designed. With voice commands. I found a way of doing it with a simple c++ program, now if I can convert that program to VB.net, I would be in like flint. :-)

using Un4seen.Bass;

namespace BassPlay
{
    public partial class Form1 : Form
    {
        BASS_DEVICEINFO deviceInfo = new BASS_DEVICEINFO();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          
        }

        public void getDevices()
        {
            deviceInfo.name.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Bass.BASS_Init(1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetDevice(1);
            // create a first stream in this context
            int stream1 = Bass.BASS_StreamCreateFile("alarme.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream1, false);

        }

        private void button2_Click(object sender, EventArgs e)
        {

            Bass.BASS_Init(2, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetDevice(2);
            // create a second stream using this context
            int stream2 = Bass.BASS_StreamCreateFile("alarme1.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream2, false);

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Bass.BASS_Init(3, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetDevice(3);
            int stream3 = Bass.BASS_StreamCreateFile("alarme2.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream3, false);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Bass.BASS_Init(1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_Init(2, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_Init(3, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            // set the device context to the first device
            Bass.BASS_SetDevice(1);
            // create a first stream in this context
            int stream1 = Bass.BASS_StreamCreateFile("alarme.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream1, false);

            // set the device context to the second device
            Bass.BASS_SetDevice(2);
            // create a second stream using this context
            int stream2 = Bass.BASS_StreamCreateFile("alarme1.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream2, false);

            // set the device context to the third device
            Bass.BASS_SetDevice(3);
            // create a third stream using this context
            int stream3 = Bass.BASS_StreamCreateFile("alarme2.wav", 0L, 0L, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(stream3, false);
        }

   }
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1