How to split WAV files which have grown larger than file size limit

6 views (last 30 days)
I have a scientific instrument which continually logs to a wav file until the user stops the recording. A colleague left it running too long resulting in a 3GB+ file, and the header of the wave file getting corrupted. The only fields which show up using audioinfo are the sample rate and bytes per sample. It have attempted to generate a blank 10 minute wav file, and then replace the data from byte 44 onwards (I.e. I skip the header). The approach didn’t work. Does anyone have ideas of other approaches I can try?

Answers (1)

Walter Roberson
Walter Roberson on 5 Dec 2022
However, depending on how the data was logged, it might not be possible to get anything back.
When growing WAV files, it is common for one chunk of WAV data to be written out, and then for the header to be updated to reflect how long it turned out to be. Unfortunately that is prone to problems if you try to store more than the maximum file size, or if something goes wrong during the writing. One approach that reduces the errors is to update the header after a bufffer-full, so that at any one time only the last buffer might go missing... provided that you do not write too much data.
Another approach when growing WAV files is to put bunches of samples into separate segments. If I recall correctly you can get around some of the header limitations by mostly ignoring them, and writing out chunks that each individually live within the size limits. The original WAV format was designed by Microsoft to be able to just copy one WAV file after another without having to update anything in the headers. If that is the approach taken by the software, you might be able to get a fair bit of the data back, perhaps.
But if the data happened to be logged to a filesystem that has a 2 gigabyte limit, then it becomes more difficult to predict what the file system would have done with the file when you tried to grow the file larger than that.
  3 Comments

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!