Scripts: new musawk script

master
Pierre Neidhardt 2014-01-17 12:17:16 +01:00
parent 0a90b09a0f
commit 3834e89c76
1 changed files with 31 additions and 0 deletions

31
.scripts/musawk Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# From http://kmkeen.com/awk-music/
rate=64000
awk -v rate="$rate" 'function wl() {
return (rate/160)*(0.87055^(int(rand()*10)))};
BEGIN {
srand();
wla=wl();
while(1) {
wlb=wla;
wla=wl();
if (wla==wlb)
{wla*=2;};
d=(rand()*10+5)*rate/4;
a=b=0; c=128;
ca=40/wla; cb=20/wlb;
de=rate/10; di=0;
for (i=0;i<d;i++) {
a++; b++; di++; c+=ca+cb;
if (a>wla)
{a=0; ca*=-1};
if (b>wlb)
{b=0; cb*=-1};
if (di>de)
{di=0; ca*=0.9; cb*=0.9};
printf("%c",c)};
c=int(c);
while(c!=128) {
c<128?c++:c--;
printf("%c",c)};};}' | aplay -r $rate