I’ve had an accident with data loss and successful recovery using Audacity, so I thought I’ll post my experience for others to benefit from it.
I recorded something with a Zoom H2 portable sound recorder.
I’m not sure if because of a broken SD card or my mistake (post factum I’ve noticed that I didn’t switch off the device before taking out the SD card) - the recorded file was not visible on the card when I put it into the computer.
So I used photorec program from package testdisk to get back my files.
Install it if you don’t have it:
sudo apt-get install testdisk -y
And run it as root:
sudo photorec
It has a nice CLI interface that leads the user thought the process of recovering the files. It’s reading a block device omitting the filesystem and looks for the file headers. Despite the name it can find almost any type of files you’d ever need.
So I got a bunch of WAV files among others. I loaded them all up to Audacity to inspect what’s there. After a while I recognized the file I was looking for.
I copied the file to another directory (the original files belong to root user so it’s hard to do anything with them besides reading and using root for other stuff than administration and special tasks is dangerous) and changed it’s name so I can easily identify it - photorec names files like this:
recup_dir.1/f0419968.wav
recup_dir.1/f0853888.wav
recup_dir.1/f0881568.wav
recup_dir.1/f0914624.wav
recup_dir.1/f1132256.wav
recup_dir.1/f1133152.wav
recup_dir.1/f1957512.wav
I started a new project in Audacity and imported the file as raw audio.
My corrupted file was captured as a stereo 96000 kHz / signed 24-bit little-endinan WAV. You need to know or guess this if you want to recover your own data.
Some parts of it were ok - a 10% chunk in the middle, the rest was either badly distorted (like after +30 dB hard clipping) or completely turned to noise (like it was interpreted with wrong bit depth or was some other binary data, not audio).
I imported the file several more times incrementing the byte offset by 1 each time, putting in the same parameters elsewhere (it’d be nice if Audacity remembered last used parameters and provide a “reset” option to get defaults back BTW.).
Each imported iteration looked different.
After 5th trial I’ve realized I now have all parts of the file properly imported, I just need to put them together. This took some selecting, and deselecting, copying form one layer pasting to the same place on another. I needed to manually fix some bad samples that didn’t copy properly (a bug?). After that I just needed to truncate the file header (as it’s not audio data so will sound like rubbish anyway). And voila!
My explanation of the phenomenon of data corruption:
Somehow different parts of the files got different byte offsets, which caused the bytes to change their magnitude as digits, so some parts of the audio data were interpreted as louder than they were captured (some so loud to look like solid noise). Each sample was 24 bit, so 1 byte is 1/4 of a sample. So I needed to do 4 trials to go 1 sample forward. Why I really needed 5 trials? Not sure. Maybe you can tell me. Maybe the fact that it’s a stereo file matters here.
I hope this story can help you recover some lost recordings! If so, please write
Bless you!
- unfa