INTERACT FORUM

Please login or register.

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

Author Topic: Expression Gurus please help me on this...  (Read 3895 times)

Saucepan

  • Junior Woodchuck
  • **
  • Posts: 73
Expression Gurus please help me on this...
« on: March 26, 2016, 03:22:28 pm »

Can anyone build an expression that will take the song with the longest duration in your library, and then display it in the Display Window as "this is the longest song in your library"?


It's a goofy example, but the expression will help me with a more complex issue.


I've tried a number of things, and failed.


Thank you in advance.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Expression Gurus please help me on this...
« Reply #1 on: March 26, 2016, 04:20:59 pm »

I don't what "display window" you are wanting to put information in.

But an expression to find the longest song isn't too hard.  Make a new smartlist.  Then build an expression to do it.  You can do it manually, but here's something you can paste into "import/export" at the lower left:

Code: [Select]
[Media Type]=[Audio] ~sort=[Duration]-d ~n=1
That will show just the longest song in your library in the smartlist window.

Brian.
Logged

Saucepan

  • Junior Woodchuck
  • **
  • Posts: 73
Re: Expression Gurus please help me on this...
« Reply #2 on: March 26, 2016, 04:34:18 pm »

Thank you for the reply.

I'll try to clarify a bit better.

Display Window
 - meaning that window at the top of the app that displays what's currently playing. I'm probably off with the terminology.

For the expression
 - making a smartlist to do it is easy.

What I want to do, is create a Library Field and throw this currently unknown expression into the Calculated Data field so that whatever the longest song is, will be stored in that field.

Make sense?
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Expression Gurus please help me on this...
« Reply #3 on: March 26, 2016, 04:51:28 pm »

What you're describing would be a library field associated with every single song.  ...and that field would be identical for all songs:  It would show the longest song in the library, either by some identifying characteristic (probably by name and duration).

You might be able to do this with global variables and then assign the result back to a library field.  But that sounds really, really awkward and generally seems "wrong".  Plus, I don't think global variables work at all in calculated data.  This would have to be put into a smartlist or a view and then assigned to a field in all songs.  Maybe it's possible, but I'm not sure.

What are you trying to do?  Maybe there's a different approach that is more straight forward.

Brian.
Logged

Saucepan

  • Junior Woodchuck
  • **
  • Posts: 73
Re: Expression Gurus please help me on this...
« Reply #4 on: March 26, 2016, 05:15:53 pm »

What I'm trying to do is pretty easy to grasp, but difficult (maybe impossible) for MC to do. And MC is pretty darn great as we all know.

Anyway, I want to be able to take any record, say Radiohead's 'OK Computer', and tell me where it charts in my library. Like, for MC to display that it's currently my #3 favorite record for 1997, or #12 favorite record for the 90's, or #34 overall.

That's it.



Wouldn't that be cool? It seems like a simple idea, but MC (or any other player) can't do it. I've tried expressions, variables yada yada. It's a pet project that I've looked into on and off since I started using MC (in 2004!).

What I've done, as an alternative, is to manually assign values myself, and update them every so often. But it's taxing and not as fun. I'm looking for MC to calculate this for me, on the fly. Variables are the answer, but I'm not savvy enough to pull it off.

With ferday's help (who is great), I've managed to get very close.


The last piece of the puzzle is to sort my records top to bottom, and then assign an order to each. Then I'm done.




I've asked about this over the years to check in and see if anyone can crack it.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Gurus please help me on this...
« Reply #5 on: March 26, 2016, 08:00:55 pm »

what's the criteria?  (what is the ranking based on, is it your [Points] expression thing?)

groupsummary() can get you a few numbers...i think you could possibly at least find the highest ranked and lowest ranked moderately easily...

if you were ok with having numerous smartlists (for example, by year, genre, etc.) i think it may be possible inside MC.  to get a true rateyourmusic style of chart aggregation, i don't think it's physically possible inside MC currently. however it might be possible to do if you export .csv playlists from MC into an Excel template

Logged

Saucepan

  • Junior Woodchuck
  • **
  • Posts: 73
Re: Expression Gurus please help me on this...
« Reply #6 on: March 26, 2016, 09:36:50 pm »

Yea, the criteria is based on that whole Points expression you built. I've tweaked it and taken it further, but I'm still stuck on the one problem:

 - how to sort all the values in descending order

and then

 - how to assign a value of 1 to the highest, then 2 to the next and so on
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Gurus please help me on this...
« Reply #7 on: March 26, 2016, 10:08:28 pm »

i'm working on something right now.  it's not perfect, or likely to be

i don't have points, so i've been experimenting with album DR which is similar in that it can be sorted.  my album DR smartlist is (cleverly) title Album DR, replace that with your overall [points]

so...make a new smartlist (let's call it chart sequence),the code will look like this, but your playlist id will be different (the points id) as well as your sort field of course.  when you are making the smartlist, use the rules dropdown menus to choose your [overall points] smartlist to get the right playlistid, then go into import/export and type the rest of the code (replacing average DR with your [points] field)

Code: [Select]
[Media Type]=[Audio] playlistid==294821897 ~nodup=[album] ~sort=[Average DR]-d
this gives me a list, sorted from highest to lowest (points), and only lists one track from each album (important!)

now make a new library field (let's call it chart #), as an integer value, user edited ,and relational (one value per album)

now in your new chart sequence playlist, select all the files, and tag files.  in the tag window select the new [chart #] tag.  type in =counter() and wait for a while.  now, the field will be populated with numbers from 1 to however many albums you have...the number 1 will be assigned to the highest points album.  each album will auto-receive the value since you've made it relational

so, now you have a number assigned to the points values.  if you made another smartlist, let's say [decade]=90's, you could sort on the new field and find the top albums from that decade etc

the only magic i haven't figured out, is how to use the playlist id and sequence number...if we could access this, we wouldn't need to manually sequence anything.  however, it's still pretty simple to do, because when you change some ratings, just go to this sorting smartlist, select all files, and type counter() into the tag field....so it will re-number all your tracks pretty quickly

hope this makes sense


Logged

Saucepan

  • Junior Woodchuck
  • **
  • Posts: 73
Re: Expression Gurus please help me on this...
« Reply #8 on: March 26, 2016, 10:27:15 pm »

It does make sense, and it also works. Pretty brilliant.

I knew it'd be some weird workaround like this, and you figured it out and nailed it, again. Getting counter() to work as intended + the Relational 'storing one value per album' were the keys.


Excellent job, and thank you.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Gurus please help me on this...
« Reply #9 on: March 27, 2016, 12:54:42 am »

Glad it works.  I keep thinking about doing something similar ever since the big points expression, but with actual chart ratings (I don't use ratings for myself and won't start now).  It would be cool to see my # plays and even stats like DR compared to chart #'s

But I'm way too lazy to try and pull all that data for all my albums
Logged
Pages: [1]   Go Up