Generating Random Chiptunes on Linux
I like to listen to music while I work. I find - especially in an open plan office - that it is an essential aid to concentration.
That said, I find music with lyrics particularly problematic as my brain prefers to concentrate on the words rather than the task in hand.
On long flights, I often use a white noise generator to drown out sound.
I've recently started listening to random music. A simple command line script to generate a highly synthetic / chiptune / glitchnoise neverending piece of music.
This code is shamelessly ripped off from Robert Elder's blog post and the subsequent HackerNews discussion
cat /dev/urandom | \ hexdump -v -e '/1 "%u\n"' | \ awk '{ split("0,3,5,6,7,10,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 24000
Copy & paste that into your Ubuntu terminal and it should sound something like this:
I don't know enough music theory or maths to determine what will sound pleasant and what won't. But a little bit of fiddling got me this jaunty little number:
cat /dev/urandom | \ hexdump -v -e '/1 "%u\n"' | \ awk '{ split("0,1,2,4,8",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 30000
It's not quite up to the standards of Daft Punk - but it covers up the noise of the office and allows me to concentrate without (audible) distraction.