INTERACT FORUM

Please login or register.

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

Author Topic: smart playlist expression hijinks  (Read 2824 times)

laerm

  • Galactic Citizen
  • ****
  • Posts: 424
smart playlist expression hijinks
« on: November 26, 2013, 04:03:22 pm »

(This feels like a glynor question... ;D )

I've just bought a new (old) car and I just put in a new (new) stereo. It's got a USB port on it, so hey, I can finally use MC's portable sync features. I'm starting to whip up some complex playlists but I've run into something that I think is insurmountable with the expression language. Is it possible to tabulate a numeric field and then perform operations on it?

My example:

I'd like to drop on a handful of albums that are well-liked by me. I've never used ratings – it's too much work on my part, plus it's kinda redundant, as the top albums get listened to a lot anyway – so that's not a criterion I can filter by. I was hoping I could use the expression language to add up the number of plays for an album and then divide by the number of tracks on the album, to get an average play count per song. This way I can have my random selection of tracks, expanded to full albums, and then put on some random albums whose average song play count is >4, let's say.

The way it is now
Code: [Select]
[File Type]=[mp3] [Number Plays]=>=4 ~limit=40,1,[Artist] ~a ~s=3900gets me to a certain place, but say I have an album where there's one great track I've listened to a bunch but the rest is meh, if that great track was one of the seed tracks chosen by the ~limit, I'll get the meh album.

I've got some other playlists ideas I am trying to thwack out that are related and require some kind of computation (i.e. one of albums that were imported >3 years ago and have only been listened to once, a/k/a the Can I Delete These? playlist), so, if I can figure this one out, the man can eat fish for a lifetime, as they say.

Thanks!
Micah

PS for board admins: Have you ever thought it made sense to bust out a new board for these kinds of questions? Expressions, smartlists, regex, core commands, etc? Call it the hacker board or something...I think the last 10 topics I have posted (not about Mac feedback) are all on these subjects, but do they make sense in Windows board only (now that there is Mac and Linux), or maybe this question makes sense in Android, etc...
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42373
  • Shoes gone again!
Re: smart playlist expression hijinks
« Reply #1 on: November 26, 2013, 04:22:20 pm »

This doesn't help with a Smartlist, but you can see the average number of plays for an album by:

1) Drag the stock 'Albums' view to the root of Audio and pick 'Copy'.
2) Rename the new view 'Album Stats'.
3) Click on the new view.
4) Use the view header to switch from thumbnails to details.  You'll now have a details list of albums.
5) Customize the columns to add the fields you want to summarize.  For example, add 'Number Plays'.  It will show values like '10.7 avg'.  You can sort by any column.
Logged
Matt Ashland, JRiver Media Center

laerm

  • Galactic Citizen
  • ****
  • Posts: 424
Re: smart playlist expression hijinks
« Reply #2 on: November 26, 2013, 10:36:42 pm »

Aha, thanks Matt. Useful for my data-lovin' self, if not completely what I am looking for. ;)

Micah
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: smart playlist expression hijinks
« Reply #3 on: November 29, 2013, 10:31:11 am »

(This feels like a glynor question... ;D )

I've just bought a new (old) car and I just put in a new (new) stereo. It's got a USB port on it, so hey, I can finally use MC's portable sync features. I'm starting to whip up some complex playlists but I've run into something that I think is insurmountable with the expression language. Is it possible to tabulate a numeric field and then perform operations on it?

My example:

I'd like to drop on a handful of albums that are well-liked by me. I've never used ratings – it's too much work on my part, plus it's kinda redundant, as the top albums get listened to a lot anyway – so that's not a criterion I can filter by. I was hoping I could use the expression language to add up the number of plays for an album and then divide by the number of tracks on the album, to get an average play count per song. This way I can have my random selection of tracks, expanded to full albums, and then put on some random albums whose average song play count is >4, let's say.
actualy you can do this. i use more of those fields. first you have to make a smartlist.
Code: [Select]
[Media Type]=[Audio]
[=save(0,TrTot[album artist (auto)][album])1]=1
[=save(math(1+load(TrTot[album artist (auto)][album])),TrTot[album artist (auto)][album])1]=1
[=save(0,NPT[album artist (auto)][album])1]=1
[=save(math([Number Plays,0]+load(NPT[album artist (auto)][album])),NPT[album artist (auto)][album])1]=1
~sort=[Album Artist (auto)],[Album],[Track #],[Media Type],[Disc #],[Name]
this smartlist creates global variables. in this case TrTot, which is the total of tracks, and NPT, which is the number plays total of all tracks of an album.

the thing with this kind of lists, lists that create global variables, is that they must be run on startup or when something changes. i do that by putting this list under audio>customize view>set rules for files display>playlist is any....

ok, so now there are two global variables. make a new library field.. i called mine: number plays AV. set this field as a calculated field and put as a rule:
Code: [Select]
Formatnumber(Math(load(NPT[album artist (auto)][album])//load(TrTot[album artist (auto)][album])),2)&datatype=[number] This devides the total play of the tracks through the amount of tracks. of course you could add that step also to the smartlist. but that is how i do it.

 :)
gab

PS i hope i did not make a mistake in the code since i filtered it out of a smartlist calculating a bunch more global variables :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: smart playlist expression hijinks
« Reply #4 on: December 01, 2013, 05:02:21 pm »

[=save(math(1+load(TrTot[album artist (auto)][album])),TrTot[album artist (auto)][album])1]=1

Try the new SaveAdd() function to avoid Math().
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up