Skip to Content
It is currently March 2nd, 2021, 8:26 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: May 31st, 2020, 12:53 am 
Offline
New User
New User

Joined: May 9th, 2016, 12:59 pm
Posts: 10
Hi, I am trying to modified a script for the hour(time) every 6 tracks but I see is working but SAM does not play the hour and minutes tracks on AUX 1 only pass a silence. Please somebody can help me, what I am doing wrong?


Code:
{*****************************************

 PAL Script to speak the time through AUX1

******************************************}
PAL.Loop := True;
PAL.WaitForPlayCount(1); //Wait 4 songs to give the time again

// Here are programmed how many elements are in the queue

PAL.loop := true;                   // Loop the script to ensure the time signal is played at every 6 Tracks

var Player1 : TPlayer;              // Declare an instance of TPlayer and assign it DeckA
var Player2 : TPlayer = Aux1;       // Declare an instance of TPlayer and assign it Aux1
var ActiveVol, AuxVol1 : integer;   // Declare containers for the current volume levels
var LowVol : integer = 20;          // Set the lower volume limit here
var HighVol : integer = 330;        // Set the high volume level here
var minute, fileHour, fileMin, hour : String;
var position : String = 'ipTop';
PAL.LockExecution;
Aux1.Eject;
fileMin := 'C:\time\MIN'+minute+'.mp3';
fileHour := 'C:\time\HRS'+hour+'.mp3';

Aux1.Play;
ActivePlayer.Volume :=80;
PAL.UnlockExecution;
PAL.WaitForTime('+00:00:02');
ActivePlayer.Volume := 155;
PAL.WaitForTime('+00:00:02');
ActivePlayer.Volume := 210;
PAL.WaitForTime('+00:00:01');
ActivePlayer.Volume := 255;


Last edited by DJ Cassio on May 31st, 2020, 7:28 am, edited 1 time in total.
Please use [code][/code] tags in the future


Top
 Profile  
Reply with quote  
PostPosted: June 2nd, 2020, 5:08 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8155
Location: Cologne (Germany)
You never defined what minute and hour are.
The variables are declared, but empty and there's no logic to fill them with the current time.

Your script will try to play C:\time\MIN.mp3 and C:\time\HR.mp3 regardless of what minute or hour it is. Is that intended?

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 2nd, 2020, 5:58 pm 
Offline
New User
New User

Joined: May 9th, 2016, 12:59 pm
Posts: 10
Thank you for reply, what I intend is to give the time after played 6 songs, it has to be exactly with Sam Broadcaster clock.
I have a pal that does it but the time goes through regular players A and B.
I want to use the Aux1.
Thank you again for your time, I going to continue to work on it to see I can make work.


Top
 Profile  
Reply with quote  
PostPosted: June 3rd, 2020, 3:02 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8155
Location: Cologne (Germany)
If you need more help, just post the script here and we'll see if we can help change that.

By the way:
The Fade you built manually can be replaced with a FadeToVolume command.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 8th, 2020, 11:16 pm 
Offline
New User
New User

Joined: May 9th, 2016, 12:59 pm
Posts: 10
Hi, Finally after looking and trying many combinations of codes I made SAM work to give the hour on the Aux1 and Aux2.
Here is the code if somebody wants to use it under the own risk.

Please feel free to recommend if everything is correct o there are commands that is not need in the code.

One version.


Code:
// This PAL will give the hour on Aux1 AND Aux2

PAL.loop := true;
PAL.WaitForPlayCount(1); //espera 4 temas para dar la HORA nuevamente.
const TimeHeader  : String = 'C:\Time';
const TimeHours   : String = 'C:\Time\Hours';
const TimeMinutes : String = 'C:\Time\Minutes';
const MyGMTZone   : Integer = -4;
var  countQueue : Integer;

var Player1 : TPlayer;              // Declare an instance of TPlayer and assign it DeckA
var Player2 : TPlayer = Aux1;
var Player3 : TPlayer = Aux2;
var i : integer;
var Song : TSongInfo;
var minute, fileHour, fileMin, hour : String;
var duration  : Integer;
var fname        : String;
var fnamehh      : String;
var fnamemm      : String;
var ampm         : String;

var hh,mm,ss,ms : Integer;

   DecodeTime(Now,hh,mm,ss,ms);
   if (hh = 0) then hh := 12;
   if (hh > 12) then hh := (hh-12);
   if (mm <= 9) then
    WriteLn('The Time Is '+IntToStr(hh)+':'+'0'+IntToStr(mm));
       if (mm >= 10) then
         WriteLn('The Time Is '+IntToStr(hh)+':'+IntToStr(mm));

