This is a platform for User Generated Content. G/O Media assumes no liability for content posted by Kinja users to this platform.

How to make a stand-alone white/brown/grey/pink noise generator

Hey Oppo, since a lot of us are cohabitating these days, I thought I’d share with you my favorite “life hack” of the last couple years: A white noise system. It helps keep distractions down and drown out your dogs/kids/refrigerator/zombies scratching at the door.


Disclaimer: It has been over a year since I’ve made one of these, so some of the steps are a little fuzzy. If one of you does this let me know where the snags are and I’ll update the post as we go!

Now, white noise is actually a defined term meaning, approximately, “a random signal having equal intensity at different frequencies, giving it a constant power spectral density.” So we’re not building that.


Actually what we are building is arbitrary sound playing device, that we then load our favorite white noise sound byte into. Basically my setup is a Raspberry Pi, a set of speakers, and... that is it.

Basically this will consist of:

  1. Sound playing device (In this example a Raspberry Pi)
  2. Speakers
  3. Sound file(s) of your choosing
  4. Python script
  5. USB Sound Card (Optional)

My system is cobbled together from a couple of guides, but here is the jist:

Step 1: Set-up your device

I’m using a Raspberry Pi, but this guide could be used for any Linux based device. I’m not covering how to get the OS running on whatever device you choose as there are plenty of those guides on the internets.


Power on the device and install Python and PyGame via your favorite software manager.

Load the following code into a python file in a directory of your choosing. In this case the file is and the directory is /home/pi/

import pygame

pygame.mixer.init()‘[your/path/here.wav’) #the -1 permits continuous playback


Save that as, for example,

This code originally actually selected a file at random from a list and played that, but that wasn’t really my jam. Unfortunately I can’t find the OP to give credit to, so if anyone runs across it in their internet travels let me know and I will update with a link.


You’ll need to point the script to your noise file on device.

Step 1.5: What noise to play?

The world is your oyster and there are plenty of places you can download ambient noise files, but here is how it worked out for me:

In the past, I’ve like brown noise (lol). It is deeper than white and sounds more like water to me. Allegedly pink noise is the best for sound curtains, but in practice I found it too harsh and tinny. Maybe I was playing it too loud? Maybe my speakers were too shitty.


What I’ve found makes the ideal sound for me is:

  • Mostly low frequency
  • Little to no variation
  • No actual water sounds or thunder
  • Very long file (~24 hours works best)

By far my favorite is this:


The sound of the USS Enterprise’s engine idling. I know, sounds silly but actually it is prefect white noise. Just listen to it!

The full 24 hour MP3/WAV is a little over a gig (don’t be fooled by the OGG, it is only a few hours long) but well worth it.


Whatever sound you choose, I suggest you open it Audacity or whatever audio editing program you like. Basically you’ll want to make sure there isn’t a massive gap at the beginning/ end of the file that would be audible. You can also make modifications to ensure the file loops seamlessly, though in practice I don’t mind the audio glitch every 24 hours. If your sound file is very short, I suggest making it at least 4 hours long, preferably much longer, to reduce the chances for errors.

Step 2: Testing your script and troubleshooting audio

Next up you’ll need to make your executable. That is easy by just saying chmod +x You can then execute the script by running it in python python, assuming you have speakers connected. If you don’t... well now is the time.


HOWEVER, I’ve found there are a couple problems with this.

First off, by default the sound output is set to 100% and that doesn’t seem to work well. Before I run the script I’ll run amixer set PCM — 100, which seems to make everything better. (That is a double dash between PCM and 100 but Kinja is formatting it weird.)


So try that first and see where it takes you. IIRC the — 100 is telling amixer to set the output to 10.0%.

Even when doing that, with the default sound output from a Raspberry Pi I’d get unwanted noise, random clicks, and interference. A lot of this came down to the power supply to the Pi. If you use a bad supply that apparently causes it to introduce artifacts into the audio. Also if you power USB speakers off the Pi you’re asking for trouble.


Even with all of that in an ideal configuration, you can still get clicks, pops, and other annoying artifacts in the output. There are a lot of things to google to fix it, though this article seemed to help me the most.

Or, the solution to all of this, apparently, is to use a USB sound card. I haven’t done it for this application as once I get these working I tend to never touch them again. (I have two in the house both of which have been running for well over a year...) If you continue to have audio problems a USB sound card may be the solution.


Step 3: Auto-running the script

There are a ton of different ways to auto-run code in Linux and I suggest you look them all up and choose one that works best for you.


I chose the deprecated rc.local method because it was easy and straightforward. All I did was add the following two lines to my rc.local file... I think?

amixer set PCM — 100 
python /home/pi/ &

The & at the end of that command is very important. If you don’t have that, execution will pause waiting for that code to finish executing. If you recall, we set that code to never finish executing.... so you’ll get some weirdness.


Anyway, via your favorite method make that puppy auto-run and, if you’re sure you haven’t messed it up, reboot and see what happens.

Step 99: Other Considerations

Umm... well what else is there? As I mentioned above I’ve had two of these running for several years without issues other than having to wrestle with audio clicks, pops, etc. They seem to survive reboot gracefully, which is surprising for a Pi.


I would say there is no need to use an expensive new Pi 4. Just any linux based machine you can find. If you have a Pi 2 or 3 lying around, this might be a good use for it. I personally love the Beagle Bone series, but as they’re a little pricier I’m not sure I can recommend them for this application.

I’m sure there is a way to do this in another OS, but I’m sure I don’t know what it is.


I would say DO NOT connect this to your network permanently. I say that because after I get these running I don’t touch them, therefore they get behind on their security updates and quickly would become a liability on the network. I’d also write down any static IP settings and login information on the Pi itself so if you need to make a change in a year or so you can still get in to the poor thing.

I hope this works out for you guys!

Share This Story

Get our newsletter