After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 544680 - Weighted random mode
Weighted random mode
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: Other Extensions
git master
Other Linux
: Normal enhancement
: 1.x
Assigned To: Banshee Maintainers
Banshee Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-07-25 12:30 UTC by Elena Grassi
Modified: 2009-06-13 00:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
first version of the patch (5.03 KB, patch)
2008-07-25 12:32 UTC, Elena Grassi
none Details | Review
Version connected with menus (11.48 KB, patch)
2008-07-28 18:18 UTC, Elena Grassi
none Details | Review
Version connected with menus (11.48 KB, patch)
2008-07-28 18:19 UTC, Elena Grassi
needs-work Details | Review
Changed names and multi-line strings (11.79 KB, patch)
2009-01-13 23:39 UTC, Elena Grassi
none Details | Review
Updated to git master + fixes (7.63 KB, patch)
2009-06-04 07:38 UTC, Alexander Kojevnikov
none Details | Review
Changed weights (7.84 KB, patch)
2009-06-05 07:51 UTC, Alexander Kojevnikov
committed Details | Review

Description Elena Grassi 2008-07-25 12:30:56 UTC
Right now the patch is just a modification of Banshee.Services/Banshee.Collection.Database/DatabaseTrackListModel.cs
which implements random selection based on songs ratings.

If someone wants to give a hand/suggestions...as a beginner I'm full of doubts:
-where this code should be placed (the ShuffleStars class)?
-when to re-Initialize the weights? 
-will it be better to use this as an Extension or as another shuffle
mode?
-... :)

[patch diffed against revision 4247]
Comment 1 Elena Grassi 2008-07-25 12:32:22 UTC
Created attachment 115243 [details] [review]
first version of the patch
Comment 2 Andrew Conkling 2008-07-25 17:09:32 UTC
(In reply to comment #0)
> If someone wants to give a hand/suggestions...as a beginner I'm full of doubts:
> -will it be better to use this as an Extension or as another shuffle
> mode?

I'm not a developer, but I'd imagine that the best way to implement this would be as an extension rather than a replacement for the current shuffle code. The mailing list would be a good place to discuss that, as not all the contributors read the bugs as diligently, but there are a number of people who would be willing to help.

Seems like a nice idea though; I look forward to trying it!
Comment 3 Bertrand Lorentz 2008-07-26 14:14:21 UTC
I think that this really should be a new shuffle mode, like "Shuffle by Artist" or "Shuffle by Album". Those two are visible but greyed out in the UI because they're not implemented.
I had a look on how to add a shuffle mode, but couldn't figure how to connect the UI stuff to the GetRandom code.

This shuffle mode could be integrated directly in banshee, or through an extension, depending on our maintainers' thoughts about this.
Comment 4 Elena Grassi 2008-07-26 15:30:48 UTC
Yes sorry I didn't point out that the actual patch was just a kind of "proof of concept" (I wanted to try the new shuffling) - I'm going to start trying to figure out how to made it an extension or a possible choice in the shuffle menu; but I'd like to hear which one would be the best in maintainers' and users' opinion (btw I agree with Bertrand).
Comment 5 Elena Grassi 2008-07-28 18:18:35 UTC
Created attachment 115441 [details] [review]
Version connected with menus

Here it is the version connected with menus, allowing shuffle by song and new weighted mode. As a novice  I'm aware that it will be a mess, but maybe could work as a starting point (I'll have to figure out what MemoryTrackListModel does and if there should be some new implementation there...).
Comment 6 Elena Grassi 2008-07-28 18:19:03 UTC
Created attachment 115442 [details] [review]
Version connected with menus

Here it is the version connected with menus, allowing shuffle by song and new weighted mode. As a novice  I'm aware that it will be a mess, but maybe could work as a starting point (I'll have to figure out what MemoryTrackListModel does and if there should be some new implementation there...).
Comment 7 Andrew Conkling 2008-07-28 19:40:39 UTC
Obsoleting one patch for the other, since it looks like everything got posted twice.
Comment 8 Gabriel Burt 2009-01-13 22:29:52 UTC
Elena, this is really good.  Can you change Weighted to Rating, and star(s) to rating as well?  Use @" ... " for multi-line strings (vs " " + " " etc)
Comment 9 Elena Grassi 2009-01-13 23:39:26 UTC
Created attachment 126389 [details] [review]
Changed names and multi-line strings

Here the requested modifications of the patch, against rev. 4915
Comment 10 Gabriel Burt 2009-03-26 01:52:45 UTC
Hey Elena, sorry there's been no feedback for so long.

I just spent quite a while looking at the code, and I'm probably just forgetting, but can you explain what the overall purpose is?  What is the end result - that items with a more common rating are played more often?
Comment 11 Elena Grassi 2009-03-26 22:04:52 UTC
Highest rated songs are played more often, yes. And for lazy-raters (like me :) ) unrated songs are considered as 3-stars.
Comment 12 Alexander Kojevnikov 2009-06-04 07:38:42 UTC
Created attachment 135921 [details] [review]
Updated to git master + fixes

Elena, thanks for the patch! I used this feature all the time in iTunes and missed it in Banshee.

I updated your patch to apply to git master. I also added these changes:

* Replaced ShuffleRating class with GetRandomRating method.
* Re-read ratings distribution on each call.
* Reduced the number of database queries from 5 to 1, making the distribution calculation more efficient.
* Use selected model (and not the entire Library) when calculating the distribution.
* Use the random_began_at time-stamp as the other shuffle modes.
* Fixed a bug when unrated tracks have never been played.
Comment 13 Alexander Kojevnikov 2009-06-05 07:51:30 UTC
Created attachment 136001 [details] [review]
Changed weights

Changed the weights from [1, 2, 3, 4, 5] to [1, φ, φ², φ³, φ⁴].
Comment 14 Gabriel Burt 2009-06-13 00:46:42 UTC
Thanks a lot, Elena and Alexander!  I committed the most recent patch (slightly tweaked for some recent changes to the random code).