Author Topic: Repeat a sound file every 2-3 sequences.  (Read 2492 times)

Offline Justtazz

  • Full Member
  • ***
  • Posts: 65
  • 80013
Repeat a sound file every 2-3 sequences.
« on: December 03, 2013, »
Question 1
Is there a way to have a sound file repeat every 2-3 songs in a playlist?

Question 2:
Custom Scripting is there any documentation on this for Xlights?

Thanks

Justin
Justin
Aurora, Co


Offline CaptainMurdoch

  • Sr. Member
  • ****
  • Posts: 180
Re: Repeat a sound file every 2-3 sequences.
« Reply #1 on: December 03, 2013, »
You are not allowed to view links. Register or Login
Question 2:
Custom Scripting is there any documentation on this for Xlights?

Not sure on Question #1, but I think the answer for #2 is that there's not much out there.  It's BASIC with some added commands though, so if you're wanting to know about structure, you can look at most BASIC documentation.  If you have a specific question, we might be able to help with that.

Offline jnealand

  • Patron Member
  • Sr. Member
  • ****
  • Posts: 2494
Re: Repeat a sound file every 2-3 sequences.
« Reply #2 on: December 03, 2013, »
You might create a short animation with things like twinkle or slow color washes that play while your sound file plays.  then just put it in your playlist where every you want it.  You just have to keep adding the same thing to the playlist.  No biggie.
Jim Nealand
Kennesaw, GA

Offline Justtazz

  • Full Member
  • ***
  • Posts: 65
  • 80013
Re: Repeat a sound file every 2-3 sequences.
« Reply #3 on: December 03, 2013, »
I wanted to be able to do a random playlist and not repeat opening and closing announcements so this is what I came up with.
I can explain if need be but our IT department keeps taking the network down to replace the phone system.  I just wanted to post the solution I came up with.

Custom Script for random playlist and opening and closing sequences with a reoccurring announcement every 2-3 songs.

Code: You are not allowed to view links. Register or Login
100 REM *
101 REM * Created: 12/03/13 15:51:04
102 REM * Random: on
103 REM * Repeat: on
104 REM * First Item Once: on
105 REM * Last Item Once: on
106 REM *
110 LET ListName$="2013 Test"
120 SETPLAYLIST ListName$
125 LET x=0
130 ONPLAYBACKEND 140
131 PRINT "At:", FORMATDATETIME$(NOW,5)
132 PRINT "Playing:",ITEMNAME$(1)
133 PLAYITEM 1
134 PRINT "Song Count:",x
135 WAIT
140 ONPLAYBACKEND 300
170 IF PLAYLISTSIZE-2>1 THEN 176
172 PRINT "ERROR: not enough items in playlist to support random playback"
174 GOTO 400
176 LET LastItemPlayed=-1
178 DIM PLAYED(PLAYLISTSIZE)
180 FOR I=1 TO PLAYLISTSIZE
182 LET PLAYED(I)=0
184 NEXT I
186 LET PlayCount=0
188 GOTO 300
200 REM *
201 REM * Play item NextItem
202 REM *
203 IF NextItem <> 2 THEN 205
204 LET NextItem=RND(PLAYLISTSIZE-2)+2
205 IF x=3 THEN 208
206 IF x<3 THEN 213
207 GOTO 213
208 PLAYITEM(2)
209 PRINT ITEMNAME$(2)
210 LET x=0
211 WAIT
213 LET LastItemPlayed=NextItem
214 PRINT NextItem
215 PRINT "At:", FORMATDATETIME$(NOW,5)
220 PRINT "Playing:",ITEMNAME$(NextItem)
221 PRINT "Song Count:",x
222 LET x = x +1
230 PLAYITEM NextItem
240 WAIT
300 REM *
301 REM * Jump here at end of song or sequence
302 REM *
305 LIGHTSOFF
310 IF SECONDSREMAINING <= 0 THEN 400
320 IF PlayCount>=PLAYLISTSIZE-2 THEN 180
330 LET NextItem=RND(PLAYLISTSIZE-2)+2
340 IF PLAYED(NextItem)>0 THEN 330
345 IF LastItemPlayed=NextItem THEN 330
350 LET PLAYED(NextItem)=1
360 LET PlayCount=PlayCount+1
370 GOTO 200
400 REM *
401 REM Reached scheduled end time
402 REM *
410 ONPLAYBACKEND 490
415 PRINT "At:", FORMATDATETIME$(NOW,5)
420 PRINT "Playing:",ITEMNAME$(PLAYLISTSIZE)
430 PLAYITEM PLAYLISTSIZE
440 WAIT
490 LIGHTSOFF
Justin
Aurora, Co


