INTERACT FORUM

Please login or register.

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

Author Topic: Auto rate tracks based on number of plays  (Read 9939 times)

djfalstaff

  • Recent member
  • *
  • Posts: 43
Auto rate tracks based on number of plays
« on: January 04, 2017, 12:44:11 pm »

Is it possible to auto rate tracks so the track rating tags gets updated after a certain number of play counts?
For example,
0 to 2 plays - no stars
2 to 5 plays - one star
5 to 6 plays - two stars
7 to 8 plays - three stars
9 to 10 plays - four stars
> 10 plays - five stars
Logged

~OHM~

  • Citizen of the Universe
  • *****
  • Posts: 1825
  • "I Don't Play The Music The Music Plays Me"
Re: Auto rate tracks based on number of plays
« Reply #1 on: January 04, 2017, 10:09:42 pm »

I have no clue. I'm guessing no reply means it's not possible.
Logged
“I've Reached A Turning Point In My Life. I Now Realize I Have More Yesterdays Then Tomorrows”

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Auto rate tracks based on number of plays
« Reply #2 on: January 05, 2017, 02:35:51 am »

It's not possible to auto-update the content of normal tags in this way, however you could create your own rating tag and make it a calculated expression based on your requirements.  That is entirely possible.


Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Auto rate tracks based on number of plays
« Reply #3 on: January 05, 2017, 03:33:11 am »

the best currently possible way (IMO) to do it, is in a smartlist.  every so often, just open and close the smartlist and the updates will take place.
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Auto rate tracks based on number of plays
« Reply #4 on: January 05, 2017, 04:19:06 am »

Smartlists cannot write tags...?

If you want data fields to update you have to do it manually. 



Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Auto rate tracks based on number of plays
« Reply #5 on: January 05, 2017, 08:09:55 am »

Mark's idea is the best IMHO.  I just tested it and it works great.  I made a new field called:
Rating (calculated)

I set it up as an Integer type with an Edit Type of Five Stars.  Then I made it Calculated Data and used this expression:

Code: [Select]
IfElse(Compare([Number Plays],>=,3),5,
Compare([Number Plays],>=,2),4,
Compare([Number Plays],>=,1),3,
Compare([Number Plays],<,1),1
)

This is a very simple and naive mapping that makes 3 or greater plays equal to 5 stars, 2 plays equal 4 stars, 1 play equals 3 stars, and no plays is 1 star.  Change the values as  you'd like to get the mapping you want.

Good Luck.

Brian.
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #6 on: January 05, 2017, 09:28:32 am »

The calculated field seems like a solid idea.
I would like to translate that calculated back into the the standard field at some point, though.
Does anyone know of a tag writer program that let's you create updates based on some logic?
 
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Auto rate tracks based on number of plays
« Reply #7 on: January 05, 2017, 11:05:50 am »

Simplest way is to just create a smartlist that shows the source and destination fields.  Then you just CTRL-A to select the entire dataset and F2 to open a destination field for editing and you'd enter =[source field] (whatever the field is called) and it will copy every field from the source to the destination as long as all are selected.
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #8 on: January 05, 2017, 01:12:23 pm »

Your suggestions actually gave me an idea and I'm hoping that you all wouldn't mind helping me by translating it into an expression.
I'm thinking of returning just a number instead of using stars.
The basis being this
Code: [Select]
IfElse(Compare([Number Plays],>=,10),100,
Compare([Number Plays],=,9),90,
Compare([Number Plays],=,8),80,
Compare([Number Plays],=,7),70,
Compare([Number Plays],=,6),60,
Compare([Number Plays],=,5),50,
Compare([Number Plays],=,4),40,
Compare([Number Plays],=,3),30,
Compare([Number Plays],=,2),20,
Compare([Number Plays],=,1),10,
Compare([Number Plays],<,1),0
)
Then adding some modifiers to the base number.

If the Artist is in a list of my favorite and most trusted artists (could I store a list of 30 or so somewhere?)then add + 20

