I have a three week old baby. Occasionally she refuses to sleep. Some people tell me this is the way life is, some people tell me I need to buy things to fix it. This is becoming an alarmingly common pattern in this parenting game.

Anyway one of these things "I need to buy" is a white noise generator. White noise defined as:

a random signal is considered "white noise" if it is observed to have a flat spectrum over the range of frequencies that is relevant to the context. For an audio signal, for example, the relevant range is the band of audible sound frequencies, between 20 to 20,000 Hz.

There are several things I can buy. Apps for Android, dedicated boxes that I'm sure just play a tiny clip of pre-generated noise, all the way to mega-expensive true-random white noise generators.

I want to generate my own white noise sample

I know I could download one with youtube-dl from one of the many videos out there but copyright aside, frequency compression is horrible online I want full-white-frequency goodness. If such a thing actually exists. Plus I'm a glutton for punishment and I believe that if something can be done via the command line, that's the way we should be doing it. That's how I aim to raise this one anyway.

So we have things like /dev/urandom and paplay. Is there a sensible way to take random data and channel it into the audible range of white noise and out of my speakers? Answers that write to file are okay too. The important thing is a steady range-confined sample. No squawks.

Note: answers that generate the brown note will not be appreciated ☹

  • 29
    See other answers for the techie side. Practical me says that there are CDs of surf/rain/waterfall noise that may not be mathematically pure white noise but are probably much closer to the soothing ear-candy you are looking for (and likely at the origin of the reputation of the white noise). – xenoid Jun 20 '16 at 21:22
  • 5
    Would this work? – Mitch Jun 20 '16 at 21:30
  • 6
    The post that @Mitch pointed at is not in reference to the 'brown note'. "The term "Brown noise" does not originate from the color, but from Robert Brown who discovered Brownian motion." – Adrian Jun 20 '16 at 22:05
  • 4
    Tune the radio away from any channel? – gerrit Jun 21 '16 at 10:36
  • 12
    Unless you have already taught your baby Pearson's chi-squared test, true randomness isn't too big of a deal. – PyRulez Jun 22 '16 at 3:14

12 Answers 12

Use the Swiss army knife for sound generation, SoX.

You install it from the official repositories, simply by typing:

sudo apt-get install sox

Updated, fancy answer (pleasing ocean waves):

After experimenting a bit with SoX, I came up with this great command which imitates the soft murmur of the sea with its soothing sound of waves that flow over a flat sandy beach on a sunny summer day...

Well, enough poetry, here's the command. Listen yourself.

play -n synth brownnoise synth pinknoise mix synth sine amod 0.3 10

Explanation:

This command first generates and mixes brown noise and pink noise, which I find to be the most comfortable and natural noise. Then it generates a sine wave of 0.3 Hz with an offset of 10% and uses this to modulate the amplitude of our mixed noises to produce the sound of ocean waves.

Modifications:

  • Timer:
    You can add a timer and limit the playback duration by specifying the number of seconds, the number of minutes and seconds (mm:ss) or the number of hours, minutes and seconds (hh:mm:ss) right before brownnoise. Here's an example for one hour:

    play -n synth 1:0:0 brownnoise synth pinknoise mix synth sine amod 0.3 10
    
  • Wave frequency:
    If you want the waves to hit the beach more or less frequent, simply change the frequency of the sine wave used for amplitude modification (0.3 in the above command). The number represents the amount of waves per second, so a frequency of 0.1 Hz will cause 0.1 waves per second and therefore make one wave last for 10 seconds:

    play -n synth brownnoise synth pinknoise mix synth sine amod 0.1 10
    
  • Minimum background noise volume:
    The sine that is used for amplitude modulation got shifted to an offset of 10%, so the brown-pink noise will always be played with at least 10% volume. If you want a stronger or weaker background noise, increase or decrease this offset to your needs. Here's an example with 20% background noise:

    play -n synth brownnoise synth pinknoise mix synth sine amod 0.3 20
    

Old, boring answer (plain white noise):

Now the easiest command to play white noise infinitely (until you abort it with Ctrl+C) is this:

play -n synth whitenoise

If you prefer a time limit, you may add that in the format hh:mm:ss. The following command would make noise for one and a half hour, for example:

