LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Play Wave File - how to wait until finished in ONLY local block diagram section

Labview 6.1 on Win 2000

I am playing several .wav files sequentially to create dynamic messages for a phone alarm system, based on what is wrong (simplified example: "Alarm on" "Sensor X" "Unit X" "Please Respond").

I just noticed that when the .wav files are playing, ALL vi's in the entire hierarchy stop executing, not just this subvi with the "Snd Play Wave File.vi"! This is not acceptable, my monitoring and logging functions need to keep operating.

Is there a way to "wait until finished" only locally? Is there a way to see if the play VI is finished?
The only thing I can think of is to time every .wav file and set up a table of filenames and length in time and look up how long t
o wait, but there are a lot of .wav files and this adds complexity to maintenance/updates.
0 Kudos
Message 1 of 5
(3,615 Views)
If you wait until finished, it will hold on to that thread until it is done playing. "Snd Play Wave File.vi" will use whatever thread was given to it. So if the calling thread is in the User Interface thread, all user interface activity will be blocked until completion. You can get around this by having a thread you don't use elsewhere call the VI. Set the thread in VI Properties>>Execution.

If you don't wait until finished, you can't query to find out if it is complete. This may be what you want. What do you need to ensure happens after the the sound completes?

-Lars
0 Kudos
Message 2 of 5
(3,615 Views)
> I just noticed that when the .wav files are playing, ALL vi's in the
> entire hierarchy stop executing, not just this subvi with the "Snd
> Play Wave File.vi"! This is not acceptable, my monitoring and logging
> functions need to keep operating.
>
> Is there a way to "wait until finished" only locally? Is there a way
> to see if the play VI is finished?
> The only thing I can think of is to time every .wav file and set up a
> table of filenames and length in time and look up how long to wait,
> but there are a lot of .wav files and this adds complexity to
> maintenance/updates.

Does the code playing the .wav uses a DLL, ActiveX, or the sound VIs?
Most likely, this code is running in the UI thread of LV, and it will
affect the other code in LV that mu
st run in the UI thread including
indicator update and property nodes.

If it is possible to affect the wav playing to run in another thread,
the UI in LV will be free to process events or draw. If not, the
diagram should run normally until it needs to execute code that requires
the UI thread, and it will also keep the UIs from updating, even if the
diagram is running. To test, you might make a VI that increments an
integer every milliseconds or something. Before and after playing the
..wav playing, is the timer affected in execution, or just in its ability
to update displays?

Greg McKaskle
0 Kudos
Message 3 of 5
(3,614 Views)

I leave an example which can contribute, you can use output sound info but will have to wait to finish the thread

0 Kudos
Message 4 of 5
(3,143 Views)