Skip to content

Instantly share code, notes, and snippets.

Avatar

Oona Räisänen windytan

View GitHub Profile
View lsb-time-read.pl
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;
View ninja.pl
if (/^\.ninja (.+)/) {
$irivi = lc($1);
$irivi =~ tr/ÅÄÖ/åäö/;
$irivi =~ tr/åäöéèü/aaoeeu/;
$irivi =~ s/[^a-z\- ]//g;
$irivi =~ s/\s+$//;
$irivi =~ s/\s\s/ /g;
%ninjanames = qw( a KA b ZU c MI d TE e KU f LU g JI h RI i KI j ZU
k ME l TA m RIN n TO o MO p NO q KE r SHI s ARI
t CHI u DO v RU w MEI x NA y FU z ZI );
@windytan
windytan / whistle-encode.pl
Last active Sep 27, 2016
whistle encoder
View whistle-encode.pl
#!/usr/bin/perl
# windytan's pea whistle encoder
# http://www.windytan.com/2015/10/pea-whistle-steganography.html
# (c) 2015 Oona Räisänen
# ISC license
use warnings;
use strict;
my $data = $ARGV[0] // "OHAI!";
@windytan
windytan / bpm.pl
Last active Sep 14, 2016
Count newlines per minute. Press enter for beat. Useful for music, heart rate, etc.
View bpm.pl
#!/usr/bin/perl
#
# bpm.pl - count newlines per minute
#
# Oona Räisänen 2012
# Public domain
#
# Usage: ./bpm [-n SAMPLES] [-p DECIMALS] [-s]
#
# -n SECONDS: average over SECONDS seconds (default 5)
View deinvert-difficult.pl
$fs = 48000; # sample rate
$fc = 3729; # carrier frequency
$filter = " sinc -$fc"; # optional LP filter
$fc = freq($fc);
open(IN, "sox scrambled.wav -c 1 -b 16 -e signed -t .raw -|");
open(OUT,"|sox -r $fs -c 1 -b 16 -e signed -t .raw - descrambled.wav".
$filter);
View deinvert-easy.pl
open(IN, "sox scrambled.wav -r 8600 -c 1 -t .s16 -|");
open(OUT,"|sox -r 8600 -c 1 -t .s16 - descrambled.wav");
$n = 1;
while (not eof IN) {
read IN, $a, 2;
print OUT pack("s",unpack("s",$a) * $n);
$n *= -1;
}
View mod.pl
open(S,"sox salakalastaja.wav -t .raw -e signed -|");
open(U,"|sox -b 16 -c 1 -e signed -t .raw -r 44100 ".
"- ssb.wav sinc 6000 -n 4096");
while(not eof(S)) {
read(S,$a,2);
print U pack("s",unpack("s",$a) *
cos(($n++ * 2 * 3.141592653589793 * 6000) / 44100);
}
View sigint-to-csv.pl
while(not eof(STDIN)) {
read(STDIN,$a,2);
$a = unpack("s",$a);
print $a."\n";
}
View fsk.pl
use constant BPS => 300;
use constant SRATE => 44100;
$dur = 0;
for (qx!cat olddata.asc!) {
chomp($a = $_);
if ($a * $preva < 0) {
$nbits = int($dur / (SRATE/BPS) + .5);
print ((($preva < 0) ? 1 : 0) x $nbits);
$dur = 0;
View delta.pl
$prevbit = 0;
$n=0;
for (qx!cat ddtaa.asc!) {
chomp($a = $_);
if ($n >= 2300) {
if (($n - 2300) % 80 == 0) {
$bit = ($a > 0) ? 1 : 0;
print (($bit != $prevbit) ? "1" : "0");
$prevbit = $bit;
}