LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Playing a wav file while doing other things?

Hello

I'm writing a program that displays a series of digits one after another,
while playing a wav file of a certain length. The idea is that 9 digits are
displayed for one second each (1), then 5 seconds blank screen (2), then a
keypad appears (3). The wav file should be playing throughout (1) and (2),
but stop when (3) happens. In one frame of a sequence, I play the wav file
(and set it to don't wait til finish), and present the digits in a
subsequence. In the next frame, I present the keypad. The wav file is the
correct length for this timing to work out (14 seconds), but the only way I
can see to execute (3) at the right time, is to use a timer in the first
frame to wait for 14 seconds. This works on a fast computer, but
on slower
computers there is sometimes a delay before the wav file is started. As a
consequence, sometimes the keypad appears (3) before the wav file has
finished. Does anyone have an idea how to ensure that this never happens? I
thought about setting the wav play vi to 'wait-til-finish' but then it won't
be able to display the numbers simultaneously...

Any ideas would be greatly appreciated!

Thanks
-Jody
0 Kudos
Message 1 of 4
(3,254 Views)
I wonder what code did you use to display digits that cannot run simultaneously with SndPlayWaveFile. Normally you may run other stuff while playing sound by setting "Wait Till Finish" as long as you use different dataflow (or thread) with the sound one. Maybe you can post your code here.

If your code doesn't allow you to simultaneously run both, you may have to use WIN API to poke the status of the Sound device and display the keypad after the sound device stops. I know the function sndPlaySound() can do this.

Hope this can give you some clue.
0 Kudos
Message 2 of 4
(3,254 Views)
It won't let me post my vi so I put it here with the wav file I'm using.

http://acoustics.auc.dk/~jg/labview/

This simplified version plays the sound and displays the first number,
then it waits til the wav has finished before displaying the remaining
numbers. I am using a different dataflow for the wavplay and for the
numbers loop, as far as I can see - is this the best way to do it?

cktears wrote:
>
> I wonder what code did you use to display digits that cannot run
> simultaneously with SndPlayWaveFile. Normally you may run other stuff
> while playing sound by setting "Wait Till Finish" as long as you use
> different dataflow (or thread) with the sound one. Maybe you can post
> your code here.
>
> If your code doesn't allow you to simultaneously ru
n both, you may
> have to use WIN API to poke the status of the Sound device and display
> the keypad after the sound device stops. I know the function
> sndPlaySound() can do this.
>
> Hope this can give you some clue.

--
Jody Ghani

Research assistant Email: jg@acoustics.auc.dk
Sound Quality Research Unit Phone: (+45) 9635 7509
Department of Acoustics Fax: (+45) 9815 2144
Aalborg University
Fredrik Bajers Vej 7-B5 http://www.soundquality.dk
DK-9220 Aalborg Øst http://www.acoustics.auc.dk
0 Kudos
Message 3 of 4
(3,254 Views)
The wav file you posted is pretty big. It's possible that on slower computers, it takes a longer time to load the file(?). In that case, you need to make sure to start the two count down display and the wav file at the same time.

Try the attached modification to your program. It has the added feature of not proceeding to the next frame until both the timer and wave file are finished. There is another mod to simplify the code by letting the for loop do the indexing for you.

Hope it's helpful.

Tim
0 Kudos
Message 4 of 4
(3,254 Views)