If the genre contains the word Progressive or Metal + 10
If the Ratings field has 4 stars +5
If the Ratings field has 5 stars +10
If the track is in more than two playlists + 10
if the track is in more than three playlists + 20
if the track is in more than five playlists + 50

Thanks in advance!

 

Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Auto rate tracks based on number of plays
« Reply #9 on: January 06, 2017, 03:17:03 am »

Not sure about the playlists test, but the rest is doable.  Just wrap multiple IfElse rules inside the math() rule, eg

math(IfElse(ruleset1) + IfElse(ruleset2) + IfElse(ruleset3))

http://wiki.jriver.com/index.php/Expression_Language
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #10 on: January 06, 2017, 03:50:06 am »

We've been discussing about automatic ratings lately on those threads, where you'll certainly find some ideas :

http://yabb.jriver.com/interact/index.php/topic,108605.msg752569.html
http://yabb.jriver.com/interact/index.php/topic,108564.msg751975.html
http://yabb.jriver.com/interact/index.php/topic,100596.msg697624.html#msg697624

With those informations and the great help of other members, I've been able to automatically rates my albums with a formula based on both album's rating and album's number plays. If this may interest you I'll post some details here tonight.

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #11 on: January 06, 2017, 08:34:30 am »

I am interested. It makes me wish for a special section of the forum or wiki just for expression recipes.
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #12 on: January 06, 2017, 11:38:06 am »

Is it possible to auto rate tracks so the track rating tags gets updated after a certain number of play counts?
For example,
0 to 2 plays - no stars
2 to 5 plays - one star
5 to 6 plays - two stars
7 to 8 plays - three stars
9 to 10 plays - four stars
> 10 plays - five stars

As you're talking about tracks rating, what you're asking for can very easliy be done with search lists :

- In a category view, add a category.
- Then edit it and select "search list" as a type.
- "Add" an item and call it "*"
- In the "Rule" above select "Number played" then "Is less than" then "3"
- In the "Rule" above select "Number played" then "Is more than" then "0"
- Repeat for each conditions you need.

Et voilà ! :)
You'll have all your tracks sorted by "ratings" (see picture. I've been too lazy to do all rules)

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #13 on: January 06, 2017, 11:38:52 am »

It makes me wish for a special section of the forum or wiki just for expression recipes.

Yes ! This would be really great, I totally second you on that !

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #14 on: January 06, 2017, 12:03:32 pm »

I am interested.

Automatic rating of an Album based on rates and number plays

Ferday, Mark_h, blgentry and few other users have been very helpful on this topic. They have done all the job, not me  ;)

My initial wish was to generate a rating per album (and no per tracks as it is by default in MC). This rating would be an average of all tracks rated in this album (Sum of ratings / number of tracks).

Then I thought also that the number of time an album have been played should have an influence on the global rating of this album. This "Album number plays" is calculated this way : sum of Number plays of each tracks within an album / number of tracks of this album.

So my final formula for my Album_rating is : (Album_sum_rating+Album_sum_Number_plays)/Number_of_tracks

I personnaly prefer using "views" rather than "smartlists" but this works the same for both. I'll explain for "views".

1. Create a view, call it "Album Rating" (you could name it "Bob Dylan" too, it will work the same)
2. Then "Customize view"
3. "Set rule for file display"
4. Import /export

