Skip to content

Instantly share code, notes, and snippets.

@tynes
Created December 8, 2016 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tynes/346b30601007391ad00ae50fdf3fd112 to your computer and use it in GitHub Desktop.
Save tynes/346b30601007391ad00ae50fdf3fd112 to your computer and use it in GitHub Desktop.
generate music from entropy on the command line
#!/bin/bash
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | xxd -r -p | aplay -c 2 -f S32_LE -r 16000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment