Howdy y'all, I spent my company holiday cooking up a patch that allows Banshee's shuffle to be marginally more intelligent (think: single-celled amoeba instead of a rock). This patch harnesses many advanced computer science techniques like "PROBABILITY", "GREEK LETTERS[1]" and "RANDOM NUMBERS" to construct a shuffle that will oftentimes hover inside of a genre, creating a fluid and dynamic listening experience, then will hop out of said genre to maintain that musty aura of randomness we all know and love. For those all you smarmy inquisitors (you know who you are), feel free to read the patch to find out how it all works. Its rather simple, really. To apply this patch, you'll need Banshee from CVS. I'd love to hear how people like this -- HOVER_FREQUENCY may still need some tweaking to be optimal. -Brad -- [1] Sadly, the greek letters had to be removed due to a run in with the confusing-variable-name-police. No, not the sexy police. -- Brad Taylor Genome Software LLC http://www.getcoded.net
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/banshee/ChangeLog,v retrieving revision 1.291 diff -u -r1.291 ChangeLog --- ChangeLog 2 Jan 2006 06:12:58 -0000 1.291 +++ ChangeLog 2 Jan 2006 22:48:59 -0000 @@ -1,3 +1,10 @@ +2006-01-02 Brad Taylor <brad getcoded net> + + * src/PlaylistModel.cs: Implement a more intelligent Shuffle that has a + 68% chance of hovering inside the current genre, making the transitions + between songs slightly more fluid. Of course, this value should be + tweaked for better results. + 2006-01-02 Aaron Bockover <aaron aaronbock net> * src/MusicBrainz/Client.cs: Null checks on GetID Index: src/PlaylistModel.cs =================================================================== RCS file: /cvs/gnome/banshee/src/PlaylistModel.cs,v retrieving revision 1.29 diff -u -r1.29 PlaylistModel.cs --- src/PlaylistModel.cs 30 Dec 2005 06:08:42 -0000 1.29 +++ src/PlaylistModel.cs 2 Jan 2006 22:49:00 -0000 @@ -364,6 +364,33 @@ private bool GetRandomTrackIter(out TreeIter iter) { + const double HOVER_FREQUENCY = 0.68; + + if(Source is LibrarySource + && !playingIter.Equals(TreeIter.Zero) + && Count () == Globals.Library.Tracks.Count) { // XXX: Gross way to check that there isn't a search active + TrackInfo last_track = IterTrackInfo(playingIter); + + if(Globals.Random.NextDouble() < HOVER_FREQUENCY) { + string query = "SELECT TrackID FROM Tracks " + + "WHERE Genre = '" + Statement.EscapeQuotes(last_track.Genre) + "' " + + "ORDER BY RANDOM() LIMIT 1"; + + int id = 0; + try { + id = Convert.ToInt32(Globals.Library.Db.QuerySingle(query) as string); + } catch { } + + if(id > 0) { + LibraryTrackInfo track = Globals.Library.GetTrack(id); + if (track != null) { + iter = track.TreeIter; + return true; + } + } + } + } + int randIndex = Globals.Random.Next(0, Count()); return IterNthChild(out iter, randIndex); }
Attachment:
signature.asc
Description: This is a digitally signed message part