Length-weighted Playcount in Foobar 2000

I recently added %playcount% display to my Foobar2000 Facets view to have categories like 25+ plays. It always bugged me that playcount was such an unfair measure: I listen to a lot of mixes that weigh in at around 60 minutes, and listening 10 times to such a mix is worth a lot more than listening 10 times to your average 5 minutes song.

If you just multiply the %playcount% by 100%, you run into some issues, though. Obviously a mix I listened to once doesn't weigh as much as say 10 5-minute-song listens. There doesn't seem to be a log() function in Foobar's scripting, so an alternative is to let the length corrected playcount only have a certain influence (e.g. 30%):

$div($add($muldiv(
  $mul(
    $div($div($mul(%length_seconds%,100),60),<AVGLENGTH_MINUTES>)
      ,%play_counter%)
    ,$put(lengthweight,<LENGTHWEIGHT_PERCENT>),100),
  $mul(%play_counter%,$sub(100,$get(lengthweight))))
  ,100)

This will give you a playcount in the same range like %playcount%.

For Facets we need categories:

$if(
  $greater($put(playtime,
    $div($add($muldiv(
      $mul(
        $div($div($mul(%length_seconds%,100),60),<AVGLENGTH_MINUTES>)
          ,%play_counter%)
        ,$put(lengthweight,<LENGTHWEIGHT_PERCENT>),100),
      $mul(%play_counter%,$sub(100,$get(lengthweight))))
      ,100)
  ,199)
  ,200 plays,
  $if($and($greater(200,$get(playtime)),$greater($get(playtime),64)),65 plays,
    $if($and($greater(65,$get(playtime)),$greater($get(playtime),24)),24 plays,
      $if($and($greater(24,$get(playtime)),$greater($get(playtime),9)),10 plays,
        $if($and($greater(10,$get(playtime)),$greater($get(playtime),0)),1 play,
          0 plays)))))

Obviously, you need to put in your average song length (I use 5), weight ratio (30 seems to work fine), and delete all newlines and indentations:

$if($greater($put(playtime,$div($add($muldiv($mul($div($div($mul(%length_seconds%,100),60),5),%play_counter%),$put(lengthweight,30),100),$mul(%play_counter%,$sub(100,$get(lengthweight)))),100)),199),200 plays,$if($and($greater(200,$get(playtime)),$greater($get(playtime),64)),65 plays,$if($and($greater(65,$get(playtime)),$greater($get(playtime),24)),24 plays,$if($and($greater(24,$get(playtime)),$greater($get(playtime),9)),10 plays,$if($and($greater(10,$get(playtime)),$greater($get(playtime),0)),1 play,0 plays)))))

Now I just need to find a way to tag my mp3s with my last.fm playcounts…

Archives