From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing WAV file contyinuously(streaming)

I have a requirement to continuously write data to a WAV file.The present VI available (write to wave file.vi) dumps all the data in one stretch. here i think all thje data is accumulated in memory using "shift register and build array" and finally put into a WAV file. this is not suitable for me since i have to write continuously for a very long time and four files at a time. I am writing to binary file using "streaming to disk" techniques. i want to do similar thing to a WAV file.(labview 7.1). is there any method ?
0 Kudos
Message 1 of 7
(4,347 Views)
You will find the framework for what you need here:-

http://forums.ni.com/ni/board/message?board.id=170&message.id=156093
This information wil enable you to stream to disk into files as required....

However, just how big is big?
0 Kudos
Message 2 of 7
(4,330 Views)

http://forums.ni.com/ni/board/message?board.id=170​&message.id=156093


The written Link is down - is there anybody who has a working link or the header of the topic? Greets

0 Kudos
Message 3 of 7
(3,679 Views)

Its been many years since I posed on this forum.

The text link I posted still works (at least two minutes ago)....

 

The link you have made seems to have an error in it as the web site is reporting invalid parameter.

 

The Microsft links I created are all out of date, shame on Microsoft!

 

Some nice souls posted working VI's to re-write headers, so you should be up and running very quickly.

 

Cheers.

Message 4 of 7
(3,635 Views)

Try

http://forums.ni.com/ni/board/message?board.id=170​&message.id=156093

 

There were some extra unprintable characters in the middle of the URL.

Message 5 of 7
(3,622 Views)

As you may be aware, a WAV file needs to adhere to a particular format (do a Web search for WAV File Format to learn more).  One requirement of the Format is the beginning of the File include, in bytes 4..7, a 32-bit integer denoting the number of Bytes in the entire Wave File.  A similar requirement is present for the "Chunk" that actually holds the Sound information -- the number of Sound Samples is part of the Header.

 

This makes writing a Streaming Wave routine a bit of a challenge -- how do you Predict the Future to know, in advance, the number of Sound Samples you will have in your file?

 

Assuming you can't do this, you can "lie", then "correct the lie".  You can start writing the Wave Header information, putting -1 (the largest possible 32-bit number when considered as an unsigned quantity) where Size is indicated.  Figure out how to organize the Sound section (say by writing 10 seconds of sampled data at a time, and keeping careful track of the number of samples written).  When you are done, close the file, re-open it, position it at the "wrong" data sizes, and "correct" them using the now-known number of samples.  If you do it right, you will have "fooled" the system into thinking you wrote the file all-at-once.

 

Bob Schor

Message 6 of 7
(3,615 Views)

Hi Bob!
I tried to use "correct the Lie" implementing the llb descriped in this whitepaper:

http://digital.ni.com/public.nsf/allkb/3CF14E200E8DB3CB86256C840028C5D2?OpenDocument

But it won't work correct. One mistake i got to correct is the exact order how the arrays CH1 to CH9 are written into file - i used to do this with local variables and the aren't refreshing at the correct order. Any Idea how to implement a Function that's building up an 2D-Array that is only refreshing when new data is saved at a local variable?
On the other Hand, the created .wav file isn't accepted in audacity and windows media player as a .wav.
Only thing that's working is to import Data as "Import Raw Data" in Audacity, but samples and sampled time isn't that correct. It should be 3k Sps and a Resolution of 16 Bit per sample - and you should see an sinus with 1 Hz from CH1...8

I attached my whole VI and the created .wav file from the VI and also the raw Data which is read in from the Beagle Protocol Analyzer can be found here:
https://www.dropbox.com/sh/36i1log7j7lrimm/AAA4lcXQYxrsRUI5AdyhdgQoa?dl=0

Any ideas how to correct the mistakes i have done so far?

Greets, Pulled

0 Kudos
Message 7 of 7
(3,565 Views)