07-18-2019 07:43 AM
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?
07-18-2019 08:53 AM
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
07-18-2019 10:14 PM - edited 07-18-2019 10:15 PM
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.
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.
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.
07-19-2019 10:52 AM
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.
08-15-2021 07:12 PM