paste this :
Code: [Select]
[=save(0,var_number_of_tracks[album artist (auto)][album])1]=1 [=save(0,var_plays_sum[album artist (auto)][album])1]=1 [=save(0,var_points_sum[album artist (auto)][album])1]=1 [=save(0,var_album_plays[album artist (auto)][album])1]=1 [=save(0,var_album_points[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(formatnumber([Number Plays, 0])+load(var_plays_sum[album artist (auto)][album])),var_plays_sum[album artist (auto)][album]),)1]=1 [=if(compare([rating],<,1), save([rating]+load(var_points_sum[album artist (auto)][album])),var_points_sum[album artist (auto)][album]), save(math(([rating] - 2)*3 + load(var_points_sum[album artist (auto)][album])),    var_points_sum[album artist (auto)][album]))1]=1 [=save(math(load(var_plays_sum[album artist (auto)][album]) / load(var_number_of_tracks[album artist (auto)][album])),var_album_plays[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 [Media Type]=[Audio] ~sort=[Media Type],[Sequence],[Album Artist (auto)],[Album],[Disc #],[Track #],[Name] ~a
5. In "Tools>Options>Library and Folders>Manage Library Fields"
6. Add new field
7. Name it "AA_Album_Rating" (Still works with "Bob Dylan" too, but could be confusing. "AA_" is just to have custom fields on beginning of the list)
8. Check "Calculated data"
9. Paste this :

Code: [Select]
=FormatNumber(math((load(var_plays_sum[album artist (auto)][album])+load(var_points_sum[album artist (auto)][album])) / (load(var_number_of_tracks[album artist (auto)][album]))), 0)
Et voilà !
Now you can use your "AA_Album_Ratings" field in your view pane !



djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #15 on: January 06, 2017, 12:49:19 pm »

I'm trying to work this out and learn the system as I go along. I want the expression to be easy to read and manage.

In a smart list, I'm creating an expression field called "Auto Rating".
Inside that, I'm putting the following calculations.

First, I want a base Point amount from play counts saved in a global variable called basePoints.

UPDATED: based on feedback in the replies to be shorter

Code: [Select]
save(math([Number Plays] * 10, basePoints))

UPDATED: based on feedback, I going to handle Favorite Artists in the following way.
I created a new library field called "IsFavoriteArtist" that is an integer with 0 and 1 for the allowed values and it is set to write the value into the file.

Code: [Select]
  save(if(isequal([IsFavoriteArtist], 1, 2), 50, 0),favoriteArtistBonus)

After that, I'll create a list of favorite genres
Should this be stored here or would it make more sense for this to be a library field?
Code: [Select]
save(
listbuild(1, ;,
Progressive,
Metal)
, favoriteGenres)

I need to take the favoriteGenre list and compare it against the Genre field.
If the Genre field contains the string from the list then apply the bonus.
I don't know how to do this.

Code: [Select]
  save([something goes here], favoriteGenreBonus)

Then I want to store my ratings bonus

Code: [Select]
save(
IfElse(
Compare([Rating],>=,5),10,
Compare([[Rating],=,4),5,
Compare([Rating],<=,3),0
)
, ratingsBonus)

Then I want the playlist bonus (not sure how to do this)
When you look at the tags for a track, the Playlists tag lists all the manual playlists the track is in.
I'm just not sure on how you access this and get the count.
Code: [Select]
  save([something goes here], playlistBonus)

Finally, I want to add them together and return the final point value

Code: [Select]
math(load(basePoints) + load(favoriteArtistBonus) + load(favoriteGenreBonus) + load(ratingsBonus) + load(playlistBonus))

Some examples

Journey - Don't Stop Believin' with a play count of 24,a rating of 5, and is in 6 manual playlists
100 + 20 + 0 + 10 + 50 = 180

Nightwish - Everdream with a play count of 4, a rating of 5, and a genre of Symphonic Metal
40 + 20 + 10 + 10 + 0 = 80

Rush - Limelight with a play count of 5, a rating of 5, and a genre of Progressive Rock
50 + 20 + 10 + 10 + 0 = 90
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #16 on: January 06, 2017, 02:32:13 pm »


Code: [Select]
save(
IfElse(Compare([Number Plays],>=,10),100,
Compare([Number Plays],=,9),90,
Compare([Number Plays],=,8),80,
Compare([Number Plays],=,7),70,
Compare([Number Plays],=,6),60,
Compare([Number Plays],=,5),50,
Compare([Number Plays],=,4),40,
Compare([Number Plays],=,3),30,
Compare([Number Plays],=,2),20,
Compare([Number Plays],=,1),10,
Compare([Number Plays],<,1),0
)
, basePoints)

This could be simplified into :

Code: [Select]
save(math([Number Plays] * 10, basePoints))

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #17 on: January 06, 2017, 02:44:27 pm »

I updated it with your suggestion.
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #18 on: January 06, 2017, 03:25:29 pm »

I can see two ways to create your favoriteArtistBonus (or favoriteGenreBonus) :

One is by using a IfElse(compare... expression but this can be a little bit tedious to build and to maintain.

Another one is by creating a integer FavoriteArtist field with two values allowed (0/1). 0 is default. You tag it to 1 when it is your favorite Artist/genre
Then when you want to calculate your rating you can easily do that :

MyRating = Playcount*10 + trackrating + FavoriteArtist*10 + Favoritegenre*10

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #19 on: January 06, 2017, 06:13:03 pm »

That makes sense for Favorite Artist.
The Favorite Genre would be too much of a pain.
People keep inventing new types of metal and I just don't feel like keeping up with that.
A fuzzy search against the keywords Metal and Progressive will give me what I want without having to upkeep it.
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #20 on: January 06, 2017, 06:33:01 pm »

I updated my post to reflect the changes we talked about.
I just to figure out the Favorite Genre and Count of playlists to give it a try.
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #21 on: January 07, 2017, 01:20:43 am »

I'm trying to put it all together minus the playlist count but I get a syntax error and I'm not sure what I did wrong.

I save my variables so I can easily tweak them when I need to.
Code: [Select]
save(10 , genrePointValue)
save(5, fourStarValue)
save(10 , fiveStarValue)
save(50 , favArtistValue)

get my base points
Code: [Select]
save(math([Number Plays] * 10, basePoints))
Get the favorite artist bonus.
Code: [Select]
save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue)), 0),favoriteArtistBonus)
Get the ratings bonus
Code: [Select]
save(
IfElse(
Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),
Compare([[Rating],=,4),formatnumber(load(fourStarValue)),
Compare([Rating],<=,3),0
)
, ratingsBonus)
use the formula to get the final value
Code: [Select]
math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) + formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus)))
I get a syntax error and here's the expression as one snippet
Code: [Select]
save(10 , genrePointValue)
save(5, fourStarValue)
save(10 , fiveStarValue)
save(50 , favArtistValue)
save(math([Number Plays] * 10, basePoints))
save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue)), 0),favoriteArtistBonus)
 save(
  ifelse(isequal([Genre],Metal, 8), formatnumber(load(genrePointValue)),
isequal([Genre],Progressive, 8), formatnumber(load(genrePointValue)), 1, 0)
 , favoriteGenreBonus)
  save(
IfElse(
Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),
Compare([[Rating],=,4),formatnumber(load(fourStarValue)),
Compare([Rating],<=,3),0
)
, ratingsBonus)
 math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) + formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus)))
 
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #22 on: January 07, 2017, 02:23:18 pm »

