Audacity Win 2.1.3: Fixing broken .wav files

I found something interesting on the Internet, about how to fix broken .wav files that won’t open in any players. Someone named Scott Hanselman said something about using a binary file editor, specifically a Hex editor, to fix the headers. However, I’m not sure where I can find any good Hex editors that would work with JAWS. Anybody have any pointers? I’ve tried Notepad++, but all I get when I read the file line-by-line is a bunch of weird code. Here’s an example of a .wav file that I’ve recently recovered with ICare Data Recovery Pro, but when I import it into Audacity as Raw data, unfortunately I get nothing but very loud static. What do I do next? When I import it into Audacity, it seems to want to say the file was encoded in PCM, 16 Bit, 44Khz, Big Endian. What’s “Big Endian”? A teacher of mine, Ed McManus, who works at the Music Technologies department at Lane Community College in Eugene, Oregon, told me that Hex editors are usually sight-oriented, in other words, I would have to have sighted help to fix the headers of a file that is presumably corrupted!

If importing RAW just produces static, then it’s probably not only the headers that are wrong.
The first thing that you need to know in order to fix a WAV file, is what the format is. If you don’t know what the format is, then you don’t know what headers are required.

Sometimes you may know what the format is because you know where the file came from - for example, if it was ripped from a CD and you know for sure that it was ripped as WAV (and not MP3 or any other format), then it is probably “signed 16-bit PCM WAV” with a sample rate of 44100 Hz. When you know what the format is, then you can import it into Audacity using RAW import. If you know the format but it still imports as trash, then the file is too badly damaged to be recovered.

If youdon’t know exactly what the format is, but you are certain that it is PCM WAV, then you may be able to determine the format by trial and error with RAW import settings.

If you succeed in importing as RAW, then you can export as a WAV file and Audacity will add the correct headers for you - no need to manually edit the headers.

I recorded it originally with Sonar 8.5 Producer Edition 64 bit, at a bit depth of 24 bit, PCM, and a sampling rate of 44.1KHZ. From what I understand, Sonar usually saves .wav files as Riff Wave.

Try importing as RAW, 24-bit, 44100 Hz sample rate.
Try each of the Endian settings.
Do you know how many channels it had (mono or stereo)?

I’ve tried 24 Bit, 44 KHZ, Little Endian, Mono, and I get static. I tried 24 Bit, 44 KHZ, Little Endian, Stereo, still static. Same thing with Big Endian. I even tried changing the offset to 1 or 2 bites, and I get a combination of static with scrambled audio. What do I do next?

It’s not looking very hopeful. Which settings give you “scrambled audio”?

Here’s an example of a .wav file that I’ve recently recovered with ICare Data Recovery Pro,

If you intended to attach a file or give a link, it’s missing from your post.

It’s also possible for the data recovery tool to do more damage. So you might try reading raw audio from the original and the recovered file.

Is the file size about right? For example 24-bits is 3 bytes, so that’s 3 x 44,100 for each second of audio. Double that for stereo.

…specifically a Hex editor, to fix the headers. However, I’m not sure where I can find any good Hex editors that would work with JAWS.

I can’t help you with that, but it wouldn’t be that helpful anyway… In order to reconstruct the header you’d need the same information as you need to open the file as raw data. If something is wrong with the header, the easiest thing to do is open the file as raw and then re-export as WAV (after guessing all of the correct parameters).

Big Endian. What’s “Big Endian”?

It’s the byte-order. (24-bit data has 3 bytes per sample.) The data in a WAV file is normally little-endian. That means the data is “backwards” with the least significant byte first. (But the samples are in the correct order, so the 1st 3 bytes represent the 1st sample.)

The audio data in a WAV file is just an array of bytes, so if you don’t start at the right place (offset) or you get the byte-order wrong, or if you get the bit-depth (number of bytes per sample) wrong, the sound will be scrambled. If you guess the sample rate wrong, it will simply play at the wrong speed. Or, if the offset is wrong the left & right channels can get mixed-up (not so bad). With 24-bits (3 bytes) an offset of 0, 1, or 2, should work (although the left & right in a stereo file could be mixed up). Then the pattern just repeats after that. Except if there’s a header it will get read as audio and you’ll hear a short glitch at the beginning (which can be edited out). The header is supposed to be 44 bytes so an offset of 44 would be correct if you had a good WAV file.

By “Original”, do you mean the “Raw file”? ICare Data Recovery Pro finds both “Lost Files” and “Raw Files”. With “Raw Files”, however, it’s hard to tell what’s what, as they all have names like “File 001”, instead of the original names like “Drum Overhead (5)”. Would I listen with my ears to tell which file is the one I want?