Skip to content

Instantly share code, notes, and snippets.

@windytan
Created February 10, 2013 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windytan/4748902 to your computer and use it in GitHub Desktop.
Save windytan/4748902 to your computer and use it in GitHub Desktop.
use constant BPS => 300;
use constant SRATE => 44100;
$dur = 0;
for (qx!cat olddata.asc!) {
chomp($a = $_);
if ($a * $preva < 0) {
$nbits = int($dur / (SRATE/BPS) + .5);
print ((($preva < 0) ? 1 : 0) x $nbits);
$dur = 0;
} else {
$dur++;
}
$preva = $a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment