I am a light sleeper. So a while back I was thinking about getting a "white noise" generator for my bedroom.

Then I remembered that my computer sits right across from my bed. Certainly there must be a software option...

Sox is "the swiss army knife of sound processing programs". It comes standard on most GNU/Linux distributions and is available for other platforms.

It includes sound generation capabilties, for pure tones and for white noise. More agreeable for my purpose, though, is "pink noise", which is also in sox's bag of tricks.

After a bit of experimentation, I found the following shell script produced agreeable results:

pinknoise:

#!/bin/sh len='7:00:00' if [ "$1" != '' ]; then len=$1 fi sox -t sl - -t sl - synth $len pinknoise < /dev/zero |\ sox -t sl - -t ossdsp /dev/dsp band -n 1200 200 vibro 20 .1

The script takes an optional argument providing the length of time to run and produce sound (hh:mm:ss format); it defaults to seven hours, where its output will mask minor noises to allow a decent night's sleep. The first sox invocation generates the noise, while the second applies a filter and a light vibrato effect that I find a little more pleasant than the raw noise.

You may have to change the "-t ossdsp" and/or the "/dev/dsp" depending on your audio setup. man sox to discover other options. Share and enjoy.

The latest sox renamed the "vibro" effect to "tremolo", breaking my script when I updated. That was annoying. I've also reworked the thing so the pipe is no longer needed. Here's the revised, updated version:

#!/bin/sh len='7:00:00' if [ "$1" != '' ]; then len=$1 fi play -t sl - synth $len pinknoise \ band -n 1200 200 tremolo 20 .1 < /dev/zero

Thanks all for your interest.