ref: 1dce09166370ecf9cc3764fb19c91c651578529e
dir: /bin/frequenzbohrer/
#!/bin/awk -f # ; mkdir $home/mid # ; for(i in $notestringsbelow) echo 2 0^$i | mst | games/midi -c > $home/mid/^$i^.pcm function extant(v, a){ for(e in a) if(a[e] == v) return 1 return 0 } function addrange(n){ i = length(roster) + 1 for(o in range){ m = n + range[o] if(m > 0 && m <= length(note) && !extant(m, roster)) roster[i++] = m } } function new(){ print "Find die noten, allied schweinhund!" for(i in qs){ do n = int(rand() * 10000000 % length(roster) + 1) while(extant(roster[n], qs)) qs[i] = roster[n] } for(i in keys) qs[int(rand() * 10000000 % length(qs) + 1)] = keys[i] cmd = "cat $home/mid/^(" for(i=1; i<=length(qs); i++) cmd = cmd note[qs[i]] ".pcm " cmd = cmd ") >/dev/audio" system(cmd) } BEGIN{ split("\ c0 c♯0 d0 d♯0 e0 f0 f♯0 g0 g♯0 a0 a♯0 b0 \ c1 c♯1 d1 d♯1 e1 f1 f♯1 g1 g♯1 a1 a♯1 b1 \ c2 c♯2 d2 d♯2 e2 f2 f♯2 g2 g♯2 a2 a♯2 b2 \ c3 c♯3 d3 d♯3 e3 f3 f♯3 g3 g♯3 a3 a♯3 b3 \ c4 c♯4 d4 d♯4 e4 f4 f♯4 g4 g♯4 a4 a♯4 b4 \ c5 c♯5 d5 d♯5 e5 f5 f♯5 g5 g♯5 a5 a♯5 b5 \ c6 c♯6 d6 d♯6 e6 f6 f♯6 g6 g♯6 a6 a♯6 b6 \ c7 c♯7 d7 d♯7 e7 f7 f♯7 g7 g♯7 a7 a♯7 b7 \ c8 c♯8 d8 d♯8 e8 f8 f♯8 g8 g♯8 a8 a♯8 b8 \ c9 c♯9 d9 d♯9 e9 f9 f♯9 g9 g♯9 a9 a♯9 b9 \ c10 c♯10 d10 d♯10 e10 f10 f♯10 g10", note) # FIXME: just have all notes from octaves -1,0,+1 split("-12 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 12 1 2 3 4 5 6 7 8 9 10 11", range) srand() print "Vich noten shall wir testen diese day, bastard?" } NR == 1{ n = split($0, keys) if(n < 1) exit("no notes to hand") for(k in keys){ m = 0 for(n in note){ if(keys[k] == note[n]){ m = n break } } if(m == 0){ print "unknown note " keys[k] exit("unknown note " keys[k]) } keys[k] = m addrange(m) } for(i=1; i<=6*length(keys); i++) qs[i] = 0 new() } NR > 1{ # FIXME: just choose one of the notes at random; only test one note; # say which one it's testing for(i=1; i<=NF; i++) if(!($i in qs) || !extant(qs[$i], keys)) print "NEIN! Es ist " note[qs[$i]] "!" new() }