Skip to content

Instantly share code, notes, and snippets.

@windytan
Last active Aug 29, 2015
Embed
What would you like to do?
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