(jmarshall @ feb. 21 2006,01:01 Wrote:regarding the randomness, i don't think that calling srand(timegettime()); rand() is necessarily a reliable random sequence - the "random" number is tied to close to the current time. it gets even worse if you modulo it as the low bits of rand() are less variable than the high bits. this is used elsewhere in xbmc as well and is the reason for a number of other phenomena such as the slideshow random angles not being particularly random.
perhaps we could have a random number class that seeds once and then uses the one sequence (up until a set number of drawings, then re-seed it) so that we can get reasonable randomness? i think using srand() and rand() is fine as long as we do it sensibly.
also, we could have a history vector of song ids for database::getrandomsong() to eliminate the issues pike is seeing for say 100 songs or so.
party mode looking great though - i like it 
cheers,
jonathan
agreed, jonathan, but more importantly, even if you had a truely "random" distribution, without protecting against it, you could have a legit double hit of one song in a 10 of 38 selection...just making a point that pure random distributions won't prevent something selected once from showing up again until all possible values have been populated. in this case, i think a check needs to be made not to add the random song to the queue unless there are 10 or fewer files to pick from (at which time you just fall into randomizing the order of the files that you do have) if it is already in the queue.
time for a random number populator to select all possible combinations without repeats increase exponentially, as you approach selecting 100% of the files for your list, unless coded for. i've found that it is pretty fast if you have at least 125% of the population available for selection without too much extra case coding (i.e. maintaining a hash or array of files selected and only randomize the picking of the new reduced array is optimal if you have to approach 100% random selection). so, if you didn't want to have your randomized function take too long, but also didn't want to have to maintain a "files left to add that have never been picked yet" for your selection, you would just mandate that there be at least 125-150% of the files in the library (that means >12 to 15 files in the library to compile a random unique list of 10). sorry, that is probably more complicated of an explaination than it needed to be, but i'm a bit strung out right now with other issues. :o
-jm