Live data from Hacker News

'Music' from /dev/urandom

blog.robertelder.org

51–58 of 58 posts

Re: 'Music' from /dev/urandom

#51
post #6

Is there a way to make it sounds more pleasant? The sine wave is a bit harsh...

The example from /r/coding[1] is very nice to listen to: 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 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); wh…

That's quite a delight for the ears. Reminds me of Stéphane Picq's work on the Dune computer game soundtrack, back in the early 90s. It had some similar sounds.

Re: 'Music' from /dev/urandom

#54
I don't know if I'm the only one who have noticed that, but on 64 bit machines you have to change "%08X\n" to "%016X\n". Although using %08X sounds interesting, the result is not a major scale and probably not the original intent of the code.

Re: 'Music' from /dev/urandom

#55
post #23

> I only expected this to work on Ubuntu And yet here's the command: cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i There's nothing Ubuntu-specific there: it works fine on other Linuxes. It's gotten more than a little annoying, this widespread equivalence between Ubuntu and Linux. Ubuntu is a Linux distro, albeit hardly the best, most idiomatic or most traditiona…

Part of this exercise was to leverage highly portable and backward compatible utilities as much as possible, so I expect stuff like cat and awk to work mostly the same everywhere. 'aplay' is the one I was not sure about. If I recall correctly, it was even necessary to explicitly 'sudo apt-get install' on older versions of Ubuntu.

aplay is part of ALSA, which is old enough that I wouldn't expect any differences between it on Ubuntu & on other Linuxes.

FWIW, I really dig the demo: it's cool.

Re: 'Music' from /dev/urandom

#57

I hope everyone is turning off CSS before copy-pasting this command-line into their terminal :) http://thejh.net/misc/website-terminal-copy-paste

Always paste to the browser url bar and then copy again. This clears any extra tags you might carry over and will display anything that might be hidden. You could copy and paste to notepad, but the browser bar is closer.

Great point, however the browser bar is only a single line. I guess this is where a global shortcut to start a text editor would be useful.

Re: 'Music' from /dev/urandom

#58
post #33

Handy smoke test for a good RNG? Not sure I see any case where it would actually be useful for this in practice, but I find the idea amusing in theory.

You may be able to hear or see that a very bad RNG is bad (there are certainly sufficiently bad ones for which you can), but you can not hear or see that one is good.

My thoughts exactly. You certainly wouldn't want to rely on this to identify a good RNG, but you might be able to catch a bad one.
Post reply on HN