LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I have a problem with finding a USB PnP sound device when searching for avaliable audio devices.

Solved!
Go to solution

Hi.

 

I am trying to build an application which can search for an USB PnP sound device and play a tone if the device is connected. I am able to search for audio devices using "Sound Device Info.vi" from the lvsound2.llb which comes with labview.

 

The vi can find the USB device under the right conditions, but there are problems - I will try describe 2 scenarios.

 

1. The USB device is connected before "Sound Device Info.vi" is called for the first time.

In this case the program can find the USB device. If I unplug it, the device disappears from the list of found audio devices. If I reconnect to the same USB port it reappears on the list. This is all good.

If I reconnect it to a new USB port however, the device is not found. This is not good.

 

2. The USB devices is not connected when "Sound Device Info.vi" is called for the first time.

"Sound Device Info.vi" is not able to find the device. Disconnecting and reconnecting does not make a difference.

 

I am running labview 2012 on windows 7.

 

I am running the application as a build exe.

 

I am calling "Sound Device Info.vi" as a "call by reference" and the reference is closed between calls to the vi. I was hoping this would unload the dll used in "Sound Device Info.vi" and this would solve the problem, but it has not.

 

Is there a way to reset labview usb information during run-time?

 

 

Regards

Stephan.

0 Kudos
Message 1 of 6
(9,508 Views)

I still have not found a solution to this problem.

 

Am I the only one who has struggled with this issue?

 

 

I found and old thread with a similar problem in Labview 8.6 - here the solution was to replace lvsound2.dll with the dll from labview 8.2.1

 

I tried this, but it did not make a difference.

 

/Stephan

0 Kudos
Message 2 of 6
(9,464 Views)

Probably someone would be willing to help if you had some code to look at...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 6
(9,456 Views)

I have attached a vi that shows the functions I use.

 

/Stephan

0 Kudos
Message 4 of 6
(9,437 Views)
Solution
Accepted by Winther79

Hi Stephan.

 

 

The Sounds VIs are calling a DLL located in:

C:\Program Files (x86)\National Instruments\LabVIEW 2012\resource\lvsound2.dll

 

Internally LabVIEW uses the DirectX API to enumerate the devices. The one caveat is that we probe for devices when the DLL loads. We do not probe again later. So in order for this to work for Bluetooth, USB, fire wire, etc. devices that may be inserted or removed at any time you will have to somehow control when that DLL loads and unloads. In order to do so, please see the following document:

 

Can I Dynamically Load and Unload a DLL in LabVIEW?

http://digital.ni.com/public.nsf/allkb/77594203D78D12278625729100758BE5

 

 

I would also recommand that you provide a Kudo for this Idea:

Update the lvsound2 library (Sound Input/Sound Output VIs) to support changing audio devices on-the-fly

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Update-the-lvsound2-library-Sound-Input-Sound-Output-V...

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
Message 5 of 6
(9,433 Views)

Hi again - sorry for the late response.

 

Thanks for your input A.E.P.

 

I have it working now after implementing functions to force unload of the lvsound2.dll.

 

I could not quite do it the way I wanted to though. When using the workaround to force unload of the dll, it is not possible to use functions that saves data for other functions to use. Fx I wanted to configure a waveform with the config function and then play it with the start function. This does not work when unloading the dll between calls so I had to create a soundfile so I could play the sound with only one dll call.

 

But it is working, so thanks for your help.

 

/Stephan

0 Kudos
Message 6 of 6
(9,393 Views)