LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sound Output fills up memory

Solved!
Go to solution

Hi,

 

I need to do a sound test in which pink noise is played for many hours. I generate the noise waveform with no problem, but when I add the SO blocks they slowly increase the memory usage until it is filled up to 3.7GB and the VI stops. Why is this happening? Is there an alternative way to send the output to the sound card?

 

Any suggerstion is appreciated!

Thanks

Download All
0 Kudos
Message 1 of 7
(3,282 Views)

I also tried to use these sound blocks and they don't affect the memory usage, but the output sound is very ruined after a few minutes and it is interrupted when clicking on other windows...

Download All
0 Kudos
Message 2 of 7
(3,257 Views)

I don't think the SO Start.vi is not necessary (only needed if you used the SO Stop.vi before) but it is not related to your issue. I would try adding SO Wait.vi after SO Set Num Buffers.vi. This would force the loop to wait until the current data is played before iterating again. Maybe this will solve your memory issue.

 

Ben64

Message 3 of 7
(3,238 Views)

Echoing Ben's comment, you can take advantage of LabVIEW's parallelism by restructuring your program slightly to allow Noise Waveform Generation for the next sound output to proceed while playing the current sound, like this --

Continuous Pink Noise.png

Within the loop, Generate Sound (which is your code up to the transpose of the 2D array) and Play Sound (your three Sound VIs) will do their best to execute in parallel, with the timing determined by which finishes last (which should be the Play Sound VI).  So you will only generate one "extra" sound waveform, avoiding memory problems, but will have it ready "on time" to continue playing.

 

Bob Schor

Message 4 of 7
(3,230 Views)

Ben, Bob, thank you for your suggestions. I tried both of your solutions but unfortunately they don't solve the memory problem.

I still don't understand why the memory fills up, maybe it is related to the number of samples?

I use a frequency sample of 44100 and 44.1 samples/ms for the signal generation and Fs 44100 and 2 buffers for the sound card... I don't think that the sound buffers become full, because when I stop the VI there is no latency (instead if the sound card had not finished to play all the content of its buffer the VI would not stop immediately but would wait to play all the buffer and then stop).

Is my opinion correct?

0 Kudos
Message 5 of 7
(3,196 Views)
Solution
Accepted by biomed87

It seems that the problem was the input of the Wait time block. Changing it from 20ms to 1000ms there are no more memory problems.

0 Kudos
Message 6 of 7
(3,181 Views)

@biomed87 wrote:

I don't think that the sound buffers become full, because when I stop the VI there is no latency (instead if the sound card had not finished to play all the content of its buffer the VI would not stop immediately but would wait to play all the buffer and then stop).

Is my opinion correct?


Hard to say if true or not because SO Write.vi is calling a dll. In the Express Play Waveform vi the Sound Output Wait function is called, that's why you can't stop it before the end of the waveform. If there is no wait function called by SO Write Output then when you press stop the SO Clear.vi should stop the waveform from playing even if if there's some data left in the buffer.

 

Ben64

Message 7 of 7
(3,167 Views)