I've been up on campus talking at the PNPSummit and in my spare time recording podcasts with interesting people. A particularly cool show that'll be coming up very soon ran pretty long, and filled up my 1 gig CF Card. I had to transfer that now "part 1" off that disk and keep recording "part 2." My editor Lawrence will then stitch the two files together and make the transition sound natural.
I uploaded the two parts and went along with my day. However, I got a call from the guys saying that the file wouldn't open and that it might be corrupt. Yikes. This has happened before, but it's usually just a transmission error. I opened the original file and....crap!
It won't open. Hm. Well, I figured that some WAV file programs are more strict than others. Perhaps I could open it in another program.
Well, shoot. It's not opening in any programs. That's not cool. I tried WAV Saver and while I see on the net that lots of folks have had success with it, for me it crashed as I clicked repair. Apparently my file was messed up in a special way.
As I Googled around for answers and the program "GoldWave" kept coming up. It's apparently very well thought of.
When I dragged the corrupt file into GoldWave I got this friendly dialog:
This is cool because here I can get to the RAW PCM data. I just needed to tell the system what the original recording was in. Since we're on Intel, we're little endian. The recording was in stereo, at 44.1kHz and was 24-bit. Also, anything over 12-bit is usually signed. So, I'm feeling good at this point. However:
...I ended up with a screen full of white noise. Bummer. At this point, I'm getting close to giving up. Then, on a whim, I remembered that you can click the tiny down arrow next to the Open button in the Visual Studio Open File Dialog.
I selected Binary Editor and got this:
Now, I'm not an expert on the WAV file format, but I understand it's just a header and some RAW PCM data. It's supposed to be pretty simple, but ALL ZEROS is simpler than even I expected. :)
So, I opened up Part 1, the valid WAV file, and looked at its header. Then I selected it on a word boundary (guessing) and copied it to the clipboard. Then I flipped over to the broken WAV and pasted in the first 48 bytes of the header of the working file, up to and including the "data" chunk.
Then, I saved the file with a new name and opened it in GoldWave.
Amazing, it worked! Notice the correct WAV format listed in the status bar. This trick worked, because I stole the WAV Header from a file that was encoded in the identical way. It wouldn't have worked with different files. There was a small warning from GoldWave that the header's length differed from reality, but this was fixed by File|Save As with a new filename.
Miracle of miracles. I thought the show was ruined. This technique was lucky because apparently only the header was missing and I had a header available with the same format. I hope this helps someone with the same problem.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.