Re: [Rhythmbox-devel] random smart playlist?



On Thu, 2007-01-25 at 04:46 -0700, Alex Lancaster wrote:
> >>>>> "MR" == Matt Robertson  writes:
> MR> What I'd like to do is have the smart playlist creator pick a
> MR> random subset of songs based on my criteria.  Currently it will
> MR> either pick them all, or if a limitation (MBs, time, etc.) is
> MR> reached, pick them in some ordered way.  For instance I might end
> MR> up with all the songs that come from albums beginning with 'A'.
> MR> Is there any way to get a randomized subset?  If not, should this
> MR> be requested as an enhancement?
> 
> I started working on it a while back but didn't finish it.  I got
> stuck trying to figure out how to represent the sorting order in the
> RB data structures.  If I get time I'd like to look at it again, but
> if somebody else is feeling more motivated and has a good grasp of the
> RB internals, please go for it...

If anyone in interesting in working on this, this is how I'd do it:

1) add a new instance variable to RhythmDBQueryModel, which is a
GHashTable which maps from RhythmDBEntry to int.

2) add a new sorting function to rhythmdb-query-model.{c,h}
"rhythmdb_query_model_random_sort_func". This function should look the
two entries up in the hash table to find their int value, if they aren't
in the table pick a random int and put that in the hash table. Make the
compare function say the later entry is the one with the largest int
value, and go by the LOCATION property if equal.

3) Fix the likely few bugs, and think about dealing with things like
removing entries from the table when they get removed form the model.

4) Enjoy.



Cheers,

James "Doc" Livingston
-- 
[...] and the French an excuse to use their traditional battle cry.
    -- Firebeard
"We Surrender, here, have my daughter."?
    -- Paul Tomblin 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]