Using phrases

A simple, English-like set of phrases make up the scripting language for Sequence Composer. All phrases can be entered by typing or using the Phrase toolbar, and their function is explained later in this document.

Data types

Everywhere that a time is referenced, the default time type is milliseconds (ms). To refer to seconds (s), the type must be specified. As an example:

@ 500ms //in milliseconds
@ 500 //defaults to milliseconds
@ 0.5s //in seconds, same as 500ms

Everywhere that a brightness is referenced, the default brightness type is percent (%). However, a hexadecimal value between 0x0 and 0xFF may be used equivalently to 0% and 100%. As an example:

chn = 100% //in percent
chn = 100 //defaults to percent
chn = 0xFF //in hexadecimal, same as 100%

Finally, everywhere that a generic channel is referenced (chn), the last referred channel is used (chn1 - chn16). As an example:

chn1 = 100% //sets channel 1 to 100%
chn = 0% //sets the last channel that was used (chn1) to 0%

chn2 = 100% //sets channel 2 to 100%
chn = 0% //sets the last channel that was used (chn2) to 0%

Phrases referenced in the toolbar

Time

Inserts the phrase "@ 0ms", which means all phrases after it will occur at the sequence's time of 0ms. This is an absolute timestamp. Following is an example:

//Turns an LED on fully, at 0.5 seconds turns it off, and ends at 1 second

@ 0s
 chn = 100%
@ 0.5s
 chn = 0%
@ 1s

Delta Time

Inserts the phrase "@+ 20ms", which means all phrases after it will occur 20ms after the sequence's current time. This is a relative timestamp. Following is an example:

//Turns an LED on fully, 0.5 seconds later turns it off, and ends 0.5 seconds later

@ 0s
 chn = 100%
@+ 0.5s
 chn = 0%
@+ 0.5s

Constant

Inserts the phrase "chn = 100%", which means the current channel is set to 100% brightness.

//Turns an LED on to 75% brightness, 0.5 seconds later turns it to 25% brightness, and ends 0.5 seconds later

@ 0s
 chn = 75%
@+ 0.5s
 chn = 25%
@+ 0.5s

Fade from...

Inserts the phrase "chn = fade from 0% to 100% for 0.5s", which means the current channel is set to fade from 0% brightness to 100% brightness over 0.5 seconds .

//Imitates a radio tower at night

@ 0s
 chn = fade from 0% to 100% for 1s
@+ 2s
 chn = fade from 100% to 0% for 1s
@+ 2s

Fade to...

Inserts the phrase "chn = fade to 0% for 0.5s", which means the current channel is set to fade from its current brightness to 0% brightness within 0.5 seconds . Unlike Fade from..., this fade operation starts on the value the channel already is at. The within keyword is used instead of for because the fade operation assumes the timing for it specifies a velocity at which it must fade from 0% to 100%. Because it may not be fading that whole range, it may accomplish this fade faster than the example's 0.5 seconds.

//Imitates a radio tower at night

@ 0s
 chn = fade to 100% within 1s
@+ 2s
 chn = fade to 0% within 1s
@+ 2s

...and wait until...

Inserts the phrase "and wait until finishes", which means stop advancing the sequence until the current fade operation finishes. This phrase only follows Fade from... and Fade to.... Without it, the sequence will continue advancing while the fade happens.

//Imitates a radio tower at night

@ 0s
 chn = fade to 100% within 1s and wait until finishes
@+ 5ms //<-- ***a 5ms delay is necessary, explained below***
 chn = fade to 0% within 1s and wait until finishes
@+ 5ms

Note: The 5ms delay is necessary after setting the channel to wait until it finishes because the sequence player will try to interpret all events within its current timestamp. The problem is that if the very next event is setting that same channel to something else, then it won't stop to "wait until it finished" the previous fade.

Go to...

Inserts the phrase "go to label", which jumps the sequence player's current line to wherever label was defined. When the sequence player jumps to that line, the sequence player's current time is reset to whatever time the label is.

//Accelerating charge

@ 0s
 chn = fade from 0% to 100% for 1s
@+ 1s
 chn = fade from 100% to 0% for 1s
@+ 1s
 chn = fade from 0% to 100% for 0.5s
@+ 0.5s
 chn = fade from 100% to 0% for 0.25s
@+ 0.25s
 chn = fade from 0% to 100% for 100ms
@+ 100ms

Running //<-- this is the label
 chn = fade from 100% to 0% for 100ms
@+ 100ms
 chn = fade from 0% to 100% for 100ms
@+ 100ms
go to Running

Go to... with chance

Inserts the phrase "go to label with 50% chance", which jumps the sequence player's current line to wherever label was defined, but only 50% of the time. When the sequence player jumps to that line, the sequence player's current time is reset to whatever time the label is.

//Accelerating charge, with infrequent sparking

@ 0s
 chn = fade from 0% to 100% for 1s
@+ 1s
 chn = fade from 100% to 0% for 1s
@+ 1s
 chn = fade from 0% to 100% for 0.5s
