Skip to content

Instantly share code, notes, and snippets.

@windytan
Last active December 17, 2015 10:48
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/5597089 to your computer and use it in GitHub Desktop.
Save windytan/5597089 to your computer and use it in GitHub Desktop.
$fs = 48000; # sample rate
$fc = 3729; # carrier frequency
$filter = " sinc -$fc"; # optional LP filter
$fc = freq($fc);
open(IN, "sox scrambled.wav -c 1 -b 16 -e signed -t .raw -|");
open(OUT,"|sox -r $fs -c 1 -b 16 -e signed -t .raw - descrambled.wav".
$filter);
while (not eof IN) {
$acc += $fc;
$acc -= 65536 if ($acc > 32767);
read(IN,$a,2);
print OUT pack("s",unpack("s",$a) * sin($acc/32768*3.141592653589793));
}
sub freq { int(.5 + $_[0] * 65536 / $fs); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment