User Tools

Site Tools


very_cheap_random_number_generator
static unsigned int _seed = 0xd34db33f;

unsigned random() { 
   _seed = (_seed ^ 0xaaaaaaa) * (_seed ^ 0x555555);
   return(_seed >> 16); 
}

The more bits you add and the higher up the multiply carry chain you go the more random it appears.

It's good enough for my synths white noise.

The xors prevent the generator from halting (infinite zeros).

It is quite interesting to watch what happens as the shift value changes. It may also be quite interesting to manipulate this in 2D somehow (probably just change the seed init).

very_cheap_random_number_generator.txt · Last modified: 2017/03/14 09:50 by xylene