The Sounds of Little C

A group of sonic and code explorers has been discovering excellent super-short C programs that, piped to an 8-bit audio device, generate music. Here’s the first video and a second video with sounds and code.

Here’s the code for one example, “Lost in Space,” from video #2:


main(t){
for(t=0;;t++)putchar(
((t*(t>>8|t>>9)&46&t>>8))^(t&t>>13|t<<6)
);}

If you are also a righteous Ubuntu user, you can paste that into a file (let’s call it “lost_in_space.c”) and compile it with:

% gcc lost_in_space.c -o lost_in_space

Then, pipe it (or pretend to pipe it, using padsp, since recent versions of Ubuntu don’t have /dev/dsp) to your audio device using:

% ./lost_in_space | padsp tee /dev/dsp > /dev/null

Thanks to Andrew Stern for tipping me off about this one.