Oh, the implementation is rather expensive, by the looks of it. There should be a better (more performant) way to do this for real-time. Where did you get the algorithm? Why is there a need for cos, log and sqrt? Isn't white-noise just random values (with equal distribution) from -1.0 to 1.0? As in https://www.dsprelated.com/freebooks/sasp/White_Noise.html ?
As noted in the comment:
"To get pink noise, you can apply a 3dB/Oct filter, for example the pink noise filter in the Filters section.
To get brown noise, apply an one pole LP filter to get a 6dB/oct slope.
Peter"
Oh, the implementation is rather expensive, by the looks of it. There should be a better (more performant) way to do this for real-time. Where did you get the algorithm? Why is there a need for cos, log and sqrt? Isn't white-noise just random values (with equal distribution) from -1.0 to 1.0? As in https://www.dsprelated.com/freebooks/sasp/White_Noise.html ?
Here's a fast white noise generator (using a very fast pseudo random number generator with xor -- enough to fool the ears. Keep in mind that we don't use it for things like crypto, so what's good enough can be significantly relaxed): https://www.musicdsp.org/en/latest/Synthesis/216-fast-whitenoise-generator.html
As noted in the comment: "To get pink noise, you can apply a 3dB/Oct filter, for example the pink noise filter in the Filters section. To get brown noise, apply an one pole LP filter to get a 6dB/oct slope. Peter"