Skip to content

Instantly share code, notes, and snippets.

@windytan
Last active August 29, 2015 14:02
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/a6ee763128cebeaf0d6b to your computer and use it in GitHub Desktop.
Save windytan/a6ee763128cebeaf0d6b to your computer and use it in GitHub Desktop.
use warnings;
use DateTime;
$snum = 0;
$writing = 0;
open OUT, "|sox -t .raw -e unsigned-integer -b 16 -r 44100 ".
"-c 1 - stamped.wav";
while (not eof STDIN) {
read STDIN, $sample, 2;
$sample = unpack "s", $sample;
if ($writing) {
$bit = (ord(substr($code, $pos >> 3, 1)) >> ($pos % 8)) & 1;
if (++$pos >= length($code) << 3) {
$writing = 0;
$bit = 0;
}
} elsif ($snum++ % 44100 == 0) {
$writing = 1;
$pos = 0;
$bit = 1;
$code = DateTime->now()->iso8601();
}
print OUT pack("S", ($sample + 0x7FFF) & 0xFFFE | $bit);
}
close OUT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment