Imagine I have 100 recordings by Benjamin Britten, of all sorts of durations, from 2-minute long songs to 3-hour long operas. Imagine, too, that I have asked to select 10 recordings by Britten, that last between 20 and 40 minutes, but only the first of the 10 should actually be picked to be played for some reason.
What Giocoso used to do was take the 100 recordings and randomly “rank” them: that is, it would assign a system-generated number to each one, starting at 1 and finishing at 100. Then it would grab the recordings with the first 10 ranking numbers (i.e., items 1 to 10), since that’s what I’d asked for it to select. Finally, it would assess those 10 recordings for their duration and make sure they fit between 20 and 40 minutes.
Here, for example, is the first pass: randomly select 10 recordings by Britten and rank them:
Now we apply the “between 20 and 40 minutes” filter:
Only three recordings now match all our selection requirements.
Except there was one other requirement which makes things even worse: from the possible play candidates, play only one. The way Giocoso did that was to say “where rank = 1”… and I hope you can see that I won’t be playing anything by Benjamin Britten, because his ‘rank=1’ item is one of the forbidden recordings (forbidden by its long duration). The Cello Symphony could be played on duration grounds, but because it was already assigned a rank of ‘3’, the ‘rank=1’ selection test renders it ineligible for play.
This is how Giocoso has been selecting music for a long while now… and it’s logically flawed. It certainly “worked” with a sufficiently large music collection with sufficiently high numbers of different composers and with sufficiently lax duration requirements: but it ranked first and filtered second… and doing things that way round means that lots of eligible recordings (say, Britten’s Cello Symphony or Violin Concerto from the above example) would not get selected, because they happened to be assigned the wrong, not-1, ranking number early on.
The logically correct way of doing things is to filter first and rank second. If I had done that, I would have struck out all the red items in the last table for duration reasons and that would have left this selection of three candidate recordings:
Only now do I assign a ranking:
When I finally add in the “rank = 1” selection restriction: lo and behold, my next cycle of 10 plays will include the Cello Symphony.
By assigning rank early, I make it highly improbable I’ll find a recording to play (it is pot-luck if a duration-qualified recording might get assigned a rank of ‘1’); by assigning it late, assuming any recordings meet the duration requirement, I’m absolutely guaranteed to pick one of them when I add the ‘rank=1’ restriction.
I mention this now because I’ve fixed it in the forthcoming release of Giocoso 3.37. That release (I’m tentatively aiming for the very end of March) re-orders the selection and ranking operations, with the result that it’s now much easier for recordings that qualify on duration or other configured selection criteria to make it through to being played, without being artificially disqualified on the grounds that their randomly-assigned rank number is ‘wrong’! Instead of seeing lots of this screen:
…you'll see much more of this sort of screen:
Giocoso music playback is, in short, now much more likely to play a diverse mix of works by multiple composers than before, whilst still holding fast to the ‘one composer per cycle of plays’ principle. I'm only sorry it took me this long to work out why I was having quite so many of the 'no music to play' screens before!
I’ll announce the next release here when it happens, of course: right now, I’m giving it multiple days of testing to ensure the logic is now really where I need it to be!