I'm certainly not the best person to help you on that kind of thing. Variable and expression are still very new and very confusing to me  ::) ::) ::)
...but, I believe there is a parenthesis error in this expression :

Code: [Select]
save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue)), 0),favoriteArtistBonus)
it should be :

Code: [Select]
save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue), 0)),favoriteArtistBonus)
instead. Not sure it will solve your problem though.

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #23 on: January 07, 2017, 03:02:12 pm »

This is what I'm using for my calculation. I believe it's close enough to what you would like to achieve to allow you to adapt it to your needs.

I've added a line for 'genre' bonus. It add 1000 if genre = "Métal" (I'm not THAT crazy of metal  ;D, even if I really like a LOT bands like Dream Theater, Haken, Leprous, Riverside, but it was for testing purpose).

Code: [Select]
[=save(0,var_number_of_tracks[album artist (auto)][album])1]=1
[=save(0,var_plays_sum[album artist (auto)][album])1]=1
[=save(0,var_points_sum[album artist (auto)][album])1]=1
[=save(0,var_album_plays[album artist (auto)][album])1]=1
[=save(0,var_album_points[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(formatnumber([Number Plays, 0])+load(var_plays_sum[album artist (auto)][album])),var_plays_sum[album artist (auto)][album]),)1]=1
[=if(compare([rating],<,1), save([rating]+load(var_points_sum[album artist (auto)][album])),var_points_sum[album artist (auto)][album]), save(math(([rating] - 2)*3 + load(var_points_sum[album artist (auto)][album])),    var_points_sum[album artist (auto)][album]))1]=1
[=if(isEqual([genre],Métal,1), save(math(load(var_points_sum[album artist (auto)][album]) + 1000),var_points_sum[album artist (auto)][album]), save(load(var_points_sum[album artist (auto)][album]), var_points_sum[album artist (auto)][album]))1]=1
[=save(math(load(var_plays_sum[album artist (auto)][album]) / load(var_number_of_tracks[album artist (auto)][album])),var_album_plays[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
[Media Type]=[Audio] ~sort=[Media Type],[Sequence],[Album Artist (auto)],[Album],[Disc #],[Track #],[Name] ~a

Number of plays is calculated by this line :
Code: [Select]
[=save(math(formatnumber([Number Plays, 0])+load(var_plays_sum[album artist (auto)][album])),var_plays_sum[album artist (auto)][album]),)1]=1
The rating bonus is calculated by this line :
Code: [Select]
[=if(compare([rating],<,1), save([rating]+load(var_points_sum[album artist (auto)][album])),var_points_sum[album artist (auto)][album]), save(math(([rating] - 2)*3 + load(var_points_sum[album artist (auto)][album])),    var_points_sum[album artist (auto)][album]))1]=1I consider that
 - rating '0' mean I've not yet evaluated the song
 - rating '1' is bad (malus value = -1)
 - rating '2' is neutral (bonus value = 0)
 - rating '3' is good (bonus value = 1)
 - rating '4' is very good (bonus value = 2)
 - rating '5' is exceptional (bonus value = 3)

Genre bonus is calculated by this line :
Code: [Select]
[=if(isEqual([genre],Métal,1), save(math(load(var_points_sum[album artist (auto)][album]) + 1000),var_points_sum[album artist (auto)][album]), save(load(var_points_sum[album artist (auto)][album]), var_points_sum[album artist (auto)][album]))1]=1
Then, I just need to create a field with this expression :
Code: [Select]
=FormatNumber(math((load(var_plays_sum[album artist (auto)][album])+load(var_points_sum[album artist (auto)][album])) / (load(var_number_of_tracks[album artist (auto)][album]))), 0)
Keep in mind that my initial purpose was to get a rating per album.

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #24 on: January 07, 2017, 04:01:55 pm »

I have a simple a question.
Your global variables look like this.

Code: [Select]
[=save(0,var_number_of_tracks[album artist (auto)][album])1]=1

Code: [Select]
save(10 , genrePointValue)

Yours starts with "[=" and end with "]=1".
What effect does that have?

Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Auto rate tracks based on number of plays
« Reply #25 on: January 07, 2017, 05:51:15 pm »

You need to use his format!

but you can declare and save multiple in one statement

 Please read here for a better idea on the variables as used in MC

http://yabb.jriver.com/interact/index.php/topic,77826.msg528415.html#msg528415
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #26 on: January 07, 2017, 06:05:36 pm »

I think I see the issue now but what does this missing syntax represent?
I'm trying to fully understand the syntax so I don't have to just copy the work of others.

Code: [Select]
[=
save(10 , genrePointValue)
save(5, fourStarValue)
save(10 , fiveStarValue)
save(50 , favArtistValue)
save(math([Number Plays] * 10, basePoints))

save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue)), 0),favoriteArtistBonus)

 save(
  ifelse(isequal([Genre],Metal, 8), formatnumber(load(genrePointValue)),
isequal([Genre],Progressive, 8), formatnumber(load(genrePointValue)), 1, 0)
 , favoriteGenreBonus)
 
  save(
IfElse(
Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),
Compare([[Rating],=,4),formatnumber(load(fourStarValue)),
Compare([Rating],<=,3),0
)
, ratingsBonus)
1]=1

