ITMFA
gonzo blogging, commentary, opinion, and more from Tom Swiss
about unreasonable.org | contact Tom | recent updates | register | RSS feed | send a story
Active forum topics
Recent comments
"white noise" generator with sox for Linux
By tms at 17 January 2007 - 5:39pm | Categories: |

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I like it!

By Drew Haven (not verified) on 5 December 2007 - 7:22pm

This beats the heck out of "cat /dev/urandom > /dev/dsp". The band filter is nice to take out the pops.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <b> <i><hr><blockquote><img>
  • Lines and paragraphs break automatically.
More information about formatting options