Skip to content

Instantly share code, notes, and snippets.

@sloanlance
Forked from yyolk/awk-music.sh
Created September 11, 2022 02:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sloanlance/f6e848d7021590871a560d72e66bd630 to your computer and use it in GitHub Desktop.
Save sloanlance/f6e848d7021590871a560d72e66bd630 to your computer and use it in GitHub Desktop.
#!/bin/sh
awk 'function wl() {
rate=64000;
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)};};}' | ./sox -t raw -r 64k -c 1 -e unsigned -b 8 - -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment