cycfi / q

C++ Library for Audio Digital Signal Processing
MIT License
1.12k stars 146 forks source link

Noise synthesizer #35

Closed dissonancedev closed 2 years ago

djowel commented 2 years ago

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"

dissonancedev commented 2 years ago

Thank you for the feedback. I have updated wthe code with your suggestions. They sound better now and should also perform significantly better too.

dissonancedev commented 2 years ago

Alright, should be done now :)

djowel commented 2 years ago

perfect!