The Sound of Data

Spurred on by a recent weekend full of hot-tub induced dehydration, beer, and lack of sleep, some friends of mine discovered an interesting (I think, I at least) capability of the command line computer interface. Prepare to be really geeked-out.

As I wrote briefly about last year, on the Linux command line, you can pass the output of one program into another by joining them together with | (the “pipe” character). For example, if you entered whois actsofvolition.com | gedit, it would take the output of the whois lookup for that domain name and open it in gedit, a text editor.

White Noise

It occurred to one of us, in our sleep-deprived state, that you might be able to pipe the output of the random number generator into an audio player, and hear random noise. So, we tried this:

cat /dev/urandom | aplay

Let me explain: cat is a program to output the contents of a file. The /dev/urandom is a random number generator for linux. aplay is a simple sound player. So here, we are taking random data and asking an audio player to play it. It worked! It sounds like white noise. Here’s a short MP3 sample: random.mp3 (run out my headphone jack and and back into my line-in, since I could figure out how to record the audio directly to disk.

Hearing Your Hard-Drive

So, the next logical step (again, very little sleep) was to try sending in some non-random data. So we tried:

ls -R / | aplay

The ls command displays the contents of the current director. The extra options tell it to start at the root of your hard-drive (/) and go recursively into all sub-folders (-R). It basically lists out the file and folder names on your entire hard drive.

This sounded more like the bleeps and squawks of a modem making a dial-up connection (remember picking up another phone when someone was dialed-up to the internet?). Here’s an MP3 sample: filesanddirs.mp3.

The Digital Anthem

American Flag

Finally, we wanted to hear what some more structured data sounded like. Images and photos in compressed file formats like PNG and JPEG sound pretty much like random noise, due to the compression. However, un-compressed image files, like BMP (bitmap) files are very simple and structured.

So, I grabbed simple bitmap image of the American flag (usa.bmp) and the results are pretty cool. It sounds like digital hardcore.

cat usa.bmp | aplay

Here’s the MP3 of the American flag bitmap file: usa.mp3.

 

51 thoughts on “The Sound of Data

  1. How many beers did you have before you did this? You have really taken the geekery up a notch! Having said that, I still think its pretty cool, in a “Close Encounters of the Third Kind” sort of way.

  2. cat /dev/urandom | sox -s -b -t raw -r 44100 – out.ogg

    Sox is a thing which does for sound what ImageMagick’s convert does for images. Since you’re feeding in data whch doesn’t have any formatting at all, you have to lie to sox and tell it a format that the data is in: that’s what all the options do. Sox also doesn’t do mp3 encoding, so this outputs an ogg, but I suppose you could sox something into a wav file and then chuck that through your choice of mp3 encoder if you wanted to.

    I am firmly of the opinion that you never ever ever need to use a wire to connect a bit of a computer to another bit of the same computer 🙂

    On the other hand, I knew about sox: this would have been considerably harder if I didn’t…

  3. sil, I was searching for something like sox. It does exactly what I was looking for. Thanks!

  4. Let’s listen to urandom for messages from [your favorite deity or none at all], or from Linus 😉

    The next step is to convert mouse movements into sound, and voila! … a new musical instrument.

  5. Actually, you can cat your mouse (heh) and pipe it to aplay. Just find your X11 conf file (I’m on Fedora Core 3, so it’s /etc/X11/xorg.conf) and find the device your mouse is attached to. Then issue “cat /dev/input/mice > /tmp/music.txt” where “/dev/input/mice” is your mouse device. You can then cat the resulting file and pipe it to aplay. It seems to be a pretty uniform high-pitched sound. You can probably just cat the mouse straight to aplay, but I don’t have speakers on the one system and can’t seem to find the mouse device on my touchpad laptop (or at least to cat it), so I catted the mouse on my desktop system and copied the file over to my laptop to listen (so I needed a file to copy).

  6. If you plug your (hi-fi) headphones directly into the back of your soundcard, and turn up the volume, you can hear a very faint version of the hard drive/processor sound.

    It was kind of fun listening to a 3D render.

    The flag sounds strangely good.

    Speaking of turning image data into sound: Winamp has its Nullsoft Tiny visualisation plugin, that outputs the equalizer to you screen, placing all frames vertically next to one another, creating a human understandable left-to-right image of sound.

    You can configure the plugin to create black where there is sound, and white where there is none, and the result is as if you’ve tried to draw out the music on paper with smudgy charcoal. I have a couple screenshots; I’ll uploade them one time.

  7. I did this a few years ago in a similar state of mind. I listened to ColdFusion Studio (compiled delphi), Eclipse IDE (java), and some other ones. They sound quite different based on the underlying language.

  8. Or if you’ve got a Mac and want to hear some poetry:

    uuencode /bin/ls /bin/ls | say

    Or for some annoying singing:

    uuencode /bin/ls /bin/ls | tr [-az-AZ-] a | say

    I kind of like the rhythm of:

    uuencode /usr/bin/say /usr/bin/say | tr [-az-AZ-] k | say

    Or the 50’s stylings of:

    uuencode -m /bin/ls /bin/ls | head -11 | tail -10 | sed ‘s/AAA/ doowaa /g’ | sed ‘s/A/ boop boop /g’ | say

    Rock on.

  9. Seth: on Windows I had renamed the file to .Wav and fed the file thru an encoder – blade i believe – and that outputs mp3.

  10. This rocks!
    Think of the things you could do with this! It’s like MIDI, but higher pitched and not as good!

    Wheres mspaint? I’ve got composing to do!

    By the way, I don’t seem to have aplay in debian sarge. Is there an equivalent?

  11. On many Linux boxes (including my Fedora 3 laptop) you can simply do a ‘cat [soundfile] > /dev/audio’. This works for ‘cat /dev/urandom > /dev/audio’. The beauty part is that you can do this remotely. I used to ssh into a box at work, turn the mixer volume all the way up, and ‘cat [loud sound] > /dev/audio’. If the person at the console has their speakers on, this command causes said person to soil themselves.

  12. Reminds me alot of backing up data on a Nomad Jukebox 4(5?) years ago… you had to rename your files to .mp3, so that the nomad program would copy them (this is before Creative or a third party released software that got around that)…

    So, you’re data files appeared as MP3s.

    And, you could play them. And, they really really hurt my ears.

  13. Most of the songs on my first album make heavy use of instrument samples which were non-sample files. In “Return of the Files,” all of the samples are non-sample files. The drum loop is command.com from MS-DOS 6.22.

    Doesn’t have to be amusical noise.

  14. This is an old trick for hard core UNIX users. In our little group, we used to use a similar technique to detect strange network behavior by filtering network activity through a speaker. The security guy was insane – he eventually heard noises in his own home, like the fridge winding down, and mistook them for security violations.

  15. Can you make a way that the mouse can work like a waa-waa pedel or a phase shifter over-top of the noise?

  16. I think you must try fractal images to do that. Bach Music could be represented as a Fractal, and I guess the tipical fractal pic would sound nice 🙂

    Do it and take into MOMA 🙂

  17. I used to feed /proc/kcore to my dsp device for some interesting sounds.

    cat /proc/kore > /dev/dsp

    The sound of the kernel

  18. This is pretty cool! How abt doing it the other way.. taking an mp3 and converting it to BMP. We could distributes images encoded w/ music?

  19. I used to do this all the time when I first started playing around with audio software in windows 3.11

    I had a couple (rather large) word documents that had some great sounds in them.

    Cool Edit (now Audition) is the most fun for playing around with the sounds you find in data.

  20. As far as opening any file as a raw sound file and then editing it, Soundforge does this inherently. File -> Open -> Any filetype. MS Word2K executable hides bleep bloops and drum lines.

  21. Steve, funny experiment! Audacity let’s you play non-audio data as well, but I guess something like the file list wouldn’t work.

    I remember reading about something similar, but different: using a matrix printer to play music. Instead of a picture producing music, you would have music producing a picture. I betcha there is a whole scene out there doing this. Now all you need to do is salvage that old matricprinter (and probably a computer with a paraller port) from the garage/dump 🙂

    Olivier (Brussels)

  22. Nice, but certainly not new—as an MSc student, living in Edinburgh, I found I would often sleep through my alarm. To address this, I would set a cron job to cat my kernel to my sound device at the time I wished to be awakened: cat /vmlinuz > /dev/dsp. Oh, sure, it’s not the most pleasant thing to hear first thing in the morning, but it did work pretty well.

  23. hmm cat is designed to do this – UNIX users have been using this to monitor network traffic and scare friends for years.

    try mounting a windows partition and catting *.DLL (and other gigantic win32 binaries) to /dev/dsp 😉 i think there’s a CD of this somewhere, perhaps tigerbeat6 on mdos.at..

    btw /dev/kmem sounds much better than /dev/urandom 😉

  24. I had an experience a few years ago that relates to this. The headphone jack on my machine was pretty much dead, but if I wedged the plug about halfway in, I could get one channel of audio in my headphone (L or R). When using this setup, however, I also picked up lots of soft buzzes, pops, and squeaks, which I soon realized was an audio representation of what was going on onscreen. E.G. When I dragged a menu bar, I would hear a particular buzz, and the pitch would raise or lower depending on the speed I dragged.

  25. Hehe, we had a lot of fun with this back in the 90’s on my dorm 🙂 We had our server in a dark cellar and scared the hell out of a freshman who we had told to go down and configure lpr for us 😉 2 hidden speakers playing a core dump at maximum volume almost made him crap his pants 😉

  26. Couple of interesting things!

    For Unix/Linux/*ux and Win32 users, there’s a cute little toy called Flite which can replace ‘say’ in the pipelines above (even under Windows, if you’re using Cygwin). It’s a cut-down version of the Festival speech-synthesis package; instead of being probably as complicated as Apache — more so in fact as more people use Apache — to install and configure properly, it lives in a single executable. You only get one voice which sounds somewhat like a drunken Norseman, but go figure.

    I was playing around with this and I did:

    $ perl -e ‘@w = split / /, “Now is the time for all good men to come to the aid of their country.”; print “$_n”x1000 foreach @w;’ > /dev/dsp

    which gave a very interesting series of fairly clear tones, kinda chiptuney and very nifty.

    Another neat trick is to put an & on the end of that and start it multiple times at different intervals; you get some interesting harmonics and distortion effects, kind of thing, and yeah.

  27. This is pretty neat! Has anyone found anything about converting an audio file into an image though? I have tried some searches, but I just keep turning up normal image conversion software. I would be very interested in seeing what some of my music would look like as an image. 🙂 And, imagine if you could share your music just by pasting a link to a .jpg on your website? Someone gets the file and can play it back in Adobe Audition (used to be Cool Edit) or whatever the equivalent on OS X.

    Undrhil

  28. I have a related problem to what you have here. I’m
    interested in playing a time series, like what audacity displays when you load a wav file. The difference is that my input data file has two columns
    the first one for the time and the second for the amplitude of the sound. What I want to do is play the
    sound chaos for ex. The second column for me is some
    variable I obtain from a map or the solution of a system of differential equations. The data could be
    just one column as well (just the amplitudes).

    Thanks,
    Adriano.

  29. I mean, I know you can play datafiles from fx cool edit – but how to perform something like this where all data plays randomly in windows?

Comments are closed.