play -n synth 01:30:00 whitenoise

It even shows you some nice stats while "playing":

$ play -n synth 00:00:05 whitenoise 

  Encoding: n/a           
  Channels: 1 @ 32-bit   
Samplerate: 48000Hz      
Replaygain: off         
  Duration: unknown      

In:0.00% 00:00:05.12 [00:00:00.00] Out:240k  [!=====|=====!] Hd:0.0 Clip:0    
Done.
  • 6
    I edited my answer and added a fancy but simple ocean wave sound generator command which will please baby's (and daddy's) ears far more than plain white noise. – Byte Commander Jun 21 '16 at 10:06
  • 2
    I love this - but the sine wave volume change isn't really very much like the sound of waves on the beach. It needs to increase in volume quite quickly as the wave breaks on the beach, then fall away much more slowly. Is there a way to achieve that? – Caesar Jun 22 '16 at 0:16
  • 7
    @Caesar there's a limit to how good you can get with these tools, but I think play -n synth brownnoise synth pinknoise mix synth 0 0 0 15 40 80 trapezium amod 0.2 10 is closer to what you're asking for :) – hobbs Jun 22 '16 at 5:21
  • 1
    @hobbs and now if the repetition frequency were not so regular ... ;-) :-P – Rmano Jun 22 '16 at 13:25
  • 1
    @Rmano that, I don't think is doable within sox :) – hobbs Jun 22 '16 at 18:33

White noise is torture.

Especially for the delicate ears of babies.

This is because white noise has too much energy in the high frequencies.

  • 24
    While you've got a point there, this is does not answer the question. – leftaroundabout Jun 20 '16 at 23:08
  • 19
    @leftaroundabout If it saves a baby's hearing, I think it's allowable. Even if it's technically better posted as a comment instead of an answer; it's doing more good than harm. Thanks for pointing this out, nightingale, and welcome to AskUbuntu! – Nick Weinberg Jun 20 '16 at 23:19
  • 18
    An answer that says "No, you don't want that" is fair game. The other answers that suggest the "pink" noise seem to take this into account. This answer would be better if it went on to explain that but it's still +1 from me. – Oli Jun 20 '16 at 23:42
  • 22
    @ΈρικΚωνσταντόπουλος I'm good friends with the OP. Plus he asked for a noise to "calm a baby". Tortuous noises are rarely calming. – Oli Jun 21 '16 at 8:31
  • 8
    While I typically hate "no, you actually don't (or shouldn't) want this" answers and comments, I feel like the distinction between real white noise and colloquial "white noise" is important enough that this answer is worthwhile. +1. – Kyle Strand Jun 23 '16 at 4:46

You can generate pink noise using the play command from the sox utilities:

sudo apt-get install sox
play -t sl -r48000 -c2 -n synth -1 pinknoise .1 60

Adjust the values of .1 and 60 to suit your needs. Pink noise is less harsh on the ear and is hopefully the sound you require

  • I think speaker-test does this as well, but I think pink noise is less than optimal, it's noise sure, but having no variation might not be desireable? – bc2946088 Jun 20 '16 at 21:13
  • 4
    @bc2946088 12 hours of pure white noise can be accomplished with play -n synth 12:00:00 whitenoise – Nick Weinberg Jun 20 '16 at 21:16
  • 5
    You say I can adjust them but what do the .1 and 60 arguments actually mean? – Oli Jun 21 '16 at 9:45
  • The .1 is kind of irrelevant here; the 60 is the DC offset. The lower it is the more range (in amplitute) you have in the waveform, setting it nearer to 100 will cause it have less range as it's nearly maxed out to 100% full range. – Colin Ian King Oct 20 '17 at 8:00

Not sure that this will produce real white noise that covers the whole spectrum, but a simple

pacat /dev/urandom

