release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Search | Go
Wiki > Main > FixingWaves

Fixing a corrupt wav file

Introduction

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

Method

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.

010ri.png

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.

024pv.png

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..."

038nc.png

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.

049sm.png

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.

053yj.png

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

Conclusion

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.

r2 - 02 Apr 2021 - 20:46:06 - UnknownUser

Copyright © by the contributing authors.