Raspberry Pi White Noise Generator

It’s helpful to have a white (or brown) noise machine outside our director’s office, since his office is next to the lunch room and it helps to make his conversations more private.  But all of the machines that I saw on the market are sleep-oriented, and expect that you want them to turn off after a certain amount of time.

We started with a laptop, powered speakers, and the SimplyNoise.com web site (we like the “Brown Noise” sound there).  We could use the mute button on the laptop or the power button on the speakers to turn the sound on and off.  But that’s a waste of a laptop if the machine is good for anything else, and problem-prone if the laptop isn’t good for anything else.

So I decided that this would be a good first project for the Raspberry Pi. I found that mplayer will loop an audio file forever if you use the “-loop 0” switch. It does go silent for a split second when it’s looping, so you’ll want an audio file at least 15 or 20 minutes long to minimize the number of times it sounds like it’s stuttering.

There are plenty of tutorials out there about getting started with the Pi.  After that, it’s as simple as:

  1. Load up an mp3 or wav file with 15 or 20 minutes (or more) of noise.
  2. sudo apt-get install mplayer
  3. create /etc/init.d/whitenoise.sh (included below)
  4. add it to system startup with “sudo update-rc.d whitenoise.sh defaults”

This could also be used as a Music on Hold player for older phone systems.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          whitenoise
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: whitenoise
# Description:       plays whitenoise file.
### END INIT INFO
/usr/bin/mplayer -quiet -loop 0 /home/pi/whitenoise.mp3 < /dev/null &
exit 0

6 thoughts on “Raspberry Pi White Noise Generator

  1. Brennan Jones

    Thanks for the info! I would suggest editing whitenoise.sh to contain the following:
    /usr/bin/mplayer -quiet -loop 0 /home/pi/whitenoise.mp3 < /dev/null &

    This allows mplayer to run in the background. The command you have prevents to raspberry pi from fully booting.

  2. karl.kranich Post author

    Thank you! I think I had that in my original code, and left it out accidentally. I have had problems with the Pi being unresponsive lately!

Leave a Reply

Your email address will not be published. Required fields are marked *