Rescue of a WAV file

Portrait photo of Andreas Pehnack

Andreas Pehnack

Not long ago a man contacted me and asked for help.

He had interviewed someone (audio+video), however the audio recording was interrupted at the end. Since the file was not readable by QuickTime and the interview couldn't be repeated you can imagine the situation in which he was.

Now, how to rescue a WAV file that wasn't written until the end?

Unfortunately the user didn't know anything about binary files, their formats and what could be wrong with an audio file. His first idea was to copy the end of a valid WAV file to the end of his interview to make it work.

So he sent me a short audio recording of 3 seconds to extract header and footer as a first step to repair his main interview file.

But… while WAV files indeed have a well-defined file header, there is no such footer - this means, the idea to fix the file end couldn't work! We had to take a different approach…

He then downloaded the free version of Synalyze It! and applied the grammar to his file. Because all the structures and their elements was Greek to him he proposed to send me the file.

Before doing so I wanted to know if even an unexperienced user could solve such a serious problem on his own by learning the basics of the format underlying his file.

A WAV file starts with the RIFF header, followed by so-called chunks, similar to those in PNG files.

Simple-WAV-Header What could be wrong with his file? First, we tried to fix the size field in the RIFF header structure which was zero. Obviously, since the recording software didn't finish its job and couldn't set the correct size after recording when the size is known.

This didn't do the job, QuickTime still complained with an "OSStatus error -208".

We had to dig deeper and in the Sample Data chunk we found the solution: There's also a size field that informs the reading software how much data follows. Our unfortunate but courageous user filled there the size of the audio data.

He wrote in an email to me:

"It worked!!!!!!!!!!!!!!!!!!!!!

I opened some other folders, and saw that there was no file size under "sample data, chunksize." So I put in that file size from earlier, with the total file size -8. That did it!!!!!!!!!!!!!!!!!!!"

Envision how happy he must have been! The corrupt file was repaired and his interview was rescued. :-)

In our life as a user of software we take much for granted. Software reads and writes data and in most cases all works well. However sometimes it's necessary to go below the surface and see what's actually there.

Synalyze It! was developed with the intent to support people who want to look behind the curtain and understand what's real - in the case of computers this is the meaning of all those bits and bytes surrounding us.