Is it initializing the variables?
Will the following code if appended to the previous output my formula or this this part missing something too?

Code: [Select]
math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) + formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus)))

Also, can you put comments in your code? I didn't see any in the spec.

Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Auto rate tracks based on number of plays
« Reply #27 on: January 07, 2017, 06:18:06 pm »

good question!  honestly i've never really *truly* sorted the syntax out myself.  i just refer to my notes which come from that linked thread, and go from there. 

IMO it's best to save the variable at the most basic level possible and do calculations at load time if possible

Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #28 on: January 07, 2017, 07:29:21 pm »

 I got a little further.
This seems to get parsed without error but it doesn't display anything but "..." instead of a number.

Code: [Select]
[=
save(10 , genrePointValue)
save(5, fourStarValue)
save(10 , fiveStarValue)
save(50 , favArtistValue)
save(math([Number Plays] * 10), basePoints)

save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue), 0)),favoriteArtistBonus)

 save(
  ifelse(isequal([Genre],Metal, 8), formatnumber(load(genrePointValue)),
isequal([Genre],Progressive, 8), formatnumber(load(genrePointValue)), 1, 0)
 , favoriteGenreBonus)
 
  save(
IfElse(
Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),
Compare([[Rating],=,4),formatnumber(load(fourStarValue)),
Compare([Rating],<=,3),0
)
, ratingsBonus)
1]=1

 =formatnumber(math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) +
 formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus))))
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Auto rate tracks based on number of plays
« Reply #29 on: January 08, 2017, 08:38:06 am »

