Weighted Random in iTunes 8.1

Wednesday, May 20th, 2009 by Rintaun | Uncategorized

Let me start off by saying that this post isn’t about Japan, really, so if you’re not interested in iTunes or iPods, or my hobbies (:p), you can stop reading after this first paragraph. I am planning on writing up a post on my trip to Nara last weekend, but I haven’t quite gotten to it yet. Anyway, moving on.

As you may or may not know, I have had an iPod for a while now… and frankly, while I do feel overall satisfied with the level of quality that the iPod and iTunes provide, I’ve long had quite a few issues with how certain things are handled. I won’t get into most of them today, becuase they aren’t really relevant. Unlike most of my problems, which are differences between the iPod and iTunes itself (such as differences in sorting), this is an issue that I have with iTunes alone: weighted random in the iTunes DJ (Party Shuffle) feature.

I personally feel that 5-star rating systems (for most things) are a bit restrictive. I much prefer to have the freedom of a 10-star rating system, and as such, have enabled the hidden “Allow Half-Star Ratings” option in iTunes. This gives me much better control over how I rate my songs. The only problem with this is that as shown in an interesting little study on the weighted random feature in iTunes, half-star ratings are not taken into account in the weighted random algorithm. This is problematic. Basically, I want my ratings of songs to coincide directly with how often they are played. For example, when I first learned of the half-star feature, I expanded my previous ideal of weighting to include the extra flexibility, as shown below.

0.0 -> Play never (I absolutely hate this song)
0.5 -> Play hardly ever (I don’t like this song basically at all)
1.0 -> Play seldom (I don’t like this song)
1.5 -> Play rarely (I don’t like this song very much)
2.0 -> Play every once in a while (I don’t think this song sucks, but it’s not that great either)
2.5 -> Play occasionally (I think this is an okay song)
3.0 -> Play sometimes (I enjoy listening to this song, but markedly less than others)
3.5 -> Play decently often (I think this is a pretty good song)
4.0 -> Play often (I like this song more than most)
4.5 -> Play frequently (I like this song quite a bit)
5.0 -> Play very frequently (I like this song a lot)

Of course, I made this when I learned about the half-star ratings feature, and so I basically wrote it up as a guide for myself on how to rate things. However, I then found out about the limitations in the weighted random feature, which basically makes this table more or less irrelevant.

So, being the type of person that I am, my first though was: “Is there a way around this?” Well, after googling around a bit, and coming up with basically nothing, I decided to try and put something together myself using iTunes Smart Playlists. To spoil the ending for you: it worked.

So here’s how I did it, if you’re interested in having a more precise weighted random feature in iTunes. In the end, it took 22 Smart Playlists to get it working as I want it, with one small caveat, which I’ll get to later. And it’s small, trust me.

The first step is to create 11 Smart Playlists for each of the different ratings (0, 0.5, 1, 1.5, … 4.5, 5.0). This can be accomplished using the Smart Playlist criteria for Rating. Unfortunately Smart Playlists only accept a solid star count, and this is one of the few places that half stars can’t be used. Thus, “Rating is” can only choose 1-5 stars, not halves, so for the half-star playlists, you’ll need to use “Rating is less than” and “Rating is greater than”. For example, with 4.5 stars, “Rating is less than 5″ and “Rating is greater than 4″. From what I’ve read, this only works in versions of iTunes above 7.6. Below that, you may be able to use “Rating is in the range 4 to 5″, “Rating is not 4″, and “Rating is not 5″ — this works in iTunes 8.1, but I haven’t tested it in versions prior to 7.6.

Now you have 11 Smart Playlists, each containing all the songs with a particular rating. I named mine “ZZZ (rating) Stars” so they wouldn’t get in the way of my other playlists. Now you make another 10 (or 11, if you want) playlists. Each of these should only have one criterion: “Playlist is (playlist)” where ‘playlist’ is the playlist of the corresponding rating. Then you should choose “Limit to X songs selected by (least recently played)”. X should be a number which is high for higher rated songs, but which decreases as you go down in rating. This is the weighting of the songs. I chose to essentially set the weight of 0-rating songs to 0 (thus never allowing them to play), that’s why I only needed 10 playlists. I named these playlists “XXX (rating)”

Once you have those you need one more playlist, which I titled “iTunes DJ Glossing”. This should have 10 criteria (match any) of “Playlist is (playlist)”, one for each of the weighting playlists I told you about in the last paragraph. This will pull all of those chosen songs into the pool for the iTunes DJ.

Once you have all of these playlists done, simply set iTunes DJ to use the “iTunes DJ Glossing” playlist and you’re good to go, a more precise weighted random system! The only problem with this is that one little caveat that I mentioned above — which I realized, actually, while writing this, that it isn’t even as big a problem as I thought (which was still small).

There are two sides to this, and they both stem from the “Limit to X songs selected by (least recently played)” that we chose in the “XXX” playlists. In case you were wondering, the reasoning behind that rule is simple. The first half of it is obvious; it gives us the ability to choose the weighting of our ratings. The second half, I think, is less so. You could, after all, just choose “random” for that part. However, if you do that, iTunes will randomly choose the songs for the playlist and then… keep them. So you’ll constantly have the same songs in the pool for iTunes DJ, and you’ll end up hearing the same small group over and over again. By sorting by “least recently played”, you force iTunes into rotating just-played songs out of the pool, allowing other ones to take their place. That means, essentially, that the possibility of hearing the same song again any time soon after it’s played is relatively small, as iTunes will just continue rotating through your library. I’m not sure if this is a good thing or a bad thing.

The other thing I was worried about is that you would constantly have a normal distribution of songs, basically, when one 3 star song goes out of the pool, one goes back in. But since it’s choosing songs from the pool at random, this isn’t really an issue, now is it?

Anyway, that’s all. I hope you enjoyed it, and it wasn’t too boring…

Feel free to leave your thoughts or suggestions (especially about the “least recently played” issue) in the comments!

1 Comment to Weighted Random in iTunes 8.1

Mama
May 25, 2009

I read this blog, as I have all of your others. But I must say that there was much that I did not really understand. But I love you. Happy Memorial Day! Love, Mama

Leave a comment

Spam protection by WP Captcha-Free

 

May 2009
S M T W T F S
« Apr   Aug »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Random Image