LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I continually record sound from the sound card, store it to disk?

I would like to be able to record and store to disk from the sound card, but I need to be able to write the data to disk on the fly.  I'm trying to record very long times and it seems that when I fill gthe memory I get an error.  Can anyone help?  It does not have to be in *.wav format but I will have to be able to play it back somehow.  If you can help please do.
Thank you
Bob
0 Kudos
Message 1 of 6
(4,650 Views)
LabVIEW 8.2 has TDMS file format for streaming data to disk. It should perform well enough. Alternatively create a queue, write data from sound card to this queue in on thread (producer thread). In another thread read data from the queue and append it to file (consumer thread). You can create multiple threads by having multiple loops parallel.

Message Edited by Tomi M on 10-08-2006 09:10 PM

--
Tomi Maila
0 Kudos
Message 2 of 6
(4,648 Views)
This sounds good, but I'm using 7.1.1, and I have no idea how to do what you said.  If you have an example please share it with me.
Thank you very much.
Thanks
Bob
0 Kudos
Message 3 of 6
(4,643 Views)
I can't write you an example right now. I try to explain. First, create a queue for waveform or waveform array if you are going to acquire multiple channels (search a help for queue if you don't know what it is). Then create two parallel while loops that both run as long as you want to acquire data. Pass the queue you create to both of these loops. This way both loops can access the same queue. Then in the first loop (producer loop) acquire your data in blocks of what ever size and enqueue the blocks to queue. In the other loop (consumer loop), check queue periodically for new elements. When there are new elements in the loop, dequeue the elements and append them to file. The producer loop should be fast enough to be able to acquire data from the sound card buffer fast enough. Therefore it doesn't write data directly to file but to a queue. File operations performance may change from moment to moment. The other loop doesn't need to be real-time. It just keeps reading the queue which acts as a large buffer for data, and writes it to disk. It doesn't matter if the performance of this consumer loop transiently gets slow as long as overall performance keeps in pace with the producer loop. This way you can acquire data in real time from a relatively small buffer without performance issues as long as your disk just performs well enough. If your disk doesn't perform well enough, then you need to compress the data in the consumer loop. Easy way to compress is to convert from double array to single array. If this doesn't help, try reducing the sampling rate of the data acquisition.
--
Tomi Maila
0 Kudos
Message 4 of 6
(4,640 Views)
Unfortunately, TDMS does not exist in LV7.1.  However, NI-HWS does (find it on the driver CD next to the computer based instruments such as DMM, SCOPE, and FGEN).  It has an added advantage in that it uses HDF5 to store the waveforms, so you can read it from other packages.  In addition, it also supports compression (lossless only).  HWS is 64 bit, so you can stream until you run out of disk space.  Be careful opening that file.  You may want to check out the tutorial on handling large data sets, which gives yet another method.
0 Kudos
Message 5 of 6
(4,612 Views)
There is a program called Loop Recorder that does exactly what you want.  You can find it at here

Message Edited by tbob on 10-09-2006 10:10 AM

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 6
(4,602 Views)