Skip to content

Instantly share code, notes, and snippets.

@socantre
Created March 12, 2016 21:42
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 socantre/c6f0cca7555b3b173e40 to your computer and use it in GitHub Desktop.
Save socantre/c6f0cca7555b3b173e40 to your computer and use it in GitHub Desktop.
random note generator
# based on http://blog.robertelder.org/bash-one-liner-compose-music/
# with overflow, channels, timing, etc. bugs fixed
< /dev/urandom hexdump -v -e '/1 "%u\n"' |
gawk 'BEGIN { split("0,2,4,5,7,9,11,12",a,",")}
{ for (i = 0; i < 0.3125; i += 0.0000625)
printf("%02X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' |
sed -e 's/.*\(..\)$/\1/g' |
xxd -r -p |
sox -traw -c 1 -r16000 -b8 -e signed-integer - -tcoreaudio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment