INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Smarffle (smart shuffle)  (Read 1405 times)

Qythyx

  • Galactic Citizen
  • ****
  • Posts: 390
Smarffle (smart shuffle)
« on: May 12, 2009, 12:51:06 am »

A few years ago I wrote a MC plugin that calculated a Weight numerical value for tracks based on a user configurable formula, typically including Rating, Last Played, and Number of Plays. The purpose was to order my music so that I listened to things I hadn't listened to recently and with a weighting towards things with a higher Rating. I recently finally got around to using MC's Math() expression to accomplish the same without needing my plugin.

I'd like to open up a discussion on particular formulae that work well for people. My formula is below, with a few notes. What I do is resort on this field each day before I start listening (I basically listen all day while at the office).

Math((100 + If(IsEqual(Field(Last Played,0),), 100, Math(Now() - Field(Last Played,0)))) / 100 / (10 + If(IsEqual([Number Plays],),0,[Number Plays])) * (If(IsEqual(Field(Rating, 0), ), 6, Field(Rating, 0)) * 15))

A few notes:
The first 100 is used to reduce the difference between a recently played item and one not played in such a long time. This make the numerator a range between 100 and "100 + days_since_last_played". This is the divided by 100 to scale the affect of this part of the equation. Therefore, altering the 100 denominator can cause the last played to have more or less effect.

The 10 before Number Plays has a similar effect for it. Note that I'm not dividing this portion, though.

Finally, the Rating is multiplied by 15 to make it have a larger effect.
Logged

ADDiCT

  • Regular Member
  • World Citizen
  • ***
  • Posts: 235
  • I'm a bad llama!
Re: Smarffle (smart shuffle)
« Reply #1 on: May 12, 2009, 02:30:20 pm »

Qythyx, thanks for this! I've created some smartlists based on your formula, with very interesting and nice results. The name "smarffle" rocks, too (; . I wish there was a central place for "best practice" solutions like this, like a dedicated forum.
Logged

bhageman

  • Recent member
  • *
  • Posts: 7
Re: Smarffle (smart shuffle)
« Reply #2 on: May 12, 2009, 05:55:41 pm »

Sorry, for my ignorance, but I checked the Wiki and search the forums. I couldn't find any information on using the Math expression to create a smartlist using your formula.

Could you walk me thru it? I have my own basic smartlist, but without the ability weigh stars and last played, so this would be really interesting.

Thanks!
Logged

Qythyx

  • Galactic Citizen
  • ****
  • Posts: 390
Re: Smarffle (smart shuffle)
« Reply #3 on: May 12, 2009, 10:30:11 pm »

Yeah, I know what you mean. It took me so long to convert my formula to MC because I didn't realize the Math function existed. The wiki doesn't seem to have any info on it, but the expression builder has some decent descriptions of all functions when you hover your mouse over them.

The Math function is pretty simple and just evalutes the values inside it as a methematical function. For example: Math(2 + 5 * 7) equates to 37, because the * has higher precedence than the +.

Here's a breakdown of my function:

Math((100 + If(IsEqual(Field(Last Played,0),), 100, Math(Now() - Field(Last Played,0)))) / 100 / (10 + If(IsEqual([Number Plays],),0,[Number Plays])) * (If(IsEqual(Field(Rating, 0), ), 6, Field(Rating, 0)) * 15))

1
First, the "Field" function is needed to convert certain fields into a number, instead of a date or rating. So doing that replacement simplifies the function to:

Math((100 + If(IsEqual(Last Played,), 100, Math(Now() - Last Played))) / 100 / (10 + If(IsEqual([Number Plays],),0,[Number Plays])) * (If(IsEqual(Rating, ), 6, Rating) * 15))

2
Next, the "If" and "IsEqual" stuff is needed to convert fields that might not yet have a value to some default value. For example, if a track is not rated it's rating is empty, not the number 0. Similarly for "Number Plays".

For "Last Played" I make it slightly more complex. If it has never been played I set the value to 100 (i.e., it hasn't been played in 100 days), if it has been played then I subtract the "Last Played" value from Now() (i.e., the time right now) to get the number of days since it was last played.

If I remove these it simplifies the function to:

Math((100 + Days Since Last Played) / 100 / (10 + Number Plays) * (Rating * 15))

3
This gives me my basic formula. I played with various values to come up with this and the constant numbers can be adjusted to change weightings. For clarity removing the "Math" leaves the final formula:

(100 + Days Since Last Played) / 100 / (10 + Number Plays) * (Rating * 15)



I hope that helps a bit.
Logged
Pages: [1]   Go Up