取消
显示结果 
搜索替代 
您的意思是: 

Playing Sound

已解决!
转到解答

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

 

下载全部
0 项奖励
1 条消息(共 6 条)
6,163 次查看

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 项奖励
2 条消息(共 6 条)
6,155 次查看

Like that?

labview sound problem.png

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

0 项奖励
3 条消息(共 6 条)
6,147 次查看
解答
已被主题作者 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 项奖励
4 条消息(共 6 条)
6,128 次查看

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 项奖励
5 条消息(共 6 条)
6,126 次查看

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 项奖励
6 条消息(共 6 条)
6,097 次查看