var E : DateTime = Queue.ETA;

         DecodeTime(E,hh,mm,ss,ms);

           if (hh = 0) then hh := 12;
          if (hh > 12) then hh := (hh-12);
          if (hh >0) then
       fnamehh := IntToStr(hh)+'.mp3';       //get the right file name
         WriteLn(fnamehh);

    if (mm <= 9) then
       fnamemm := '0'+IntToStr(mm)+'.mp3'      //get the right file name
     else
       fnamemm := IntToStr(mm)+'.mp3';         //get the right file name
         WriteLn(fnamemm);

    if (mm <= 9) then
    WriteLn('Will SayTime at '+IntToStr(hh)+':'+'0'+IntToStr(mm));
       if (mm >= 10) then
         WriteLn('Will SayTime at '+IntToStr(hh)+':'+IntToStr(mm));
           // Just checking
           
duration := Queue.Duration;
hour := FormatDateTime('hh', Queue.ETA);
minute := FormatDateTime('nn', Queue.ETA);

fileMin := 'C:\time\Minutes'+minute+'.mp3';
fileHour := 'C:\time\Hours'+hour+'.mp3';

if (countQueue > 0) then
  begin

  end
else
  begin
    Queue.AddFile(fileMin, ipTop);
  Queue.AddFile(fileHour, ipTop);
  end

;Song := Queue.NextInQueue;
Aux1.QueueSong(Song);
Player1 := ActivePlayer;
  // Get what the Volume is set to
  i := ActivePlayer.GetVolume;
   // Detect the empty player and queue a station ID in it
  Player2 := Aux1;
  ;Song := Queue.NextInQueue;
Aux2.QueueSong(Song);
Player1 := ActivePlayer;
  // Get what the Volume is set to
  i := ActivePlayer.GetVolume;
   // Detect the empty player and queue a station ID in it
  Player3 := Aux2;
  //PAL.WaitForTime(T['+00:00:05']);
 PAL.WaitForTime(E);
 PAL.WaitForTime(T['+00:00:00']);
    Player2.play;
    Player3.play;
  repeat
  // writeln(inttostr(p2.status));
  until Player2.status = psReady;
 // Reset Volume Back To Normal
  ActivePlayer.Volume := i;
  Song.Free;



Second Version:


Code:
 
// This PAL will give the hour on Aux1 AND Aux2

PAL.Loop := True;
PAL.WaitForPlayCount(1); //espera 4 temas para dar la HORA nuevamente.
const TimeHeader  : String = 'C:\Time';
const TimeHours   : String = 'C:\Time\Hours';
const TimeMinutes : String = 'C:\Time\Minutes';
const MyGMTZone   : Integer = -4;
var duration, countQueue : Integer;
var Player1 : TPlayer;              // Declare an instance of TPlayer and assign it DeckA
var Player2 : TPlayer = Aux1;
var Player3 : TPlayer = Aux2;
VAR Song : TSongInfo;
var i : integer;
var minute, fileHour, fileMin, hour : String;
var ActiveVol, AuxVol1 : integer;   // Declare containers for the current volume levels
var LowVol : integer = 20;          // Set the lower volume limit here
var HighVol : integer = 330;
var E : DateTime = Queue.ETA;


duration := Queue.Duration;
hour := FormatDateTime('hh', Queue.ETA);
minute := FormatDateTime('nn', Queue.ETA);

fileMin := 'C:\time\Minutes'+minute+'.mp3';
fileHour := 'C:\time\Hours'+hour+'.mp3';

if (countQueue > 0) then
  begin

  end
else
  begin
    Queue.AddFile(fileMin, ipTop);
  Queue.AddFile(fileHour, ipTop);
  end

;Song := Queue.NextInQueue;
Aux1.QueueSong(Song);
Player1 := ActivePlayer;
  // Get what the Volume is set to
  i := ActivePlayer.GetVolume;
   // Detect the empty player and queue a station ID in it
  Player2 := Aux1;
  ;Song := Queue.NextInQueue;
