dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Search | Go
Wiki > Main > FixingWaves

Fixing a corrupt wav file


Sometimes when rockbox is unable to close a wav file properly, a corrupt file will be created, but the recovery process is fairly simple, and I'll explain it in detail in this document. This process was done on a windows computer, but the linux or mac equivelent shouldn't be too hard to figure out, as the method will be practically identical, only using a different hex editor.

What you'll need


Open the WAVE file in XVI32, depending on the size of the file, this might take a little while, but a progress bar will be displayed. When it's done, you should see a screen similar to the screenshot below.


In fact, the only damaged parts of the WAVE file are the chunk data, which refers to the size of the file, which wasn't written. So to start off with, we need to find out the number of bytes in the file so that we can rebuild these parts of the WAV. Take a look in the properties box, and write down the number of bytes somewhere. In the example below, there are 274,595,884 bytes in the file.


Now, select the character directly after the letters "RIFF" in the right hand pane of XVI32, this is the first part of the corrupt data. Head to the Tools menu, and then to "Encode Number..."


Now, in the box that comes up, there are a few things that need to be entered. Firstly, in the "Number" field, enter the number of bytes in the file, minus 8. So for my example I enter 274595876. Ensure longint is selected, and overwrite at current address is also selected.
Important: Make sure the cursor is at the fifth byte, just after "RIFF".
Hit OK to fix the first part of the file.


This part is almost the same as the last part, but this time you need to change a couple of things. Firstly, you need to change where the cursor is. It should be directly after the word "data". Secondly, the number to encode should be the filesize minus 44, 274595840 in my case. Take a look at the screenshot to make sure you have it all correct (don't copy my number though), then hit OK.


Once that's all done, save the file, and open it in the media player of your choice, it should be working OK.


I'm looking into the cause of these corrupt files (rockbox isn't closing the file properly in certain situations) and hopefully I'll have a patch soon, but in the mean time, I hope this tutorial is helpful. While creating this tutorial, I used this page for all the info on the WAVE headers, which was really useful.
r1 - 14 Jul 2006 - 13:48:39 - WillRobertson
Copyright by the contributing authors.