Offline CaptainMurdoch

  • Sr. Member
  • ****
  • Posts: 180
Re: Repeat a sound file every 2-3 sequences.
« Reply #4 on: December 04, 2013, »
You are not allowed to view links. Register or Login
Custom Script for random playlist and opening and closing sequences with a reoccurring announcement every 2-3 songs.

Thanks for posting the example, it will help others.

Looks good.  Only thing I can see that you might want to take a look at would be to change the '2's in lines 320 and 330 to '3's and removing your added lines 203 and 204.  I think your current version will play a random playlist entry twice during each run through the playlist since line 204 re-calculates another random item if '2' comes up.  You also aren't checking the result of line 204, so you could actually end up playing '2' as a random item which could mean you have a slim chance of playing '2' twice in a row or only separated by one other item.  If you change lines 320 and 330 to restrict the random values to playlist entries starting at 3 then you wouldn't have that possibility.

Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Re: Repeat a sound file every 2-3 sequences.
« Reply #5 on: December 04, 2013, »
The way I got around this last year is to make copies of the audio file and insert them into the schedule. 

I had a quick "Check us out on Facebook" announcement.  So, there was "facebook.mp3" "facebook(1).mpg" "facebook(2).mpg".  It's a quirk in xLights.  I've asked for this feature in the xLights/Nutcracker section of one of the forums.

It's not ideal, but it does the trick.
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login

Offline lightsoncallaway

  • Full Member
  • ***
  • Posts: 88
Re: Repeat a sound file every 2-3 sequences.
« Reply #6 on: December 04, 2013, »
I am doing this and I simply made a copy of the xlights sequence file and added the copies in the scheduler where I wanted the repeat.

Offline Justtazz

  • Full Member
  • ***
  • Posts: 65
  • 80013
Re: Repeat a sound file every 2-3 sequences.
« Reply #7 on: December 04, 2013, »
I thought of all those ideas but it seems silly top have 5 copies of the same sequence to insert where you want it.  besides if you want your sequences to be random in the playlist it doesn't work to have multiple copies.

So to summarize the custom script below allows you to randomize your playlist and have an opening & closing sequence, as well as a sequence that you can repeat every so many songs (such as be kind to neighbors),  and you only have to have one copy of the repeating sequence.  as long as it is the second song in your playlist it will only play when you decide.

Thanks to CaptainMurdoch for the adjustments it works great so far been testing all morning.

