INTERACT FORUM

Please login or register.

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

Author Topic: Sorting by Expression Issue (Performance) - Advice/Guidance needed  (Read 785 times)

Bob007

  • Regular Member
  • Recent member
  • *
  • Posts: 45
  • nothing more to say...

I have the following issue that I was wondering if anyone had any advice/guidance on (including "don't do that, it's stupid" :-\).  It's not critical but it's been bugging me and I'm likely to give up on it unless the greater good can advise...

I have a custom calculated field as follows that shows average plays per album (...or at least my interpretation of it).

  FormatNumber(Math(GroupSummaryQuery(Album, Number Plays,1) / GroupSummaryQuery(Album, Track #)),1)

I then use that field to reverse sort some of my playlists, so that I can essentially keep track of albums that I've not played a lot etc. - example below - it's the middle thumbnail text.

 

The issue I have is that it's a demand on resources (I assume each screen refresh/update is making the calculation run) and it takes a good 40+ seconds to update a view against a small subset of circa 100 albums.

Does anyone have any advice on this?  A different approach or a workaround?

- Thanks.

Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #1 on: August 26, 2021, 08:32:58 am »

It's not a popular answer but using global variables I think that your view will load almost instantly and scrolling performance is no different than any other view.

It's a little work though to make first a smartlist which does the calculation per artist-album and then utilize playlist in the view to get the data.

For sorting I think that easiest way is to make new calculated library field which takes value from the playlist calculation. Took me ~20 min to create this without earlier thinking
Logged

Bob007

  • Regular Member
  • Recent member
  • *
  • Posts: 45
  • nothing more to say...
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #2 on: August 26, 2021, 09:16:07 am »

Thanks for responding, lepa.  Can you clarify what you mean by the following?  I don't see a way to do the calculation within a smartlist.

It's a little work though to make first a smartlist which does the calculation per artist-album
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #3 on: August 26, 2021, 10:17:29 am »

You can e.g. create following smartlist which takes all audio files which belongs to complete album and calculates dynamic field values aka global variables for every file. You can of course limit playlist to handle smaller amount of files by filtering it to your likings,

First initialize variables to 0 and then calculate values

v_track variable now contains total track count for [Album Artist (auto)][Album]
v_albumPlayedSUM contains summed playcounts of every file for [Album Artist (auto)][Album]

Import for playlist:
Code: [Select]
[Media Type]=[Audio] [Complete Album]=1 [=Save(0,v_Tracks[Album Artist (auto)][Album])1]=1 [=Save(0,v_AlbumPlayedSUM[Album Artist (auto)][Album])1]=1 [=SaveAdd(v_Tracks[Album Artist (auto)][Album],1)SaveAdd(v_AlbumPlayedSUM[Album Artist (auto)][Album],[Number Plays])1]=1
New Field to contain play count for album:
Field name: Album Play Count (calculated)
Rule: FormatNumber(Math(Load(v_AlbumPlayedSUM[Album Artist (auto)][Album]) / Load(v_Tracks[Album Artist (auto)][Album])),1)

Then you create (or go to your current) view which takes that just created playlist as a source data in the "set rule..." (see the picture). Sort by Album Play Count (calculated )Z-A.

Attached also ready made view which has info how to create smartlist and library field. This view shows every album but you can use that smart list data in every view you want



Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #4 on: August 26, 2021, 10:24:23 am »

FYI - Here is some of the original work on global variables, done by the master Mr C.

https://yabb.jriver.com/interact/index.php?topic=77826.0

Logged

Bob007

  • Regular Member
  • Recent member
  • *
  • Posts: 45
  • nothing more to say...
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #5 on: August 26, 2021, 10:30:30 am »

Thanks again, lepa.  I shall have a play around tonight/tomorrow.

Thanks for the link, dtc.  I did run a 'search' when I first encountered the issue but I've not seen this thread.

Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #6 on: August 26, 2021, 10:32:55 am »

If JRiver would add [Album Artist (auto)][Album] combination to Relational rules in the Manage Library fields it would be easier to create this kind of statistic. Then you could make field [album played] which could be made to update automatically after playing the file and all the songs for that album would get that same value.

Album is in relational rule list but I'm not sure if it just uses album name or artist and album combination. If it uses actual album key as Relation then that approach would be best and actually quite nice statistical feature


E: it is actually album key so if you have total tracks already tagged for the album then this can be easily updated in the new "After playback expression" feature
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #7 on: August 26, 2021, 10:38:14 am »

There is a lot of text in my post but if you are lazy you can just:

1. Create smartlist like in the picture by using that Import / export and paste my import text
2. Create new field: name and rule can be again copy pasted
3. Install .jvi attached to the post to get the view
4. If sorting is lost in the view. sort the view again with the new field
Logged

Bob007

  • Regular Member
  • Recent member
  • *
  • Posts: 45
  • nothing more to say...
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #8 on: August 26, 2021, 11:05:30 am »

If JRiver would add [Album Artist (auto)][Album] combination to Relational rules in the Manage Library fields it would be easier to create this kind of statistic.

It was the default behaviour for the [Number Plays] field for MC releases up to and including v18. That is, the 'grouped' display view for [Number Plays] was shown as an Average - see image.  From v19 onwards, this changed to a Total summary. 

Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #9 on: August 26, 2021, 11:54:49 am »

Okay this whole thingy can be achieved with "After Playback Expression" and after it is set there is no need for any variables or slow group calculations.

Code: [Select]
After Playback expression: [code]SetField(Play History,[Play History];Now())SetField(Album Track Play Count,Math(0[Album Track Play Count] + 1))First SetField isn't related to this but didn't bother to remove it from the paste. It saves play history dates for song just played so you can see that how many times and when the song has been played

The second SetField add +1 to new field [Album Track Play Count] which is relational field for songs album key. So every time you finish playing song it will update that albums track play count. If you have total tracks saved into metadata you only need to the your divide calculation between [Album Track Play Count] / [Total Tracks] and don't need any other calculation to slow you down.

Of course as [Album Track Count] is a new field it will start from zero if you don't first populate it with e..g your GroupSummaryQuery(Album, Number Plays,1). I'd also save total tracks to actual field so that too doesn't need to be calculated.

But after that it should be automatic and no speed loss and don't need any of those manual calculations other than the last divide

Quick Guide for the whole shebang:
1. Create new field e.g Album Track Play Count
2. Populate it with GroupSummaryQuery(Album, Number Plays,1)
 - might take some time (I don't use those as they are so slow)
3. Add SetField rule to After Play expression (see image)
4. Either count total tracks or preferably have it in the tags
5. Divide [Album Track Play Count] / [Total Tracks] in your thumbnail text

E: Attached example view .jvi with instructions in its description
Logged

Bob007

  • Regular Member
  • Recent member
  • *
  • Posts: 45
  • nothing more to say...
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #10 on: August 27, 2021, 11:25:06 am »

Thanks again for the guidance, lepa.  I think I have a working solution now.  I'm not sure why this is so much more efficient that my original solution but I guess I'd need to get into the product architecture to understand (and I'm too old for that  :))

I tried both options but opted for the first suggestion as I use an iPod for listening at work so prefer a solution that also updates when the handheld syncs i.e. not just dependant on the 'after playback expression'.

Initially, I thought I was still having performance issues but, as I was starting from a restored library, I think this was down to whatever MC needs to do after a restore (e.g. thumbnail rebuilds etc.).  After leaving it for a little while, it settled down and I now have a solution that works almost effortlessly across a library with 40,000 tracks - I'm even able to have a view that sorts my entire library (3,000 albums) by the newly introduced [Album Play Count] field without any performance drop:

 

Fingers crossed that this continues to work - I'll monitor for a few days before committing.

Thanks again for the help - this has opened up some MC capabilities that I wasn't aware of so looking forward to having a play around with the functionality.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Sorting by Expression Issue (Performance) - Advice/Guidance needed
« Reply #11 on: August 29, 2021, 06:04:13 am »

I'm not sure why this is so much more efficient that my original solution but I guess I'd need to get into the product architecture to understand (and I'm too old for that  :))
Not working for jriver so guessing here but I think that it is just simply refresh frequency. Variables are calculated only when you enter the view or refresh it. Group functions instead probably refresh every time you scroll or select new item so MC has to do very expensive calculations every time you do something
Logged
Pages: [1]   Go Up