[HOW-TO] Recover broken audacity .aup file from hard disk

Recently, I discovered that my laptop hard disk was failing service. Before total meltdown, I wanted to save at least some of the Audacity projects on the disk to a usb-device.

During the process, I encountered many input/output errors, because of bad sectors on the hard disk. One of the error occured during transmission of an audacity project file/ index file (.aup). The exact error message I got was ‘Error Splicing File: Input/Output Error’. The result was, that only 388 KB of the total 468 KB were transmitted to the USB drive. If you might have encountered a similar issue, remember that not all hope is lost if you have (most of the) data files and (part of the) audacity project file. Here’s how I managed to recover my project file for the most important part. I really wanted to share and I thought this to be the best spot.

Excuse me if my English lets you down at some point, it’s not my mother tongue. I’m also not a programmer, just someone that knows a little html and php.

Recover the project from the faulty hard disk
While Audacity project files are not recognised by any of the data recovery tools I know, I started my computer using a live-DVD of Ubuntu Studio 14.04.1. I suppose any live dvd or usb of any linux distro will do. In my case, it was the /home/ partition which was formatted /ext4/. So it should be a distro that supports /ext4/
When in live mode, I tried to search the partition for any important project or document. The Audacity project went straight onto a USB-drive, I chose to skip all parts / files that encountered Input/Output Errors like the one mentioned above.

I stored the files on another computers’ hard disk. First I tried to open the audacity project that encountered the error while copying the project file (.aup). It returned the following message “Error: no element found on line 6635”. So probably, the project file was copied fine until this line.

Structure of the .aup project file
I made a back up copy of the audacity project file, so I could do some trial and error with it.
I opened the file using a text editor (in my case gedit).

The project file works as an index file for Audacity. It tells Audacity which audio block file is place where and under which conditions. The project file is build up like a table in HTML.
tells Audacity about the project, and in which state is was when it was closed the last time
the audio block files within belong to the same audio track. channel=“0” means it’s the left track. Channel=“1” means it the right audio channel. If a channel=“0” has the linked=“1” (yes), it means that Audacity should consider this wavetrack as a part of a stereo track. I found this very important when fixing my audacity project.
Then there are the tags and , they also contain information about this specific wave track.

Knowing this, you probably can figure out how to recover your damaged .aup project file. But I will continue my explanation about my approach.

Step one: closing the tags
When Audacity told me that it couldn’t find an element on line #, and it didn’t run the project file, I first tried to close the and properly.

In gedit, I turned on line numbers, and looked up line 6635, the one I got the error message about. I first checked if the last audio block file was properly included.

It should be something like this:

<waveblock start="42729472">
					<simpleblockfile filename="e000521f.au" len="262144" min="-0.711823" max="0.534271" rms="0.099917"/>

Where “e000521f.au” is the name of your audio block file, located in the project files folder.

After that, I closed all remaining tags in this way:

			<envelope numpoints="0"/>

Step 2: un-link incomplete audio tracks
As I said, in my case I could only copy 388 KB of the total 468 KB of my Audacity project. Logical conclusion: not only the closing tags are missing, but also a lot of tags linking to audio block files (.au). Since my project only contained stereo tracks, in other words ‘linked wavetracks’, Audacity would still not open the audacity project.

I solved this issue by searching for the last [Channel=“0”] in the project file. By changing Linked=“1” to Linked=“0”. I changed the stereo track to a seperate left track and a right track. Saving the audacity project file again.

Now I could open the audacity project. Of course it mentioned the audio block files that were not-linked, and asked me to remove them. I chose to keep and ignore them, and work on the project. The result is shown in one of the attachments. There are audio parts missing, especially in the last channel. Because the project file was still a bit buggy (for example, pressing play and stop made Audacity freeze), I chose to export the project to .wav and import it into a new Audacity project. From there, I will try to recover most of the interview and I will be able to publish it later on.

Hope this can save someone from the trouble (stress!!) I went through, if there are any questions just let me know.

if there are any questions just let me know.

Which Audacity version? The very early Audacity versions produced Projects that were far easier to rescue than the current ones.

This How-To applies to the version 2.0.5. (and I guess, 2.0.6, too, but it isn’t included in Ubuntu Studio yet)