INTERACT FORUM
More => Old Versions => JRiver Media Center 20 for Windows => Topic started by: Saucepan on October 03, 2015, 12:21:30 pm
-
Hi all,
I'm trying to create a Library Field that will do some math for me.
The field will be called Points. The math that needs to be done is simple: [Number Plays] + ([Rating] * [Duration]).
What function or expression do I use, and how do I make the field return that number?
Thank you for reading.
-
I'm assuming you want the duration to be expressed in decimal minutes right? So 3:30 would be 3.5 (three and a half minutes). As a full example, a song that has 7 plays, a rating of 4, and a duration of 3:30 would be:
Points = 7 + (4 * 3.5) = 21
If that's correct, here's an expression to do it:
math([Number Plays] + ( [Rating] * [Duration,0]/60 ))
I would try it as an expression column first. Get it working the way you want, then copy the expression and put it into your calculated field.
Good luck.
Brian.
-
math([number plays]+[rating]*[duration]-0)
if any of those fields are empty, the math will fail although the -0 at the end seems to sort a lot of those weird problems
if you get an issue, try
math(formatnumber([number plays])+formatnumber([rating])*formatnumber([duration]))
edit: of course blgentry beat me to it, he's got a good point about the duration! but don't forget the formatnumber and/or the -0 otherwise an empty field will ruin the expression
-
Perfect.
I had figured out that it was the Math function while waiting for replies, but I couldn't get [duration] working properly until you guys chimed in. I appreciate this very much.
-
I have a new problem...
Now that Points works right, it won't display the way I want it to.
In a Library View, if there's more than one value, Media Center displays Points as '[Varies]'.
How do I get MC to tally the points up and display the total?
-
Ugh. That's a really different problem.
What are you adding? For example, do you mean adding all the track "points" over an album?
This requires variables, I can probably help but need really specific details on what you are trying to add up (and what is the "total")
-
Points over an Album, yes.
I'd like it to display similar to how MC displays the total Number of Plays (i.e. '73 total plays').
I appreciate the help, and will definitely use it...but if it's a headache please don't bother!
-
ha ha sorry don't mean it like that.
do you want the sum of all the track points, or the average points per track per album?
-
The sum.
-
...
-
Followed your steps:
The Expression column just displays:
0
-
smartlist import/export
[=save(0,var_number_of_tracks[album artist (auto)][album])1]=1 [=save(0,var_points_sum[album artist (auto)][album])1]=1 [=save(math(1+load(var_number_of_tracks[album artist (auto)][album])),var_number_of_tracks[album artist (auto)][album])1]=1 [=save(math([points]+load(var_points_sum[album artist (auto)][album])),var_points_sum[album artist (auto)][album])1]=1 [=save(math(load(var_points_sum[album artist (auto)][album]) / load(var_number_of_tracks[album artist (auto)][album])),var_album_points[album artist (auto)][album])1]=1 ~sort=[points]-d,[Media Type],[Album Artist (auto)],[Album],[Disc #],[Track #],[Name]
expression column
load(var_points_sum[album artist (auto)][album])
so far some basic testing seems to be working...
ok i've done some testing and hand calculations and it seems to work as long as all of the fields (number played, etc.) have real values in them..
-
It's working for me as well. This is frickin' incredible.
-
Just for fun, the code also includes an average
So if you use
load(var_album_points[album artist (auto][album])
In the expression column it will give you the sum/# tracks for an album points average (well, it should ha ha variables are hard)
Just a note: the variables are global, so if you make a custom field that uses the load(...) codes, you can see them in normal views! However when you import new tracks or increase play counts by listening, you must refresh the smartlist for the numbers to recalculate
-
Many thanks again, this is super super good stuff (for me at least).
I tweaked the initial equation to fit my specific needs (Note: I took track duration out of the equation for now)
math((formatnumber([Rating]) * 20) + (formatnumber([number plays]) * 5))
-
formatnumber([duration]/60))
That won't work. formatnumber() doesn't do math, so the divide doesn't happen. You want this instead:
formatnumber([Duration,0])/60
Brian.
-
so the OP asked for a revision, i think there's always value in making these things public in case someone else can learn from it
he wanted the totals to change by -75 if the rating was 2, and by -100 if the rating was 1
so, brief testing says that this works. to the OP or anyone that tries it, let us know that it does what you want
ifelse(isequal([rating],2,2),math((formatnumber([rating])*20)-75+(formatnumber([number plays])*5)),isequal([rating],1,2),math((formatnumber([rating])*20)-100+(formatnumber([number plays])*5)),1,math((formatnumber([rating])*20)+(formatnumber([number plays])*5)))
-
First off, thank you to Ferday for basically making this happen. Absolutely amazing.
So...
Further tweaks to give weight to every rating and play-based-on-rating. It's getting pretty accurate now.
I simplified the code a bit.
Here's the breakdown:
5 star songs: get 100 points
Each play from a 5 star song: gets 10 extra points
4 star songs: get 80 points
Each play from a 4 star song: gets 7 extra points
3 star songs: get 30 points
Each play from a 3 star song: get 5 extra points
2 star songs: take away 75 points
Each play from a 2 star song: takes an extra 5 points away
1 star songs: take away 100 points
Each play from a 1 star song: takes an extra 10 points away
0 star songs: no points
Each play from a o star song: get 2 extra points
Here's the code, that will determine every tracks' Points:
ifelse(isequal([Rating],0,2),math(((formatnumber([number plays]) * 2))),isequal([Rating],4,2),math((80 + (formatnumber([number plays]) * 7))),isequal([Rating],5,2),math((100 + (formatnumber([number plays]) * 10))),isequal([Rating],3,2),math(30 + (formatnumber([number plays]) * 5)),isequal([Rating],2,2),math(-75 - (formatnumber([number plays]) * 5)),isequal([Rating],1,2),math(-100 - (formatnumber([number plays]) * 10)))
Additionally, you can create a Field called LP Points that will tally up the score of every track and display the Point total per LP!
Type this into the Expression Field while creating that: load(var_points_sum[album artist (auto)][album])
Why bother?
Because it takes album ratings a step further by being more specific with your ratings and plays. Using this will tell you what your best albums are, what's moving up and down in your library...and what you need to get rid of. All you need to do is rate your songs as you listen to them and then it will take shape.
KEEP THAT SMARTLIST OPEN IN AN EXTRA PANE. It needs to refresh to tally everything up. Very important.
Final Note:
I didn't realize how bad Black Sabbath's Vol. 4 was! And now I do. Holy hell.
-
Hi Marko thanks for replying.
---
What I'm trying to do, and I've been bugging ferday about this for a few days (poor guy!), is to try to create a variable that will take a field I've made, and assign an order to the values (1 for the highest value, 2 for the next highest and so on) that will change every time the list is refreshed.
It's basically a way to take my albums and say 'this one is #1, this one is #2, this one is #3 etc...Almost like a Seq for my records that changes every time I change a rating of a track.
The field is called LP Points. Thanks to ferday, who is amazing, I've got it working exactly how I want.
The last step of this whole thing is to list those values, top to bottom. I'm a huge fan of charts...
Any ideas you can add to this are extremely appreciated.
Global variables are not what you would call a forte of mine, so I am not really sure if that can be achieved that way or not. I tried a couple of ideas here, using MarkH's variable based [album rating] field, playing around with counter() and customdata(#) but ran into dead ends, brick walls and redundancy.