Before I start, the algorithms mentioned above are taken from a radio station. I was lucky enough to get in touch with the creator and he provided me with some sample SQL queries (as his radio station again uses SQL databases) to help me out.
When I implemented these queries it almost matched with how the Radio station selects songs but an issue crept up where when selecting songs to play from MediaLibrary, the SQL queries would not consider songs that had already been queued, and so I would experience two songs from the same album near one another (usually separated by one other song from another album).
The creator implemented a change into the database to maintain variety when listening and one such change was he made a custom call to include queued songs when considering what to play next (Perhaps in our use case a custom table which contains the queued songs in Batch part?).
The custom call, allows the creator to look into circles (or album artists) that have played recently since the concept of circles (music groups, bands, etc.) didn’t exist in the program before this.
As a result, the system will attempt to space out songs from the same circle to further increase variety.
Now I know the queries I made will not space out songs from the same circle due to how it's made but would it be possible for you to assist me or know any idea as to how to achieve this to prevent songs from the same album/album artist appearing in a very short period? (If we prevent album artists this ultimately means preventing them from albums anyway hence the creator took this approach)