User Tools

Site Tools


very_cheap_random_number_generator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
very_cheap_random_number_generator [2016/10/18 13:03]
xylene
very_cheap_random_number_generator [2017/03/14 09:50] (current)
xylene
Line 1: Line 1:
 <​code>​ <​code>​
-static unsigned int seed = 0xd34db33f;+static unsigned int _seed = 0xd34db33f;
  
 unsigned random() {  unsigned random() { 
-   seed = (seed 0x5aa5a55a) * (seed 0xa55a55a); +   _seed = (_seed 0xaaaaaaa) * (_seed 0x555555); 
-   ​return ​seed >> 16; +   ​return(_seed ​>> 16)
 } }
 </​code>​ </​code>​
Line 11: Line 11:
  
 It's good enough for my synths white noise. 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