﻿
# Restore data from scratched Audio-CDs

#### Description
Helps to restore data from files that cannot be read accurately. For example
tracks from scratched Audio-CDs may contain random errors. If a track is
read multiple times and saved to 3 or more files (maximum supported:384),
then usually the different copies will have different errors. Hence it is
possible to analyse them and statistically choose the best value for each byte.

#### Command line options

| Argument                  | `gsr <file1> <file2> <file3> [file 4-384]` |
| :------------------------ | :----------------------------------------- |
| `-o`                      | Specify the name of the restored output file |
| `-a`                      | Try to detect and avoid using interpolated samples in the output |
| `-b`                      | Disable read buffering |
| `-md2 -md4 -md5 -sha1`    | Calculate hash using: `MD2` `MD4` `MD5` `SHA1` |
| `-sha256 -sha384 -sha512` | Calculate hash using: `SHA256` `SHA384` `SHA512` |

###### Example
```powershell
gsr 1.wav 2.wav 3.wav 4.wav 5.wav 6.wav -o out.wav
gsr r:\01\1.wav 3.wav 4.wav 5.wav 6.wav -b -sha1
gsr *.wav -a -b -sha1   # Wildcards are supported [* ?]
```

#### Notes
If no output file is specified, out.wav is created in the same directory
as the first file, or if no slash `/` or backslash `\` is found in
it's file name, then the current directory is used.

By default read buffering is enabled to spead-up reading of files cached
in RAM. However when reading many large files that cannot fit in RAM,
it might be better to disable read buffering by adding the `-b` switch.
Note: write buffering for the output file is always disabled.

Each file requires 2 or 4 MB of RAM for read buffers (1 large page).
63 input files + 1 output file will use 128 or 256 MB RAM.

CD drives may conceal read errors from Audio-CDs by taking the average value
of the previous and next sample, if they don't have errors. If most
of the input files have such a corrected sample, it will get most of
the hits and is copied to the output. To avoid this, specify the `-a` switch.
Corrected samples are detected and don't count as hits. In most cases this may
find a better match, but may also introduce errors, so avoid input files with
many errors. Use the hit score from a previous scan to find the input files
with least hits and remove them.
Note: the `-a` switch will force 16 bit scanning, instead of 8 bit, so the
samples must be aligned to 16 bits.

If the current sample is different in all input files, then the value is
copied from the input with highest total number of hits so far.


#### Supported Platforms
☂︎ Apple iOS, macOS  
☂︎ FreeBSD  
☂︎ Linux, OpenWRT  
☂︎ Windows 


#### [Prerequisites and build instructions](../../../lib.git#Prerequisites)


#### © 2014-2023 Georgi Valkov
https://httpstorm.com/download/gsr-statistic-restore/
