We are in the process of migrating the Spacial Wiki content to our new Help Center at spacial.com.
Please visit the Help Center for latest Tips and Tricks, Documentation and Troubleshooting.

Using Pal For Category Based Rotation

From SpacialAudio

Jump to: navigation, search

if your not familiar with how to add a PAL script in to SAM take a look at PAL Scripting - Hello World


Example 1 - Simple Category Based Rotation

The next example shows how to create a Category based rotation logic script, much like can be done using the Category based rotation logic module

Assumptions for this example:

  • a) All the popular music is in a category called "Hitz"
  • b) The rest of the music is in a category called "Tracks"
  • c) There are some station IDs inside the "Station IDs (All)" category.

As a program manager, you realized that your listeners like to hear two Hitz back-to-back and then play a tune from the Tracks, and then finally play a station ID so that they don't forget to what station they are listening.

Follow steps 1 to 4 from the PAL Scripting - Hello World and create a PAL script called "Example1.PAL"

Then, paste this text into it:

{#0# Make the script restart once it reaches the end}
'''PAL.Loop := True;''' 
''{#1# Insert songs into the Queue from various categories}''
'''CAT['Station IDs (All)'].QueueBottom(smLRP,NoRules);''' 
''{#2# Lets wait a while until a few songs have played
or else we will completely fill up the queue with songs!}''
'''    PAL.WaitForPlayCount(1);'''
'''until Queue.Count < 3;''' 


· The PAL.Loop := True; will make the script execute in a never-ending loop.
To stop the script press [Ctrl]+[F2]

· At the end of the script, the PAL script waits for a song to play and then checks on how many songs are left in the queue. If there are two or less songs in the queue, it continues execution of the script (which will add more songs to the queue). If this wait were not in the PAL script, it would continue adding songs to the queue till the queue eventually filled with thousands of songs!

· Notice that for the Station IDs the NoRules flag was used. This is because the station IDs category is likely to only contain a few tracks that will get played often and thus not comply with the "Do not repeat same song within [xx] minutes" rule. In order to work correctly, the playlist rotation rules must be ignored.


Example 2 - Running an Advertisement

Assumptions for this example: 1) All the advertisements are located in the "Advertisements (All)" category.

PAL Script:

PAL.Loop := True;
CAT['Advertisements (All)'].QueueTop(smLemmingLogic, NoRules);

Note:This script places an advertisement at the top of the queue after five songs play. SAM4 uses the normal playlist rotation logic to choose the five songs, but the PAL script forcefully adds an advertisement after every five songs that play.


Example 3 - Running a show a specific time

  Original Author: Chan Weinmeister
  Modified by: Louis Louw
  Purpose: To play a pre-recorded show on Wednesday at around 8:00PM
           The show is split into 4 parts
           We play a station ID after each part
PAL.Loop := True;
var mytime : DateTime;
var I : Integer;
var start_time, end_time : DateTime;
mytime := now;
start_time := T['19:58:00'];
end_time := T['19:58:30'];
{Check if this is the right day of the week}
 if DayOfWeek(Now) = Wednesday then
       if( mytime >= start_time) and (mytime <= end_time) Then
                 WriteLn('Canvas Prog Hour!');
        cat['Station IDs (All)'].QueueTop(smRandom,NoRules);
        cat['Station IDs (All)'].QueueTop(smRandom,NoRules);
        cat['Station IDs (All)'].QueueTop(smRandom,NoRules);
        cat['Station IDs (All)'].QueueTop(smRandom,NoRules);
        { Wait a while to make sure time is AFTER end_time }


· The shows are loaded in reverse order (#4 first, then #3, #2 and then finally #1). This occurs because we are loading each show at the top of the Queue. For the first song to be at the top of the queue we need to load it last.

· This script will only execute the show if it’s Wednesday between 7:58:00pm and 7:58:30pm.

· The PAL.WaitForTime is needed so that the current time is later than the end_time variable. If the script were to continue without waiting it might occur that the show is executed twice (The script will restart and still be inside the 7:58pm and 7:58:30pm time window.).


This concludes a quick introduction to the exciting world of PAL scripting. Please refer to the PAL scripting reference guide for more detailed information about PAL scripting and for more PAL scripts being used by broadcasters.


Personal tools