While you may not be aware of it, most modern *n?x systems come with a built-in industrial music generator. This generator consists of three parts:
  1. The concept of devices as files
  2. Standard input/output redirection to/from files (implemented with > and < in Bash)
  3. /dev/audio
That's about all you need. The output of just about anything, most notably cat, can be interpreted as raw sound data and sent to the speakers instead of the monitor. Most of the time this will just give you weird static. Try cat /dev/urandom > /dev/audio (outputs literally random sound). If you want something more meaningful, try simple patterns of values; the most simple value, and a good place to start, would be yes > /dev/audio, which outputs a high whining as the value 'y' is sent as audio over and over.

The trick is finding ways to get interesting patterns out of the speakers. One way to do this is to write simple programs:

int n=0, i=1;
for(;;) {
     cout << char(n+=i);
     if (n>255 || i<=0) {i++; n = n % 255;}
} 
However your best bet is to try to find something large with a repetitive structure but varying information-- large data files for example. And the two best examples of this, if you ask me, would be cat /dev/hda1 > /dev/audio (or your equivalent) or cat /proc/kcore > /dev/audio. Core is more.. well, hardcore, but catting your hard drive into /dev/audio is uncontestedly the best. You get weird, vaguely looping noise, shifting, completely unpredictable, infinitely varied but usually with a constant feel to it. Plus if there are any sound files on your drive saved in a lossless format they just play at random and then disappear back into the soup. Someday i'm going to tape 45 minutes worth of my linuxppc partition, then drive down to the local college radio station during the ambient show and ask them to play it. I doubt they'd be disappointed. > /dev/audio music can be surprisingly good, and the quality levels of hard drives tend to approach that of coil.

If this particularly interests you, you may download a sampling of crud i have created (mostly with this method) at http://charon.sjs.org/~mcc/awk


Re asofel and otaconx: Any block of text interpreted by /dev/audio tends to have a rather uniform sound, kind of a feathery leaves rustling in the wind noise. This is because ASCII text is actually printing out a rather limited range of values; after all, a character value lives in the range 0-255, but only 96 of these are on a QWERTY keyboard.
Catting /dev/null to /dev/audio produces silence, because you are simply printing a stream of zeros. Printing ANY single repeating character value to /dev/audio, in fact, produces silence, be it zero or 255. In order for noise to happen there must be at least some variation. I am not quite sure why. (This does not apply to my example of the yes program given above, because yes is actually printing a simple two-value pattern; 'y' followed by '\n' (a linebreak))

Nigh on ten years ago, in college when I used to sleep under the counters in the term room, we had some SPARCstations in there, SPARC 1's I believe. This was SunOS 4.something, not, um . . . they're calling it Solaris now, aren't they? Anyway, if you cat'd anything to /dev/audio other than an audio file, the OS would crash. I am not making this up. We tried it for the same reasons mcc tried it: "Gee, I wonder what that would sound like?" -- but we got very different results.

Where it got ugly (a.k.a. "fun") was that the permissions on the device files were wide open (I'm not a UNIX guru, but I seem to recall that this should not be the case), so that anybody could rshell into any SPARC there and cat random crap into /dev/audio, thereby killing the poor thing. Furthermore, /dev/tty* was permissioned writeable for everybody too: You could cat bogus error messages to the user's shell tools before crashing the computer ("system going down for black mass, please log off. Hail Satan!"1) -- or ascii art featuring the grinning face of J. R. "Bob" Dobbs. So if all the SPARCs were taken, you could always sit down at a dumb terminal, zero in on some poor dumb physics major wasting a valuable SPARC on useless crap like learning, and fuck with him enough that he'd give up and you could grab the SPARC.

Uh, kids? Don't do stuff like that. It's bad. Really. :)


1 Did I mention that the sysadmin was a very sincere evangelical Christian? And that we were young, stupid, and sleep-deprived enough to think that the Satan nonsense was clever . . . and that smacking people in religious soft spots was clever . . .

One way to 'play' your machine as an instrument is to cat /dev/mouse > /dev/dsp (or /dev/audio, whichever) and then twitch your mouse around and click buttons. Some of the results are really kinda interesting!

I was laying on my deck, listening to the river when this thought occured to me. Has anyone ever catted the entire E2 database to /dev/audio? Would the people running the server be willing to try this? perhaps generate an mp3 or some such thing so that everyone could hear the sound of everything?

Regarding mcc's wondering as to why no sound is produced when there is no variation:

It's really pretty simple. /dev/audio doesn't interperet each byte as a frequency or wavelength or any other representation of a tone. Instead, it interprets the data more like an amplitude. As you may remember from physics, sound is produced by vibration (usually, vibrating air). This means that sound is a wave. The energy in a wave is determined, primarily, by the difference in amplitude (the "height" of the wave, when graphed) between the peak and the valley. If you send a stream of the same byte constantly, you get no sound since there is no energy in the wave.

It'll take a little experimenting to figure out exactly how /dev/audio translates the bytes to amplitudes, but that's the general idea. (I think I just figured out what I'm going to waste MY weekend on...)

mcc's mention of catting your hard drive to /dev/audio has made me notice a peculiar thing; different filesystems sound noticeably different. Specifically:

  • ext2 sounds like a deep, mostly monotonous buzzing
  • reiserfs sounds like static (or modem noises) overlaid with a startlingly regular repeating tone
  • FAT32 sounds like a high-frequency triangle wave (much more jarring than ext2 or reiserfs)
  • NTFS sounds almost like machine-gun fire, or a badly skipping audio CD
  • BeFS sounds like radio static with arhythmic beeps.
Don't we all love Unix :-)

This of course is just a general sound, omitting the opening part of the partition where any filesystem sounds somewhat like /dev/urandom. There are also interruptions and transients following the (considered random) pattern of data in the partition.

These measurements were made under Linux 2.4, with the ALSA sound drivers version 0.9.0beta6, and a SoundBlaster Live! sound card.

The different filesystems sounding different phenomenon would probably be due to different cluster sizes. A freshly formatted hard drive will be full of all the same value. Any file written to it will only fill up the start of the cluster, leaving the end the same - thus making no sound.

Data     :ADRGESHTFDZDRSRGSEWERT00000000000000000000
Waveform :/\/\/\\\\///\/\/\/\/\_____________________
Lots of files together will make a more regular wave:
Data     :FF00F000FF00FFF0FF00FFF0F000FF00
Waveform :MM__M___MM__MWM_MM__MWM_M___MM__
If the cluster size is smaller, the clusters will be closer together, and the frequency of the envelope higher. So NTFS would sound higher than a normal fat32, which would sound higher than fat16. (I suspect my 300 meg, ridiculously small (256 byte, IIRC) cluster fat32 partition would screech!)

The blank space at the end of the cluster would only get overwritten if the file were deleted (or moved by a defragger), and a file larger than one cluster were written to it. It's not inconcievable that this slack space could stay blank for many years. Older filesystems might sound different... unless said defraggger overwrites the free space.

(conjecture: If the drive is formatted with a regular pattern instead of just the same byte over and over, it would beep instead of being silent... I don't know enough about unix filesystems to know for sure.)

Log in or register to write something here or to contact authors.