@+ 0.5s
 chn = fade from 100% to 0% for 0.25s
@+ 0.25s
 chn = fade from 0% to 100% for 100ms
@+ 100ms

Running //<-- this is the label that is jumped to most frequently
 chn = fade from 100% to 0% for 100ms
@+ 100ms
 chn = fade from 0% to 100% for 100ms
@+ 100ms
go to Sparking with 10% chance
go to Running

@ 0s //<-- this sets the time to '0' when the following label is jumped to
Sparking //<-- this is the label that is infrequently jumped to
 chn = 100%
@+ 15ms
 chn = 0%
@+ 15ms
 chn = fade from 30% to 100% for 70ms
@+ 100ms
 chn = fade from 100% to 0% for 100ms
@+ 100ms
go to Running

Go between...

Inserts the phrase "go between label1 and label2", which randomly jumps the sequence player's current line to one of the labels defined between label1 and label2. When the sequence player jumps to that line, the sequence player's current time is reset to whatever time the label is.

//Random sparking

@ 0ms
NoSpark
@+ 1.25s
go between NoSpark and BigSpark

@ 0ms
SmallSpark
 chn = 25%
@+ 10ms
 chn = 0%
@+ 1s
go between NoSpark and BigSpark

@ 0ms
MediumSpark
 chn = 50%
@+ 15ms
 chn = 0%
@+ 1.5s
go between NoSpark and BigSpark

@ 0ms
BigSpark
 chn = 100%
@+ 20ms
 chn = 0%
@+ 250ms
go between NoSpark and BigSpark

Go to... in chance

Inserts the phrase "go to label with in1 chance". This phrase is identical to go to... chance, except that an input may be referenced as the probability.

//Accelerating charge, with an undetermined amount of sparking

@ 0s
 chn = fade from 0% to 100% for 1s
@+ 1s
 chn = fade from 100% to 0% for 1s
@+ 1s
 chn = fade from 0% to 100% for 0.5s
@+ 0.5s
 chn = fade from 100% to 0% for 0.25s
@+ 0.25s
 chn = fade from 0% to 100% for 100ms
@+ 100ms

Running
 chn = fade from 100% to 0% for 100ms
@+ 100ms
 chn = fade from 0% to 100% for 100ms
@+ 100ms
go to Sparking with in1 chance //<-- here is the input probability being tested
go to Running

@ 0s
Sparking //<-- this is the label that is jumped to based on the input probability
 chn = 100%
@+ 15ms
 chn = 0%
@+ 15ms
 chn = fade from 30% to 100% for 70ms
@+ 100ms
 chn = fade from 100% to 0% for 100ms
@+ 100ms
go to Running

Go to... if in > n

Inserts the phrase "go to label if in1 is greater than 0", which means the sequence player will go to the named label if the input has a value greater than 0. Any number may be used in place of "0".

//Radio tower that strobes during the day (chn1), fades at night (chn2)
//Day is when "in1" < 50%; Night is when "in1" > 50%

DayNightTest
 @+ 1s
 go to Night if in1 is greater than 50% //<-- the input is tested
 go to Day

Day
 chn1 = 100%
 @+ 50ms
 chn1 = 0%
 go to DayNightTest

Night
 chn2 = fade from 0% to 100% for 1s
 @+ 2s
 chn2 = fade from 0% to 100% for 1s
 @+ 1s
 go to DayNightTest

Go to... if in < n

Inserts the phrase "go to label if in1 is less than 100", which means the sequence player will go to the named label if the input has a value less than 100 . Any number may be used in place of "100".

//Radio tower that strobes during the day (chn1), fades at night (chn2)
//Day is when "in1" < 50%; Night is when "in1" > 50%

DayNightTest
 @+ 1s
 go to Day if in1 is less than 50% //<-- the input is tested
 go to Night

Day
 chn1 = 100%
 @+ 50ms
 chn1 = 0%
 go to DayNightTest

Night
 chn2 = fade from 0% to 100% for 1s
 @+ 2s
 chn2 = fade from 0% to 100% for 1s
 @+ 1s
 go to DayNightTest

Define

Inserts the phrase "define Name Expression", which will replace anywhere Name is used with the word(s) used in Expression.

//Defined as blinking LED

define LED_On 100%
define LED_Off 0%

@ 0ms
 chn = LED_On //<-- LED_On becomes "100%"
@+ 500ms
 chn = LED_Off //<-- LED_Off becomes "0%"
@+ 500ms

//Defined as fading LED

define LED_On fade to 100% within 250ms
define LED_Off fade to 0% within 250ms

@ 0ms
 chn = LED_On //<-- LED_On becomes "fade to 100% within 250ms"
@+ 500ms
 chn = LED_Off //<-- LED_Off becomes "fade to 0% within 250ms"
@+ 500ms

Multiple phrases per line

Except for the define and comment phrases, all other phrases may be shared on the same line. As an example:

//Demonstrates writing a timestamp and fade effect on the same line

@ 0s chn = fade from 0% to 100% for 1s
@ 1s chn = fade from 100% to 0% for 1s
@ 2s