{{ message }}

Instantly share code, notes, and snippets.

# Oona Räisänen windytan

Last active Oct 11, 2015
Perl script to read an image of digits
View bitit.pl
 #!/usr/bin/perl use feature "switch"; open(S,"convert bitit.png gray:-|"); for \$y (0..434) { for \$x (0..699) { read(S,\$a,1); \$b[int(\$x / 27)][int(\$y / 27)] ++ if (ord(\$a) < 127); } }
Created Oct 13, 2012
Evoluution simulointia sanoilla
View muta.pl
 use utf8; use warnings; @kirjaimet = ( "a" .. "z", "å", "ä", "ö" ); \$alkutilanne = "aaaaaaaaaaaaaaa"; \$valintapaine = "kehitysoppi"; # Elinkelpoisuutta simuloidaan ns. Levenšteinin etäisyydellä, joka sopii esimerkkiimme use Text::Levenshtein qw(fastdistance);
Created Feb 10, 2013
View sigint-to-csv.pl
 while(not eof(STDIN)) { read(STDIN,\$a,2); \$a = unpack("s",\$a); print \$a."\n"; }
Created Feb 10, 2013
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;
Created Feb 10, 2013
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; }
Created Feb 23, 2013
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); }
Last active Aug 26, 2019
View fm.c
 #include #include #include #include #define FFTLEN 2048 #define SRATE 22050 // Return sinusoid power from complex DFT coefficients double power (fftw_complex coeff) {
Created Mar 26, 2013
View deco.pl
 \$|++; use warnings; use Text::LevenshteinXS qw(distance); for (qx!cat nappis.txt!) { \$merkki{\$2} = \$1 if (/^(.+) ([01]+)/); } while (<>) { chomp();
Last active Jul 15, 2021
View oscillo.pl
 use warnings; use Getopt::Std; getopt('xytGgwsf',\%opts); # pcm file = \$opts{f} # samples per pixel x \$xscale = \$opts{x} // 1200;
Last active Dec 17, 2015
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; }