On Wed, 27 Jan 2010, cal wrote:
Jens M Andreasen wrote:
[ ... ]
I am surprised that nobody so far has suggested using the key and
velocity as a "salt" to differentiate a single stream of randomness?
If you don't mind, how would one go about "salting" it?
One way that comes to mind:
unsigned short int note, velocity;
// ...
unsigned int salt = ((velocity & 0x7F)<<7) | (note & 0x7F);
struct random_data seed;
srandom_r(salt, &seed);
Thus, if you repeat the note with identical velocity...
you'll always get the same random-number sequence.
-gabriel