LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sound synchronous with Visual

Solved!
Go to solution

Hi,

 

I am developing a VI that provides breathing guidance to the user. Guidance is provided using audio and visual. I am not exactly able to figure out the audio guidance and have implemented the rest of the algorithm. let me show how it goes-

The VI calcualtes what breathing rate to guide at and a horizontal bar fills (0 to 100%) and empties to signify breathing in and out. eg- If breathign rate is 10 breaths per minute = each breath lasts 6 seconds = 3 seconds spent breathing in and 3 seconds spent breathing out(assuming 1:1 ratio, which is a control and changed by the operator).

I want to now incorporate audio feedback for the user who wishes to close eyes to relax. I have 2 .wav files for breathing in and breathing out and aim to play these files for the duration of the breathing rate - eg play file 1.wav for 3 seconds and file2.wav for 3 seconds and then file 1 and so on.

With time breathing rate reduces and length of time played increases.

I am not quite figuring this out.

I would be grateful if anyone can direct towards ideas /provide brief sample code to be used as starters.

 

A sample audio file attached.

 

0 Kudos
Message 1 of 7
(2,969 Views)

I will give you my tentative thoughts on this.

 

I think you should record an audion of the maximal lenght you will need to play. You say that at the beginning one audio file will have to play for 3 minuted, but later the time will increase. So you have to know the maximal time for the audio to be played and record an audio of such lenght. 

 

Next, if the prolongation of the playback is automatic and not controlled by the user, you should have a coefficient of the rate of the prolongation during time. And to get the current lenght of the playback I would simply multiply the previously mentioned coefficient by the initial value (which is 3 mins.). 

 

To play one audio after another cyclically, you could simply use a stacked sequence structure (interchaging the playback audios continuously) placed in a loop. You should measure the time during the playback and activate the next sequence when the limit is reached. In your case the limit would also be dynamic and it would get updated during the therapeutics. 

Message Edited by Giedrius.S on 02-13-2010 07:23 PM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
Message 2 of 7
(2,958 Views)
hey jaspal can u give ur email id?
0 Kudos
Message 3 of 7
(2,914 Views)

Hi Vizz,

 

Its jaspal.boparai@habinternational.co.uk.

0 Kudos
Message 4 of 7
(2,885 Views)

I am managing to play a .wav file of length 30 seconds, but I want to stop it after 10 seconds.

I am not quite able to do so.

How do I stop playing a .wav file after a fixed time before the end of file is reached. I tried the timeout(s) option of  Sound Output Write.VI but it doesnt work.

 

Thanks

0 Kudos
Message 5 of 7
(2,881 Views)
Solution
Accepted by topic author Jaspal
The Sound Output Stop.vi should stop playback immediately.  You can use an event structure or other timing structure to call it when you need it.  You will not be able to use the simple Play Sound File.vi.  You will need to read the sound file data using sound file VIs, then use the sound output VIs to play it.  See the LabVIEW example files for how to do this.
Message 6 of 7
(2,867 Views)

Thanks DFGray,

That worked.

0 Kudos
Message 7 of 7
(2,859 Views)