A few answers and suggestions:

I'm not great at developing these expressions.  But my normal method is to use expression columns.  They allow you to do edits a little faster than smartlist (or views) definitions.  It's still not "fast", but it's a little quicker.

I tend to develop the expressions themselves in a text editor and then cut and paste.  Again, this helps a little with speed and consistency.

Global variables are pretty unusual; as ferday said, I generally use a form that I've seen repeated in other posts and build on that form.  That form being that you seem to need to build a variable twice for some reason.  You generally see them done in pairs:  One statement to initialize the variable and a second to populate it with a value.  I think.  As I said, I don't claim to have deep understanding of how it all works.

When you get "..." that generally seems to mean that your value is of the wrong type, or not displayable or something like that.  I've had this behavior from time to time where it would produce normal looking output most of the time, but then give me "..." for some instances.  I can't decide if it means "MC can't display this because it's too big", or "MC can't display this because it's not the right type", or something else.

As with most programming, when you run into unusual behavior, it's best to back off and start with the core code.  Then add on piece by piece until it breaks.  Then you normally will have found the code that has the problem in it.

I don't think MC's expression language supports comments.  The Expression Language does some really neat stuff.  But it's not a fully formed programming language.  It's still VERY useful.  It's just limited in some respects.

Good luck.

Brian.
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #30 on: January 08, 2017, 08:52:44 am »

I tend to develop the expressions themselves in a text editor and then cut and paste.  Again, this helps a little with speed and consistency.

I do to. I quickly become confused when there's more than 2 parenthesis in my expression  ;D
I'm using Notepad++ which is a great help (for highlighting parenthesis for instance).

I wish someone could take some time to add MC "language" characteristic into Notepad++. I believe it's possible and it would be a tremendous help to developp expressions.

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #32 on: January 08, 2017, 09:24:01 am »

If I hover over it the column, the tooltip has the right number value but it doesn't display otherwise.
Honestly, I'd be happier if it was broken instead of it taunting me by almost displaying.
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #33 on: January 08, 2017, 09:53:00 am »

I came up with a simple test to highlight the issue.

