LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

play wav file if switch activated

Hi,

 

Is there a way to play one wav file if switch 1 is pressed and to have it play only once and then play a second wav file if swicth 2 is pressed? I cant find an example on any forum and I am new to Labview.

 

Thanks in advance.

0 Kudos
Message 1 of 5
(2,731 Views)

I have two reed switches connected to the analog inputs of a USB-6009 DAQ. I would like a wav file saved on my computer to play when switch one is activated and for the entire file to play; I would also like to play a second file if switch 2 is activated. Switch one will remain on until the end.

0 Kudos
Message 2 of 5
(2,727 Views)

Yes, you can do this quite easily with the VIs in the Sound palette but I doubt you're going to find a ready made example.  Post the code you've tried and we can show you where you're going wrong...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 3 of 5
(2,717 Views)

Hi, 

 

Thanks for your reply. I have posted a VI I am currently working on. I can play the wav file if I press the play button in the front panel. I can acquire the voltage signal that I need using the DAQ assistant. Now I need a way to convert the voltage signal into a digital signal (ie if voltage above 1v, then 1) and for this to activate the sound file. I can then repeat this for the second sound file.

 

Thanks.

0 Kudos
Message 4 of 5
(2,712 Views)

Well, there are about as many ways to do this as there are LabVIEW programmers but you can certainly make your VI much simpler as a start. 

 

Why do you want to use analog?  Why not just use the digital inputs of your USB-6009?  It has 12, you could make your own one octave keyboard!  If you want to use the analog in just use the Greater Than VI in the comparison palette to output a boolean.

 

If you can use digital just open the example called Digital - SW - Timed Input.vi.  It reads the DAQ digital ins and displays an array of booleans that can be toggled with the physical switches.  As you can imagine, from that point it is easy to trigger different wave files by using a simple case structure.

 

EDIT: forgot to mention that you should do this all in ONE LOOP.  Don't complicate things when you don't have to.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 5 of 5
(2,697 Views)