I have a sound engine where I feed float PCM values between -1, +1. I am trying to make a noise generator. I want to be able to generate brown noise Mathematically as float PCM valaues so that I can put it in my engine and play it live. Example of Smooth Brown Noise.

How is such noise generated Mathematically? Could anyone lead me to useful links, articles? I could not find anything useful.


Brown noise is pretty simple since it has 6 dB/octave per octave slope which can be implemented with a simple first order lowpass or integrator.

So in theory you only have to do two things:

  1. Create a zero-mean uniformly distributed random numbers (using rand() in most languages)
  2. Do cumulative sum and scale, i.e. $x[n] = x[n-1]+c\cdot (2*\operatorname{rand}()-1)$

Now in practice there are a few more considerations:

Brown noise has HUGE amounts of energy at very low frequencies and theoretically infinite energy at 0 Hz. This will likely overload any reasonable system, so you probably want "band-limited" brown noise. The easiest way to do this would to use a a first order high pass and lowpass instead of the integrator. A good starting point would be a high pass at 20 Hz and a low pass at 40 Hz.

Due to the bi-linear frequency mapping the very high frequencies will drop all the way to zero with a rolloff that's steeper than 6dB/octave. That's generally a good thing since you want to keep frequencies close to Nyquist out of your system. If that's a problem for your application, you can simply nudge the zero of the lowpass filter a bit away from the unit circle.

If you want to get fancy you could start with normal distributed random numbers instead of uniformly distributed numbers, but that's more expensive and will make only a minor difference since the aggressive filtering will turn the uniform distribution more or less into a normal one anyway.

  • $\begingroup$ Several questions, Create a zero-mean uniformly distributed random numbersdoes the numbers need to be between float PCM -1, +1?, also for the formula you have given in 2.what are reasonable values for c? are they random or is it a coefficient with a formula i am not aware of? $\endgroup$ – cs guy May 31 at 14:43
  • $\begingroup$ If you do this in floating point, I would only scale once you have the final signal. The actual scale factor will depend on what exact filters you use but can easily be determined experimentally. Create a few seconds of noise, find the peak, add 20% and you are good. Do NOT use my equation: while this is "mathematically correct" brown noise, it's not usable for practical purposes. At least add a high pass. Read the documentation of your random number generator for scaling and range info. $\endgroup$ – Hilmar May 31 at 15:28
  • $\begingroup$ i think you made a typo on the low pass frequency. Did you mean 4000hz as cutoff? 40 seems so low and it just kills the whole signal $\endgroup$ – cs guy May 31 at 16:30
  • $\begingroup$ i added the filters (low as 4k hz), it sounds okay but currently the generated noise sound has like a hissss noise, in the video i mentioned that hiss sound is not present, the hiss sound i mention is very audible in pure white noise. is there a way to get rid of that hisss sound? I suspect that its because of uniformly distributed random numbers? $\endgroup$ – cs guy May 31 at 16:33
  • $\begingroup$ No. I meant 40 Hz. You just have to add a lot of gain after the filter to get it back to your desired amplitude range. At 4 kHz the spectrum will be white below 4 kHz and that will indeed sound like a lot of hiss. $\endgroup$ – Hilmar May 31 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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