Re: [LAD] random curiosity

From: Gabriel M. Beddingfield <gabrbedd@email-addr-hidden>
Date: Wed Jan 27 2010 - 14:54:00 EET

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
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Wed Jan 27 16:15:06 2010

This archive was generated by hypermail 2.1.8 : Wed Jan 27 2010 - 16:15:06 EET