Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.