[mythtv] MythMusic playlists still not intelligent enough IMHO

Eskil Heyn Olsen myth at eskil.org
Thu Apr 19 00:00:22 UTC 2007

On Wed, 2007-04-18 at 10:50 -0400, Dan Wilga wrote:

> - assume songs are in an array
> - assume N is the length of the array (the number of songs in the list)
> - find a prime number, P, such that it is guaranteed to be larger 
> than N and yet P+N <= MAX_INT
> - choose the index of the first song, S, randomly:  S = rand() % N
> - afterward, each new song, S' is calculated like so:  S' = (S + P) % N

Interesting, I'd be interested in taking a stab at this just for the
hell of it. But what if the N >= MAX_INT/2 entries, than there won't be
any P that satisfies the criteria ? Will chosing the highest P' such
that P'+N <= MAX_INT but P' < N still yield fairly good randomness ?

Or just assume that people with 32k songs in a playlist don't care ?


More information about the mythtv-dev mailing list