This script will announce the track title and artist when it starts playing. There are a number of configurable options as follows:
PAL.WaitForPlayCount(1); // Change the number of tracks between announcements here
Replace the number 1 with your preferred track count, e.g. if you change this to 3 then every third track will be announced.
MyStation := 'My Rock Radio'; // Insert your station name here
StationTag := 'Tune in and rip the knob off'; // Insert your station tag line here
Insert the name of your station and your station tag line. These will also be announced randomly with the track information.
0 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist'];
1 : almost := 'This is,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation;
2 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist']+'. On '+MyStation+'. It is,'+MyTime2;
3 : almost := 'Just for you,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation+'. It is,'+MyTime2+' and '+MySec1+' seconds';
4 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist']+'. On '+MyStation+'. '+StationTag;
5 : almost := 'You are enjoying,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation;
These are the announcements played depending upon the random number generated. Whilst these can be edited, you should be careful and ensure all of the required code is maintained. If you wish to add options then follow the format but also increase the random number choice here:
Variety := RandomInt(5); // Generates a random number which is used to randomize the link output in the CASE
The PAL Script is available to download at the bottom of the page.
{ ******************************************************************************
With apologies and acknowledgement to the original writer of this PAL Script,
when I came across this script there was no mention of who wrote it.
I hope my additions add functionality in the manner the script was written.
********************************************************************************}
PAL.WaitForPlayCount(1); // Change the number of tracks between announcements here
PAL.LockExecution; // Lock Execution to speed up the script running
PAL.Loop := True; // Loop the PAL Script
// Declare Variables
var MyStation : string;
var StationTag : string;
var announcement, song : TSongInfo;
var map, almost, ready : string ;
var myDate : DateTime;
var addTime : DateTime;
var volume, duration, min, sec, ms : Integer;
var timeoffset : Integer = 0;
var MyTime : DateTime = Now;
var MyHour, MyMin, MySec, MyMSec, MyNow : Integer;
var MyHour1, MyMin1, MySec1, MyMSec1, MyNow1 : String;
var MyTime2 : string;
var Variety : integer;
volume := Aux2.Volume;
announcement := TSongInfo.Create;
map := 'c:\announcement.mp3';
MyStation := 'My Rock Radio'; // Insert your station name here
StationTag := 'Tune in and rip the knob off'; // Insert your station tag line here
DecodeTime(MyTime, MyHour, MyMin, MySec, MymSec); //Decodes the time into the respective parts
MyHour1 := FloatToStr(MyHour); // Converts the decoded time from integers into strings
MyMin1 := FloatToStr(MyMin);
MySec1 := FloatToStr(MySec);
if Length(MyMin1) = 1 then
MyMin1 :='0'+FloatToStr(MyMin); // Checks for a single number minute and adds a zero
MyTime2 := MyHour1+' '+MyMin1; // Inserts a space (pause) between the time segments
Variety := RandomInt(5); // Generates a random number which is used to randomize the link output in the CASE selection below
announcement['xfade'] := '&fie=0&foe=0&xf=0';
repeat
if ActivePlayer <> nil then
Song := ActivePlayer.GetSongInfo;
until (Song <> nil);
repeat
if ActivePlayer <> nil then
Song := ActivePlayer.GetSongInfo;
until (Song['songtype'] = 'S');
Song.Free;
Song := ActivePlayer.GetSongInfo;
announcement['filename'] := map;
CASE Variety OF // Play the announcement based on the contents of the integer Variety
0 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist'];
1 : almost := 'This is,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation;
2 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist']+'. On '+MyStation+'. It is,'+MyTime2;
3 : almost := 'Just for you,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation+'. It is,'+MyTime2+' and '+MySec1+' seconds';
4 : almost := 'You are listening to,'+Song['title']+'. by '+Song['artist']+'. On '+MyStation+'. '+StationTag;
5 : almost := 'You are enjoying,'+Song['title']+'. from '+Song['artist']+'. On '+MyStation;
END;
ready := URLEncode(almost) ;
WebToFile(map,'http://translate.google.com/translate_tts?tl=en&q='+ready);
if FileExists(map) then
begin
Aux2.QueueSong(announcement);
duration := Aux2.Duration;
if duration < timeoffset then
timeoffset := 0;
duration := duration-timeoffset;
ActivePlayer.Volume := 20; // Lower the Active Player Volume to overlay the soundbyte
Aux2.Volume := 350; // Raise the Axillary Player Volumes
Aux2.Play;
while duration > 999 do
begin
Inc(sec, 1);
if sec > 59 then
begin
Inc(min, 1);
sec := 0;
end;
duration := duration - 1000;
end;
ms := duration;
myDate := Now;
addTime := EncodeTime(0, min, sec, ms);
myDate := Now + addTime;
PAL.WaitForTime(myDate);
end;
PAL.UnLockExecution;
ActivePlayer.Volume := 250; //Return the volume of the Active Player to the previous level
if FileExists(map) then //Delete the previously used soundbyte
DeleteFile(map);
announcement.Free;
Aux2.Volume := volume; // Return the Axillary Player Volume to the previous level
Comments