Main Archive Specials Wiki | FAQ Links Submit Forum


Fast Whitenoise Generator

Type : Whitenoise
References : Posted by gerd[DOT]feldkirch[AT]web[DOT]de

Notes :
This is Whitenoise... :o)

Code :
float g_fScale = 2.0f / 0xffffffff;
int g_x1 = 0x67452301;
int g_x2 = 0xefcdab89;

void whitenoise(
float* _fpDstBuffer, // Pointer to buffer
unsigned int _uiBufferSize, // Size of buffer
float _fLevel ) // Noiselevel (0.0 ... 1.0)
{
_fLevel *= g_fScale;

while( _uiBufferSize-- )
{
g_x1 ^= g_x2;
*_fpDstBuffer++ = g_x2 * _fLevel;
g_x2 += g_x1;
}
}



Comments


Added on : 18/07/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu
Comment :
Works well! Kinda fast! The spectrum looks completely flat in an FFT analyzer.



Added on : 29/11/06 by gerd[ DOT ]feldkirch[ AT ]web[ DOT ]de
Comment :
As I said! :-)
Take care




Added on : 29/11/06 by nobody[ AT ]nowhere[ DOT ]com
Comment :
I'm now waiting for pink and brown. :-)



Added on : 30/11/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu
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              




Added on : 30/11/06 by nobody[ AT ]nowhere[ DOT ]com
Comment :
Yeah, I know how to do it with a filter. I was just looking to see if this guy had anything else clever up his sleeve.

I'm currently using this great stuff:

vellocet.com/dsp/noise/VRand.html




Added on : 15/12/06 by tremblap[ AT ]gmail[ DOT ]com
Comment :
I compiled it, but I get some grainyness that a unisgned long LC algorithm does not give me...  am I the only one?

pa




Added on : 17/12/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu
Comment :
Did you do everything right? It works here.



Added on : 19/12/06 by gerd[ DOT ]feldkirch[ AT ]web[ DOT ]de
Comment :
I've noticed that my code is similar to a so called "feedback shift register" as used in the Commodore C64 Soundchip 6581 called SID for noise generation.

Links:
en.wikipedia.org/wiki/Linear_feedback_shift_register
en.wikipedia.org/wiki/MOS_Technology_SID
www.cc65.org/mailarchive/2003-06/3156.html




Added on : 12/03/07 by Arif[ AT ]mail[ DOT ]---
Comment :
SID noise! cool.



Add your own comment
Comments are displayed in fixed width, no HTML code allowed!
Email:

Comment:

Are you human?



Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion