LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sound output Restart/Clear

Problem: sound output of a waveform in a loop is missing after the first run of the loop (until it reaches a later section of the waveformfrom where it stopped last).
 
Description: I am outputing waveform recorded data through the sound card using the SO VIs. I create and configure the task using 2 buffers (SO Config and SO Set Num Buffers) and start the task before a while loop (SO Start). Inside the loop I use the SO Wait and SO Write VIs to output my waveform segments not unlike the example that comes with Labview. After exiting the loop (exit button) I use SO Clear to release resources. That works ok. But if I re-enter the loop then I get no sound output unless I let the loop run longer than where it was stopped on the previous run.
 
I have tried several things but nothing seems to work unless I stop and re-start my program. Can anyone help me here? Thanks.
0 Kudos
Message 1 of 3
(2,639 Views)
My guess is that what you are seeing is the need to fill a sufficient number of buffers before the sound starts playing.  Here's a few questions:
 
1.  What do you mean by "re-enter the loop", how are you re-entering the loop (i.e. with another loop, or by running the program again), and what VIs get called before you re-enter it (i.e. are you reconfiguring the output)?
 
2.  How many buffers have you set?
 
The best thing would be to experiement with the number of buffers.  If you're still having trouble, try posting some sample code or a screenshot so we can get a better idea of where you might be going wrong.
 
Regards,
Ryan K.
0 Kudos
Message 2 of 3
(2,626 Views)

1. By re-enter the loop I mean that the loop that plays the audio is within a larger loop that controls the application flow (event handling loop as in producer/consumer pattern). So when certain event happens the inner audio loop starts until it finishes the audio output (reading from file) or a stop button is pressed, and then it falls back to the main loop that waits for user events to re-start the inner loop.

2. Buffers are set to 2.

I have played with the number of buffers but it doesn't change the situation (just makes it choppy if I use less buffers). I'll try to isolate the code and display the relevant part if I can since there is a lot of other stuff on the program.

I should mention that the data source comes from data recorded on a datalog file which is resampled. Before the inner loop the file is opened, then read within the loop to generate the output, and finnaly closed after exiting the inner loop. Not sure if that has anything to do with the issue.

0 Kudos
Message 3 of 3
(2,612 Views)