Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

SCRIPT: SFX6: Random Play

By
Carlton Guc
on 10/24/16, 4:48 PM 218 views

In this example we'll assume that there are a bunch of audio Wave files in your cue list and that it is simply a music play list. You want to play music from this list but you want SFX to select a random song each time and keep doing that until you tell it to stop.

Create the PlayRandomCues script in the SFX Script Editor:

FUNCTION PlayRandomCues


global assign @RandomPlay = 1

while (@RandomPlay == 1) do

// play a random cue

// Change “A” to the cue list containing the cues you want to randomly play

local assign @count = count list "A"

local assign @index = random 0 to @count - 1

local assign @duration = get index @index duration

 

Play index @index

delay @duration

 

delay 3

loop


END FUNCTION

Create a script to stop random play:

FUNCTION StopRandomPlay

 

global assign @RandomPlay = 0

 

END FUNCTION


Assign the scripts to triggers in SFX to start the random play using the script PlayRandomCues and stop by triggering the script StopRandomPlay.


To Fade out the currently playing cue instead of an abrupt stop, create a Volume Fade out Cue as your LAST cue in the random music cue list and modify the StopRandomPlay cue:

FUNCTION StopRandomPlay

 

global assign @RandomPlay = 0

local assign @count = count list "A"

local assign @index = @count - 2

play index @index


END FUNCTION


When executed, and since your Volume Change cue is the last cue in the list, it'll fire the fade out and stop the playing cue.


Add a Comment

Keep Informed

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/24/16, 4:48 PM
Seen: 218 times
Last updated: 10/24/16, 4:48 PM