Created
June 8, 2014 23:17
-
-
Save windytan/08650f1c7e84c7370130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use DateTime; | |
$snum = 0; | |
$writing = 0; | |
open OUT, "|sox -t .raw -e signed-integer -b 16 -r 44100 ". | |
"-c 1 - stamped.wav"; | |
while (not eof STDIN) { | |
read STDIN, $sample, 2; | |
$sample = unpack "s", $sample; | |
$ms = 0; | |
if ($writing) { | |
if ($mnum >= scalar @msamples) { | |
$writing = 0; | |
} else { | |
$ms = $msamples[$mnum]; | |
$mnum ++; | |
} | |
} elsif ($snum++ % 44100 == 0) { | |
$writing = 1; | |
@msamples = (); | |
$mnum = 0; | |
$code = DateTime->now()->iso8601(); | |
`echo $code |minimodem --tx --mark 11000 --space 13000 --file - 1200 >stamp.wav`; | |
open(MODEM, "sox stamp.wav -r 44100 -e signed -c 1 -t .raw -|"); | |
while (not eof MODEM) { | |
read MODEM, $s, 2; | |
push(@msamples, unpack("s",$s)); | |
} | |
close MODEM; | |
} | |
print OUT pack("s", $sample + 0.1 * $ms); | |
} | |
close OUT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment