Skip to content

Instantly share code, notes, and snippets.

@windytan windytan/lsb-time-read.pl
Last active Feb 12, 2017

Embed
What would you like to do?
use warnings;
my $snum = 0;
my $reading = 0;
open my $in, '-|', 'sox stamped.wav -e unsigned-integer -t .raw -';
while (read $in, $sample, 2) {
$bit = (unpack "S", $sample) & 1;
if (!$reading && $bit) {
$byte = 0x00;
$pos = 0;
$reading = 1;
$starts = $snum;
$stamp = "";
} elsif ($reading) {
$byte |= ($bit << $pos);
if (++$pos >= 8) {
if ($byte == 0x00) {
$reading = 0;
print "$starts: $stamp\n";
} else {
$stamp .= chr $byte;
}
$byte = 0x00;
$pos = 0;
}
}
$snum++;
}
close $in;
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.