seems to do the trick on my system (no need to install anything new or add a repository).

  • That certainly sounds a lot like the white noise sox produces. – Oli Jun 20 '16 at 23:40
  • 2
    @linolino aren't you on Ubuntu? If you are, it has to be installed (unless you manually removed it). It is provided by pulseaudio-utils, that is even part of the live system (see the manifest). If you don't have it, then probably your installation in corrupted. I suggest that you open a new question explaining the problem and asking for help on how to restore your installation. – dadexix86 Jun 22 '16 at 8:09
  • 1
    Unless they're using a server version. – Arronical Jun 22 '16 at 11:15
  • 1
    In any case, you can still use aplay instead of pacat. alsa-utils seem to be installed by default. – Ruslan Jun 23 '16 at 6:52
  • 1
    @dadexix86 actually I have got an lubuntu. Anyway somehow not working in my case after apt-get install. But ByteDefenders solution is working fine ;-) – linolino Jun 27 '16 at 16:10

I'm a glutton for punishment, so I'll give you the GUI way. Take a look at ANoise.

The default sound that it comes with is bad, but you can download other sounds like Forest Rain, Fountain, & Others. You can set it to start with the system, and even set it to stop after a certain time.

sudo add-apt-repository ppa:costales/anoise
sudo apt-get update
sudo apt-get install anoise

ANoise Code, And for For extra river sound:

sudo apt-get install anoise-community-extension1
  • +1 I use Anoise all the time. But it has a few major bugs with 16.04. – UniversallyUniqueID Jun 22 '16 at 15:03

Open Audacity.

Go into "Generate > Noise..."

Select "Brownian" (way less aggressive than actual white noise). Amplitude and duration does not matter much.

Loop using Shift+Play button.

The installed-by-default utility speaker-test generates pink noise (which, as @nightingale, is what you really want, not white noise). It can be set to do so indefinitely by running

speaker-test -l 0

FFMpeg has an audio noise source filter. You can play it using ffplay:

ffplay -f lavfi -showmode 0 -i 'anoisesrc=color=brown'

The arg to -i is interpreted as a lavfi filter graph, because of -f lavfi. -showmode 0 disables ffplay's default audio visualizer window, which it shows by default for audio-only inputs.

As you can see from the output of ffmpeg -h filter=anoisesrc, you get a choice of brown/pink/white noise at whatever amplitude and samplerate you like, optionally with a finite duration.


You can also use mpv, a nice fork of mplayer, or other players that allow ffmpeg filtergraphs. e.g.

mpv  av://lavfi:anoisesrc=color=brown

This might be handy if you have a custom audio-output setup configured for your favourite player.

I see that nobody has used aplay yet so try the following:

aplay --channels=2 --format=S16_LE --rate=44100 --duration=3600 /dev/urandom

It is not terribly imaginative so I have added in a timer to compensate :). The duration settings is in seconds so this will run for 1 hour and then turn off, hopefully the baby will have settled by then...

White noise is mathematically an even distribution of frequencies. You can produce it with random data from /dev/random or /dev/urandom. If you want to change the "tone" of the produced noise (for example to make it less "weighty" by removing lower frequencies, or to make it "damper" by removing higher frequencies) then you could use a command such as dd bs=1 if=/dev/urandom of=whitenoise.raw count=1048576 to generate some white noise, then import it into Audacity and use the high-pass and low-pass filters to adjust it to your liking (when using the filters remember that the average human ear will hear frequencies up to 20kHz).

EDIT: Audacity can also generate white noise itself.

Tom Swiss of unreasonable.org uses the following code (using sox) to generate white/pink noise. You'll need to first install sox (sudo apt install sox), then create a shell script with the following code:

#!/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

Hat tip http://unreasonable.org/white_noise_generator_with_sox_for_Linux

Disclaimer: I have not tried this myself yet

  • That outputs at an 8kHz sample rate, so there's no noise energy above 4kHz. :/ Proper pink noise should have some. Interesting suggestion to use a vibrato / tremolo filter on the noise, though. – Peter Cordes Jun 21 '16 at 7:38
  • 1
    Better solution? Remove len='7:00:00', if [ "$1" != '' ];then and fi, adding support for infinite noise. – EKons Jun 21 '16 at 8:33

There's also Renoise, a very powerful multi-platform audio sequencer, though the full version is commercial. The demo version however doesn't have many limitations, and will let you do what you want, and add filters, effects, etc. to the generated sound.

http://www.renoise.com

True white noise with a lowpass filter, and maybe some chorus and reverb added for a nice natural effect, would sound quite pleasing.

protected by Community Jun 22 '16 at 0:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.