LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Playing Sound

Solved!
Go to solution

Hi LabVIEW community

 

i have been trying to play a sound by LabVIEW functions. I did it, but i've got a problem. When i condition the reproduction by a button, i can play the sound once time, when i try to reproduce one more time, it doesn't work. can somebody help me?

 

 i'll ad the VI and a zip file with the .wav

 

Download All
0 Kudos
Message 1 of 6
(5,038 Views)

You are reading your wave file inside the loop so it works the first time but the second time there is no data left to read.

Move your Read File VIs outside your loop and just pass the wave data to the Sound VI.

0 Kudos
Message 2 of 6
(5,030 Views)

Like that?

labview sound problem.png

When i try it, i heard the sound in a infinite loop

0 Kudos
Message 3 of 6
(5,022 Views)
Solution
Accepted by Gabriel1010

First run in Finite Mode. Then also take the Write Sound VI outside the loop so you only write the data once.

Then make sure to configure the Sound Output Configure VI with the exact same number of samples as your file signal.

Finally add a Sound Output Start / Wait and Stop inside your loop.

That way you are going to play the exact signal once every time you press your button.

 

Btw... remember to wire through the False case as well, otherwise you will not pass a valid session to your close VIs.

0 Kudos
Message 4 of 6
(5,003 Views)

it works, but with a lot of lag response. If i play the sound one time, i need to wait like 2 seconds to play it again.i need to have a very fast response, because this is gonna be a piano application

labview sound problemsssss.png

0 Kudos
Message 5 of 6
(5,001 Views)

This likely because you have not adapted the number of samples/ch in your configuration VI to your actual waveform length. The default is 100.000 so you'll have to play a little more than 2 sec before you can re-play. 

0 Kudos
Message 6 of 6
(4,972 Views)