Errors: You forgot to reset the MinArtistTime.
Possible Improvements: You could store the "old" values in variables and reset them later. That way you're more flexible should you ever change your repeat rules.
Checking queue.count could be replaced by PAL.WaitForQueue if that works for you.
But actually: NEVER EVER try to manually build a clockwheel in PAL.
Move your singing stuff into the clockwheel. (Preferrably remove any repetitions, a clockwheel repeats on its own) and rewrite your PAL script so it will only introduce the preaching into the queue in regular intervals.)
Here's how I would do it:
This is the PAL that plays your preaching once every 22 tracks.
Code:
VAR artist, song : Integer;
PAL.Loop := True;
artist := PlaylistRules.MinArtistTime;
song := PlaylistRules.MinSongTime;
PlaylistRules.MinArtistTime := 420; // # of minutes before Artist repeat
PlaylistRules.MinSongTime := 500; // # of minutes before Song repeat
Cat['Preaching'].QueueTop(smRandom, EnforceRules);
PlaylistRules.MinArtistTime := artist;
PlaylistRules.MinSongTime := song; // # of minutes before Song repeat
// Repeat every 22 tracks
PAL.WaitForPlayCount(22);
What's confusing me is why you have one line where your singing category is picked from with NoRules.
Without that line you've got a regular repetition in your structure. With that line it breaks everything.
Here's a clockwheel taking care of that irregularity:
Code:
Cat['Station ID'].QueueBottom(smRandom, NoRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, NoRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
And this would be a much simpler version of the same Clockwheel: (minus the ID, that needs to be placed via PAL in this version)
Code:
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Cat['Singing'].QueueBottom(smRandom, EnforceRules);
Cat['Singing'].QueueBottom(smLRP, EnforceRules);
Modify the Preaching PAL like this to include the ID:
Code:
VAR artist, song : Integer;
PAL.Loop := True;
Cat['Station ID'].QueueTop(smRandom, NoRules); // put to the very top
PAL.LockExecution;
artist := PlaylistRules.MinArtistTime;
song := PlaylistRules.MinSongTime;
PlaylistRules.MinArtistTime := 420; // # of minutes before Artist repeat
PlaylistRules.MinSongTime := 500; // # of minutes before Song repeat
Cat['Preaching'].QueueTop(smRandom, EnforceRules); // put even more to the top (on top of the station ID)
PlaylistRules.MinArtistTime := artist;
PlaylistRules.MinSongTime := song; // # of minutes before Song repeat
PAL.UnlockExecution;
// Repeat every 23 tracks
PAL.WaitForPlayCount(23);