Gear / Technical Help > Post-Processing, Computer / Streaming / Internet Devices & Related Activity

Homegrown WAVE header repair utility

(1/38) > >>

pigiron:
I saw that a few folks are getting corrupted headers in their wave files and having a struggle with the existing utilities trying to fix the problem. So I cobbled together a wave header repair utility this last weekend that may help... 'cause I hate to see good music go to waste ;D

But it's a butt ugly command line program... if you want pretty, try next door.

Since it's mostly "universal" C coding, I was able to get it to compile on both Linux and Winders... don't own a Mac, sorry.

Beat the hell out of it and it seems to be working, but I'd be surprised if there wasn't some bugs still down in the cracks... so for sure, only use it on a backup copy.

Here's a sample output where it successfully repaired a wave file that had nothing but zeroes in the entire header and a partially truncated audio data sample (about as bad as it get's)...

# ./fixwav junk.wav

Existing header data. Look for the words 'RIFF', 'WAVE', 'fmt',
or 'data' to see if this is even a somewhat valid WAVE header:

00000000:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000020:  00 00 00 00 00 00 00 00 00 00 00 00             ............

Exit the program now? [y/n] n
The total file size is 32617577 bytes
Chunk Size of 0 at offset 4 is incorrect... repairing
Chunk Format at offset 8 is incorrect... repairing
Subchunk1 ID at offset 12 is incorrect... repairing
Subchunk1 Size at offset 16 is incorrect... repairing
Subchunk1 Format at offset 20 is incorrect... repairing
Is the file recorded in 0 channels?  [y/n] n
Enter number of channels... 1=Mono, 2=Stereo, etc: 2
Is the number of samples per second = 0?  [y/n] n
Enter number of samples per second: 44100
Is the number of bits per sample = 0?  [y/n] n
Enter number of bits per sample: 16
Subchunk1 Format at offset 24 is incorrect... repairing
Subchunk1 Bytes Per Sample at offset 32 is incorrect... repairing
Subchunk2 ID at offset 36 is incorrect... repairing
Subchunk2 Size at offset 40 is incorrect... repairing
Found incorrect number of audio samples. This means that either
   the new WAVE header data is incorrect, or the audio samples
   in the existing file were clobbered. Do you wish to add silent
   audio samples to the end of the file?
   WARNING: this will modify the existing file. [y/n] y

Header repair is required!
   Overwrite the existing file? [y/n] y

File repair successful

As you see, you need to know a little about the file... the number of bits, the samples per second, and the number of mics... while that might stump a n00b, I don't think you'll have any problem.

One caveat... it assumes you're feeding it a "normal" wave file... i.e. only a single data "Subchunk"... if it ain't such an animal... or if it simply has junk data appended to it (there's some dumb ass programs that add ID3 tags like that), it's gonna hose up.

anyway, they're attached below... enjoy... and remember... you got it free  ;D

udovdh:
Interesting. Thanks.
No source?

strsng:
Great, Thanks a lot. This is what I've been looking for!

Will_S:
If you're willing to share the source code, I'll take a crack at compiling it for the Mac.

pigiron:
sounds good... only ask that you throw it back up here so that all can share... unless someone has a better idea of where to keep it... it's too small, simple, and ugly for something like sourceforge.

It's created on linux, but surprisingly, the windoze compiler I used ate it without any CR/LF conversions (and without having to create a new Makefile)... and hopefully not too many changes required for the mac.

fixes and enhancements welcome  :)

Navigation

[0] Message Index

[#] Next page

Go to full version