I made two expression columns

Code: [Select]
math(10 + 5 + 10 + 50 + 20)

This one display the number properly

Code: [Select]
save(10    , var1)
save(5, var2)
save(10    , var3)
save(50    , var4)
save(math(2 * 10), var5)

math(load(var1) + load(var2) + load(var3) + load(var4) + load(var5))

This one gives you the right number when you hover over it but it doesn't display.
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #34 on: January 08, 2017, 10:38:47 am »

You have to write it on 1 line :

Code: [Select]
=save(10    , var1) save(5, var2) save(10    , var3) save(50    , var4)  save(math(2 * 10), var5) math(load(var1) + load(var2) + load(var3) + load(var4) + load(var5))
In fact, MC displayed exactly what you wrote, including the line break..

The expression column interpret litterally what you write in it.

This :
Code: [Select]





math(10 + 5 + 10 + 50 + 20)

will cause the same display problem.

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Auto rate tracks based on number of plays
« Reply #35 on: January 08, 2017, 10:57:21 am »

So the "..." must mean "line break embedded", or "line too long" because it contains a line break.  This is no doubt what I was seeing before.  Interesting.

Brian.
Logged

Cmely

  • Junior Woodchuck
  • **
  • Posts: 78
Re: Auto rate tracks based on number of plays
« Reply #36 on: January 08, 2017, 11:33:53 am »

So the "..." must mean "line break embedded", or "line too long" because it contains a line break.  This is no doubt what I was seeing before.  Interesting.

Brian.

I don't know. If you type this expression :
Code: [Select]




math(10 + 5 + 10 + 50 + 20)

You won't have any '...' (at least I don't have). Just an empty column and if you hover, you get the tooltip with the correct result.
I would say that the "..." is more likely a "invalid argument" thing or something similar.

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #37 on: January 08, 2017, 12:47:49 pm »

This display the right number but the formatting is messed up. It display things like "[70]..."
I won't be able to sort properly until it outputs a number correctly.

Code: [Select]
=save(10    , genrePointValue) save(5, fourStarValue) save(10    , fiveStarValue) save(50    , favArtistValue) save(math([Number Plays] * 10), basePoints)  save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue), 0)),favoriteArtistBonus)   save(      ifelse(isequal([Genre],Metal, 8), formatnumber(load(genrePointValue)),     isequal([Genre],Progressive, 8), formatnumber(load(genrePointValue)), 1, 0)  , favoriteGenreBonus)           save(             IfElse(             Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),             Compare([[Rating],=,4),formatnumber(load(fourStarValue)),             Compare([Rating],<=,3),0             )     , ratingsBonus) {math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) +  formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus)))]
Logged

djfalstaff

  • Recent member
  • *
  • Posts: 43
Re: Auto rate tracks based on number of plays
« Reply #38 on: January 08, 2017, 01:02:11 pm »

I finally got it to display right but I just don't why it worked.

Code: [Select]
=[save(10    , genrePointValue) save(5, fourStarValue) save(10    , fiveStarValue) save(50    , favArtistValue) save(math([Number Plays] * 10), basePoints)  save(if(isequal([IsFavoriteArtist], 1, 2), formatnumber(load(favArtistValue), 0)),favoriteArtistBonus)   save(      ifelse(isequal([Genre],Metal, 8), formatnumber(load(genrePointValue)),     isequal([Genre],Progressive, 8), formatnumber(load(genrePointValue)), 1, 0)  , favoriteGenreBonus)           save(             IfElse(             Compare([Rating],>=,5),formatnumber(load(fiveStarValue)),             Compare([[Rating],=,4),formatnumber(load(fourStarValue)),             Compare([Rating],<=,3),0             )     , ratingsBonus) math(formatnumber(load(basePoints)) + formatnumber(load(favoriteArtistBonus)) +  formatnumber(load(favoriteGenreBonus)) + formatnumber(load(ratingsBonus)))
Logged
Pages: [1]   Go Up