June 22, 2006

Bring in the (pink) noise

Author: Nathan Willis

Sometimes we need a little help to drown out the noise that surrounds us. But why settle for archaic bothers like setting up birdhouses by the study window or walking out to the woods, or high-dollar noise generation machines? Free software can generate noise to drown out your distractions, from the comfort of your own workstation.

I know, noise generation is not for everyone. Some people can work happily away for hour upon hour with the radio on, co-workers chatting, shop noise, and so on. But for some of us, auditory distractions can cripple productivity. As an undergraduate in college, I worked as editorial cartoonist for the school paper, and I often found that the best way for me to tune out the world and get work done was to move to the campus center -- where the background noise was a quiet, but near-constant murmur of indistinct conversations.

The hum of noise is seemingly easier for the brain to tune out than clear, direct sound, and yet less distracting than absolute silence as well. A few years ago, I discovered the little Mac OS X freeware application Noise, from Blackhole Media. Noise generates, well, noise. White noise and pink noise, to be exact, and that's all. Just turn it on, and tune out the traffic, dogs, neighbors, kids, or whatever your distraction du jour is. How simple.

White noise, of course, is just the colloquial term for a random signal, like static. Scientifically, white noise is just a signal that has equal power in every band, statistically averaged. So it is the equal blending of all the bands in the spectrum, like "white light" contains a mix of all the colors of visible light.

Pink noise is different, and though it is harder to put into layman's terms (it has equal energy in all octaves, power proportional to the reciprocal frequency, or so on), it's easier on the human ear. Most people prefer to drown out the undesirable sounds of daily life to the tune of pink, rather than white, noise.

For an explanation of each "color" of noise, consult the Wikipedia article on colors of noise.

The simple Linux alternative: whitenoise

I started thinking about a Linux equivalent of Noise. Much of the OS X environment is similar to GNUstep thanks to their shared ancestry in NeXTSTEP. The Noise source code is BSD-licensed, but it is coded pretty directly to Apple's Cocoa and CoreAudio, so porting it -- while possible -- would not be much faster than making a native alternative from scratch.

In theory, you could download a public-domain or Creative Commons licensed sample of pink noise, and play it in a continuous loop with an audio player, but that's a bit kludgey. For one thing, you have to run a full-featured audio player, and then you either have deal with a pop every time the end of the track comes up, or find an app that supports either true gap-less playback or cross-fading good enough to fool the ear -- which is very difficult to do on an audio track of continuous tone.

The closest parallel to Noise available for Linux is Paul Pelzl's small console app whitenoise. Although whitenoise can only generate white (i.e., not pink) noise, it has a number of runtime options that let you tweak the output. You can specify a low-pass frequency cutoff with the -c flag, which can help clip out the higher-pitched frequencies and improve the "pinkness" of the resulting signal. You can also switch between five different audio filters and adjust the filter length on each. Trial and error is the best bet.

You can also pass a time option to the program with the -t N option, where N is the number of minutes to run, and you can tell whitenoise to fade out the signal at the end of the specified time with the -f option.

While you are searching for the settings that best fit your needs, you can run whitenoise interactively by passing the -s option. You might also want to have a look at the comments on freshmeat's whitenoise page to see what others find useful. Whitenoise also has an experimental GNOME front-end -- available at the same site -- but it doesn't add much in the way of user-friendliness.

More power! Boodler to the rescue

To really take control of your sonic landscape, though, the only choice is Boodler. Boodler is a full-featured "soundscape tool" written by Andrew Plotkin. With it, you can use Python to define sonic formulas created out of pure tones, samples, effects, and other "soundscapes" -- and Boodler will create sounds on the fly, in the background, without repeating, for as long as you leave it running.

It only takes a couple of minutes to compile and install Boodler. The basic package consists of the Boodler application, scripts and support files in one directory, and a sound library in a separate directory. After following the installation instructions, you need to set two environment variables, BOODLER_SOUND_PATH and BOODLER_EFFECTS_PATH to tell the app where your installed the sound library and effects modules, respectively.

For example, if you have the sound library stored at /home/username/lib/boodler-snd and the sound effect modules stored at /home/username/src/boodler/effects, you'd want to run the following:

export BOODLER_SOUND_PATH=/home/username/lib/boodler-snd
export BOODLER_EFFECTS_PATH=/home/username/src/boodler/effects

Basic usage is simple; you call Boodler from the command line, and tell it which soundscape to play by passing an argument of the form ClassName.AgentName. The ClassName can be any of the modules installed in BOODLER_EFFECTS_PATH, and the AgentName is any of the soundscapes defined by that module. So, for example, to play the CricketMeadow soundscape from the cricket module that ships with the base installation, you would run python boodler.py cricket.CricketMeadow. You can learn more about Boodler's options (including running multiple soundscapes and using advanced agents) at the Using It page.

The noise soundscape pack, which is a separate download from the sound library, contains soundscape formulas for white, pink, brown, blue, and violet noise. Download the pack and copy the files into your sound library, and copy the file noise.py into the effects directory. Then, generating that soothing pink noise is as simple as calling python boodler.py noise.Pink.

Let's stop and listen to that for a few seconds.

Okay, good. For fuzzing out the cacophony, that is good enough, but of course Boodler can do so much more. Boodler's base soundscape packs contain a wide gamut of ambient sounds, ranging from natural to man-made. Everything from road hum to chirping crickets, from dripping water to construction site noise, is included.

There are utilities included to combine and manage soundscapes, and a detailed tutorial on how to compose your own from the elements included with Boodler. I haven't yet found a soundscape that accurately simulates the dull hum of a crowd of chattering people a la the old college student center din -- but I'm working on it.

Click Here!