Code: You are not allowed to view links. Register or Login
100 REM *
101 REM * Created: 12/03/13 15:51:04
102 REM * Random: on
103 REM * Repeat: on
104 REM * First Item Once: on
105 REM * Last Item Once: on
106 REM *
110 LET ListName$="2013 Test"
120 SETPLAYLIST ListName$
125 LET x=0
130 ONPLAYBACKEND 140
131 PRINT "At:", FORMATDATETIME$(NOW,5)
132 PRINT "Playing:",ITEMNAME$(1)
133 PLAYITEM 1
134 PRINT "Song Count:",x
136 WAIT
140 ONPLAYBACKEND 300
170 IF PLAYLISTSIZE-2>1 THEN 176
172 PRINT "ERROR: not enough items in playlist to support random playback"
174 GOTO 400
176 LET LastItemPlayed=-1
178 DIM PLAYED(PLAYLISTSIZE)
180 FOR I=1 TO PLAYLISTSIZE
182 LET PLAYED(I)=0
184 NEXT I
186 LET PlayCount=0
188 GOTO 300
200 REM *
201 REM * Play item NextItem
202 REM *
205 IF x=2 THEN 208
206 IF x<2 THEN 213
207 GOTO 213
208 PLAYITEM(2)
209 PRINT ITEMNAME$(2)
210 LET x=0
211 WAIT
213 LET LastItemPlayed=NextItem
214 PRINT NextItem
215 PRINT "At:", FORMATDATETIME$(NOW,5)
220 PRINT "Playing:",ITEMNAME$(NextItem)
221 PRINT "Song Count:",x
222 LET x = x +1
230 PLAYITEM NextItem
240 WAIT
300 REM *
301 REM * Jump here at end of song or sequence
302 REM *
305 LIGHTSOFF
310 IF SECONDSREMAINING <= 0 THEN 400
320 IF PlayCount>=PLAYLISTSIZE-3 THEN 180
330 LET NextItem=RND(PLAYLISTSIZE-3)+3
340 IF PLAYED(NextItem)>0 THEN 330
345 IF LastItemPlayed=NextItem THEN 330
350 LET PLAYED(NextItem)=1
360 LET PlayCount=PlayCount+1
370 GOTO 200
400 REM *
401 REM Reached scheduled end time
402 REM *
410 ONPLAYBACKEND 490
415 PRINT "At:", FORMATDATETIME$(NOW,5)
420 PRINT "Playing:",ITEMNAME$(PLAYLISTSIZE)
430 PLAYITEM PLAYLISTSIZE
440 WAIT
490 LIGHTSOFF

to adjust the number of songs played between special sequence change the following lines.

Code: You are not allowed to view links. Register or Login
205 IF x=2 THEN 208
206 IF x<2 THEN 213

The =2 and <2, simply change the 2 to the number of songs you want between, be advised the way the code is written it is zero based so the first song is 0 second is 1 and so on. 

Example  with a value of 3

Intro
Song - 0
Song - 1
Song - 2
Repeating Message
Song - 0
Song - 1
Song - 2
Repeating Message
Song - 0
Song - 1 ......and so on until the end of the show
Then your closing message.

Thank you all for the help

Justin

PS if you have any questions ask or PM me and I will see what I can do to help.
« Last Edit: December 04, 2013, by Justtazz »
Justin
Aurora, Co


Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Re: Repeat a sound file every 2-3 sequences.
« Reply #8 on: December 04, 2013, »
So why not make your show:

Song 0
Song 1
Song 2
Message
Repeat

Then use the play the first/last thing once option?

Thing 1
Song 0
Song 1
Song 2
Message
Thing 2 (or copy of 1)
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login

Offline CaptainMurdoch

  • Sr. Member
  • ****
  • Posts: 180
Re: Repeat a sound file every 2-3 sequences.
« Reply #9 on: December 04, 2013, »
You are not allowed to view links. Register or Login
So why not make your show:

Song 0
Song 1
Song 2
Message
Repeat

He wants the sequences in the playlist to be played in random order every time through the playlist.

Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Re: Repeat a sound file every 2-3 sequences.
« Reply #10 on: December 04, 2013, »
OH!  LOL.  That's what I get for skimming!
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login

Offline Justtazz

  • Full Member
  • ***
  • Posts: 65
  • 80013
Re: Repeat a sound file every 2-3 sequences.
« Reply #11 on: December 04, 2013, »
Sorry if i wasn't clear i have about 30 sequences. at this time i am only using a few for my playlist but i would like to just have them all available and play randomly.  So i have been running this script for about 3 hours now with no problems.  looks like it is working.
Justin
Aurora, Co


Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Re: Repeat a sound file every 2-3 sequences.
« Reply #12 on: December 04, 2013, »
You are not allowed to view links. Register or Login
Sorry if i wasn't clear i have about 30 sequences. at this time i am only using a few for my playlist but i would like to just have them all available and play randomly.  So i have been running this script for about 3 hours now with no problems.  looks like it is working.

30 sequences??  That's impressive!  And it makes more sense why you want the randomness.
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login