LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set the pointer qt the end of a .wav file

I would like to store data in a .wav file every 500ms. But when i try the Sound file Write.vi, it overwrites the data previously saved in that file. I tried to use the Set File Position.vi but it creates an error.
How should i do?
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 1 of 8
(3,579 Views)
You can do a simple modification to Snd Write Wave File. In there, the actual file write is done by the Write Characters to File function. There is an input called 'append to file' that is unwired so it defaults to the false value and will always create a new file. Create a control for this and wire it to the connector pane. then save the modified VI with a new name and in a new location.
0 Kudos
Message 2 of 8
(3,575 Views)

hi there,

if you just set "append to file" to TRUE the "Snd Write Wave File" vi will also append the header information to the file wich will lead to a corrupted file, because the header contains information about the duration of the wav file.

i suggest to store the data in a array (or in a binary file) as U8/U16 1D/2D (depending on your resolution and mono/stereo). if you want to have a wav file then write the array (or reread the binary file) using "Snd Write Wave File".

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 8
(3,570 Views)
Thank you for your reply. I already tried the solution of the array, but it's taking a lot of memory and my application will be working, in the future, on a PDA. So I can't do it like that.
Is there really no solution to set the position of the pointer at the end of the file?

Thank you
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 4 of 8
(3,567 Views)
Chris made a great point about the simple mod I mentioned would append the header each time. You could try putting the header info inside a case statement and wire the append control to the case statement as well. In the append case, just write the data. Even if you could set the pointer to the end of file, you would still have the problem of appending the header each time and still have to change the write characters to file.
0 Kudos
Message 5 of 8
(3,565 Views)

hi there

i've been so curious i had to try this out (see attachment)... the vi may needs a little bit more testing end debugging.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 6 of 8
(3,555 Views)
I've written a vi that appends sound data to an existing wav file. It does this by appending the data to the file as well as updating the wav header. Here it is
0 Kudos
Message 7 of 8
(3,126 Views)

A wavefile has header that contains some information More about it here http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

This header has a constant size 45 bytes if I am not wrong. So if you work with a dynamic recording you must create a file with a empty header. Then your recording is done you can update your header. Then working with binary files this is not problem. Just tell the file write to write x bytes from offset 0.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 8 of 8
(3,123 Views)