LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Playing different sounds on different devices simultaneous

Hi, I'm trying to play different sound files on my PC speaker and on a USB headphone adapter.

i can see there are 2 devices but i can just play only one at a time (depend on the windows sound output)

is it possible to do so?

0 Kudos
Message 1 of 5
(3,689 Views)

The basic Sound VIs in LabVIEW use the Windows "Sound" API (I believe).  This allows you to send a two-channel waveform to "left" and "right" channels, but unless you have a very fancy Sound Card, you can't play one Audio file on your PC Speakers and a different Audio file on your Headphones (they both connect to the same source).

 

There are hardware devices that you can purchase that can generate waveforms and have D/A outputs to drive multiple speaker outputs.  Some of these have an API that you can possibly program with LabVIEW, but you'd probably be pretty much on your own ...

 

Bob Schor

0 Kudos
Message 2 of 5
(3,656 Views)

Hi LP-tst,

 

If Windows is showing two (or more) sound devices, you should be able to use them simultaneously from within LabVIEW. My laptop supports both Speaker and Headphone output (when the headphones are plugged in), and I can access them both and playback sounds simultaneously, even though only one of them is the default device.

 

sound_devices.png

 

Within LabVIEW there are a few VIs hidden in lvsound2.llb (specifically Get Num Devices.vi and Sound Device Info.vi) which help with determining the number of available output devices and their names. You can use this info to open multiple sound devices, and playback audio using both. See the attached code example.

 

multiple_audio_device_playback.png

 

I'm working on an open source DJ app written entirely in LabVIEW, and one of the features is simultaneous audio output on multiple devices (master + headphone cueing). Feel free to poke around the code for details on how the simultaneous output is being done.

 

One thing to note is that LabVIEW only enumerates the sound devices when it first starts, so you'll need to have all of the audio devices available in Windows before starting LabVIEW.

Message 3 of 5
(3,603 Views)

There's also WaveIO which is an alternate audio interface library for LabVIEW. It also supports multiple output devices along with WASAPI and ASIO if you need those lower level features. The included example PlayWave_multi_cards.vi demonstrates multiple audio device output.

Message 4 of 5
(3,589 Views)