Aux2.QueueSong(Song);
Player1 := ActivePlayer;
  // Get what the Volume is set to
  i := ActivePlayer.GetVolume;
   // Detect the empty player and queue a station ID in it
  Player3 := Aux2;
  //PAL.WaitForTime(T['+00:00:05']);
 PAL.WaitForTime(E);
 PAL.WaitForTime(T['+00:00:00']);
    Player2.play;
    Player3.play;
  repeat
  // writeln(inttostr(p2.status));
  until Player2.status = psReady;
 // Reset Volume Back To Normal
  ActivePlayer.Volume := i;
  Song.Free;


Top
 Profile  
Reply with quote  
PostPosted: June 9th, 2020, 3:45 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8155
Location: Cologne (Germany)
Code:
           if (hh = 0) then hh := 12;
          if (hh > 12) then hh := (hh-12);

This can be shortened using the modulo operator if you want:
Code:
hh := hh mod 12;


But overall there's 200 lines or so that are completely unused in the first script except for printing on the console of the PAL Editor:
Code:
   DecodeTime(Now,hh,mm,ss,ms);
   if (hh = 0) then hh := 12;
   if (hh > 12) then hh := (hh-12);
   if (mm <= 9) then
    WriteLn('The Time Is '+IntToStr(hh)+':'+'0'+IntToStr(mm));
       if (mm >= 10) then
         WriteLn('The Time Is '+IntToStr(hh)+':'+IntToStr(mm));

var E : DateTime = Queue.ETA;

         DecodeTime(E,hh,mm,ss,ms);

           if (hh = 0) then hh := 12;
          if (hh > 12) then hh := (hh-12);
          if (hh >0) then
       fnamehh := IntToStr(hh)+'.mp3';       //get the right file name
         WriteLn(fnamehh);

    if (mm <= 9) then
       fnamemm := '0'+IntToStr(mm)+'.mp3'      //get the right file name
     else
       fnamemm := IntToStr(mm)+'.mp3';         //get the right file name
         WriteLn(fnamemm);

    if (mm <= 9) then
    WriteLn('Will SayTime at '+IntToStr(hh)+':'+'0'+IntToStr(mm));
       if (mm >= 10) then
         WriteLn('Will SayTime at '+IntToStr(hh)+':'+IntToStr(mm));
           // Just checking


This is the last time that either mm, hh or fnamemm or fnamehh are used. After that you only use the Queue.ETA formatted Date string.


Why do you add semicolons to the beginning of the lines following the statement that should be terminated by semicolon?
And what use does the 00 wait have? ( PAL.WaitForTime(T['+00:00:00']); )


In the second script you never reassign Player2 and Player3, they're just alias names for Aux1 and Aux2, so you could leave those variables away and just use Aux1 and Aux2 respectively. You only need a variable to store the ActivePlayer as that could be either DeckA or DeckB at any given time.


This snippet will never go in the first branch of your if as you never set countQueue to any value:
Code:
if (countQueue > 0) then
  begin

  end
else
  begin
    Queue.AddFile(fileMin, ipTop);
  Queue.AddFile(fileHour, ipTop);
  end

That means you can simplify it and leave the if out and just add the two files to the queue.

Last but not least: Your i variable is completely useless as you never change the volume. You record what volume the Active Deck is set to, keep it at that volume and never change the volume and then reset it to the number it has been on all the time.

The good part: I didn't know about the FormatDate function. That's a clever way to get around the 12/24 and leading zero mess. Congratulations on finding that.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 10th, 2020, 6:27 pm 
Offline
New User
New User

Joined: May 9th, 2016, 12:59 pm
Posts: 10
Thank you for the compliment, but I can not take credit for something I did not create, as I said before, I just grab code from other scripts and put them together, I think I just get lucky that the combinations worked for my needs. That is the reason I post them here for the members to check them or using them if they want, under their own risk. Thank you so much to everybody that check and help me with the ideas, especially to Mastacheata because always helping with ideas and advises.


Top
 Profile  
Reply with quote  
PostPosted: June 10th, 2020, 8:01 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8155
Location: Cologne (Germany)
patino3855 wrote:
Thank you for the compliment, but I can not take credit for something I did not create, as I said before, I just grab code from other scripts and put them together, I think I just get lucky that the combinations worked for my needs.

I think that's the best way to learn the stuff, if you're interested in learning it.

I was very lucky to learn Turbo Pascal in school (which is the predecessor to Delphi - The language that SAM is coded in and that is at the base for the PAL scripting language as well)

Also reviewing other people's code is part of my job and I'm always happy when someone new tries to fight their way through the PAL djungle instead of just taking the readymade scripts for granted.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group