Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.
The way a lazy DJ works
From SpacialAudio
I like to be a DJ. Unfortunately, I'm too lazy to be in front of my PC everyday. Thus, I record my voice, and make it into two part: beginning and ending phrase. I make 500 phrase for each type. Then I make a PAL to play 3 songs, and then play 1 beginning phrase randomly, and then choose 1 commercial break, and then play 1 ending phrase randomly again, and so on. If I run the script, I found that the listener will hear me with randomly 500x500 comments. It looks live though.
But still, it would be boring if the DJ is only one, and the program is only one also. So, The I make the script able to read the program file, called SPL (SAM PAL), to enable SAM playing different program every day.
Again, unfortunately, the script is far from good. I Sent it to forum to have your comments, suggestion, and improvement. Hence, the script will be good for everybody. I Found a bug, but I have no clue, where it was. If I play it for hours, there will be errors on the EVENT LOG, category "CORE", type "Exception", message "Unhandled exception (Access violation ... )".
It would be great if the script is improved and enriched.
You may download the scripts here. Lazy DJ.pal and Tuesday.spl
Code retrieved from archive org:
PAL
{-----------------------------------------------
CTA MusicBox PAL Script
Copyright(c) Jawara Technology, 2003.
All right reserved.
Please include this copyright information if you change this file
Program file format:
hh1:mm1:ss1,hh2:mm2:ss2,QID,SongString,SQuantity,Request,DJName,
Description:
hh1:mm1:ss1 : Time program played;
hh2:mm2:ss2 : Time program stop;
QID : Query := 1, SongCategory :=0; (Not yet Applicable, just write 0)
SongString : Query string if QID=1
Song category if QID=0; (Not yet Applicablem, just write the Song Category)
SQuantity : Number of songs per loading, 0 = Random 1-5 songs;
Request : Disable := 0, Enable:=1;
DJName : DJ name (Category: DJName_Begin,DJName_Ending);
Note: Please do not forget to add a coma "," at the last character
Example:
08:00:00,10:30:15:,1,Station IDs (All),3,1,Dimaz,
------------------------------------------------}
var FileName: array[0..7] of String;
var FileDir : String;
var FilePth : String;
var KeepPlay : Boolean;
var Curday, Lastday : Integer;
var ProgFile: TStrings;
var LineID : Integer; // line pointer of current file
var PosID : Integer; // Position of commas
var ComPos : Integer; // temporary commas check
var LoopI : Integer; // looping dummy variable
var TextPos: String; // value before commas delimited
var Wrkline: String;
var LoadFls : Boolean; // tougle of loading new file?
var Count : Integer; // looping position
var CLoop : Integer; // Loop limit;
// parameter loaded from lines of file
var BegProg, EndProg: String; // Beginning and ending program
var SngProg, DJSound: String; // Song program and Name of DJ
var QTgl,PrgLoop, ReqActive: Integer;// Query, Loop, and Request policy
Const General : Integer = 0;
FileDir := 'D:\websource\radio\'; // program file path
FileName[General] := 'General.spl'; // general program file
FileName[Sunday] := 'Sunday.spl';
Filename[Monday] := 'Monday.spl';
Filename[Tuesday] := 'Tuesday.spl';
Filename[Wednesday] := 'Wednesday.spl';
Filename[Thursday] := 'Thursday.spl';
Filename[Friday] := 'Friday.spl';
Filename[Saturday] := 'Saturday.spl';
KeepPlay:=true;
ProgFile := TStringList.Create;
CurDay := DayOfWeek(Now); // get day of week
LastDay := CurDay;
LoadFls := true;
// check general file incase program file not found
FilePth := FileDir + FileName[General];
if not FileExists(FilePth) then begin
ShowMessage('Default file is not found. Script is terminated!!');
KeepPlay := false;
end;
While KeepPlay do begin // never ending loop
if Loadfls then begin // if need loading new files
// load program file
CurDay := DayOfWeek(Now); // get day of week
LastDay := CurDay;
FilePth := FileDir + FileName[LastDay];
LoadFls:=false;
if FileExists(FilePth) then begin
WriteLn('Loading '+FilePth);
end else begin
FilePth := FileDir + FileName[General];
WriteLn('Loading general file'); // file should exist
end;
ProgFile.Clear; // clear last loaded file
ProgFile.LoadFromFile(FilePth); // load program file
if ProgFile.count < 1 then begin
ShowMessage('Script cannot find or load file, Script terminated.');
Exit;
end;
Count:=0;
end;
LineID:= 0;
Writeln(IntToStr(ProgFile.GetCount));
Randomize;
Repeat
WrkLine:=ProgFile.get(LineID); // get line
WriteLn(WrkLine);
PosID:=0;
Repeat
ComPos:= pos(',',WrkLine); // get commas
if ComPos > 0 then begin
Inc(PosID,1);
TextPos:='';
for LoopI := 1 to ComPos-1 do
TextPos:= TextPos + CharAt(WrkLine,LoopI);
Case PosID of
1 :begin
// get Begining time
BegProg :=TextPos;
end;
2 :Begin
// get Ending time
EndProg:=TextPos;
end;
3 :begin
// get Query tougle
QTgl:=StrToInt(TextPos);
end;
4 :begin
// get Song string
SngProg:=TextPos;
end;
5 :begin
// get loop policy
PrgLoop:=StrtoInt(TextPos);
end;
6 :Begin
// get Request policy
ReqActive:=StrToInt(TextPos);
end;
7 :Begin
// get Request policy
DJSound:=TextPos;
end;
end;
TextPos:='';
for LoopI := ComPos+1 to Length(WrkLine) do
TextPos:= TextPos + CharAt(WrkLine,LoopI);
WrkLine:=TextPos;
end;
Until ComPos = Length(WrkLine);
Inc(LineID,1);
if LineID > ProgFile.Count then LineID :=0;
Until (now > T[BegProg]) and (now < T[EndProg]);
Writeln(BegProg);
WriteLn(EndProg);
WriteLn(IntToStr(QTgl));
WriteLn(SngProg);
WriteLn(IntToStr(PrgLoop));
WriteLn(IntToStr(ReqActive));
WriteLn(DJsound);
If ReqActive = 1 then RequestPolicy.enabled := True
else RequestPolicy.enabled := false;
If PrgLoop = 0 then CLoop:= RandomInt(4)+1
else CLoop:=PrgLoop;
While (now > T[BegProg]) and (now < T[EndProg]) do begin
if Queue.IsEmpty then begin
WriteLn('Add '+intToStr(PrgLoop)+' songs of ..' + SngProg);
For LoopI:=1 to CLoop do begin
if QTgl = 0 then
cat[SngProg].QueueBottom(smLemmingLogic,EnforceRules)
else
cat[SngProg].QueueBottom(smLemmingLogic,EnforceRules)
end;
end;
PAL.WaitForPlayCount(1);
Inc(Count,1);
if CLoop = 0 then Cloop:=3 ;
if Count > CLoop then begin
WriteLn('Add comments and Commercial breaks');
cat[DJSound+'_End'].QueueTop(smRandom,NoRules);
cat['Commercial'].QueueTop(smRandom,NoRules);
cat[DJSound+'_Begin'].QueueTop(smRandom,NoRules);
count := 0;
PAL.WaitForPlayCount(CLoop);
if Queue.isEmpty then begin
cat[SngProg].QueueBottom(smRandom,NoRules);
PAL.WaitForPlayCount(2);
end;
if PrgLoop = 0 then
CLoop := RandomInt(4)+1;
end;
end;
if LastDay <> DayOfWeek(Now) then LoadFls := true;
end;
