LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert characters into a file using Labview

I have collected acoustic data that I am turning into wav files. After the collection, I now know the file size and need to insert the wav file header on top of this file. Can anyone tell me how to concatenate two files, or insert the wav header (string) data into the other file? My current method is very inefficient. The collected data file can become extremely large, so I am trying to avoid reading this file. I would rather poke data into it without overwriting any existing data. Thanks in advance.
0 Kudos
Message 1 of 6
(3,283 Views)
You could have a template file with the header information already in it.(or multiple for different formats) Then add the wav data after the header using the offset feature of the write file and save it as a different name.
Message 2 of 6
(3,284 Views)
You could also save the data with enough blank space at the start of te file to hold the header data. You could then overwrite those bytes to insert the header data.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 6
(3,283 Views)
hello
See attached vi. It is a modification of NI warite wav vi. It only writes header. So Write a default header, append your data and write heder again using the number of bytes of audio.

Hope this helps.
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 4 of 6
(3,283 Views)
> I have collected acoustic data that I am turning into wav files. After
> the collection, I now know the file size and need to insert the wav
> file header on top of this file. Can anyone tell me how to concatenate
> two files, or insert the wav header (string) data into the other file?
> My current method is very inefficient. The collected data file can
> become extremely large, so I am trying to avoid reading this file. I
> would rather poke data into it without overwriting any existing data.

As others have pointed out, you can overwrite portions of a file, but
the OS file APIs don't allow for inserting. Either leave blank space
when initially making the file, then seek and write, or read the
contents of the file in chunks and write to the other. Doing
this in
chunks means you don't read the entire file into memory at once, and the
chunk size affects the speed. Perhaps someone already as a utility VI
for doing this, but it is a simple loop with read, write, and error
checking.

Greg McKaskle
0 Kudos
Message 5 of 6
(3,283 Views)
Thanks for the info. Per everyone's suggestions, I created a dummy header then appended my data to this header. After my collection completed, I overwrote the header with the correct file size information. Everything works much more efficiently now. Thanks to all who've responded. This was the first time I've posted a question and the reponse time and responses were great!
0 Kudos
Message 6 of 6
(3,283 Views)