Thumbnail

Sound Script (Ezb)

Execute a script when sound is played out of the EZB speaker

+ How To Add This Control To Your Project (Click to Expand)
  1. Make sure you have the latest version of ARC installed.
  2. Select the Get button in this page to download the archive file.
  3. Double click the downloaded archive file to execute installer.
  4. The installer will add this control to ARC.
  5. Load ARC and press the Project -> Add Control button from the menu.
  6. Choose the Audio category tab.
  7. Press the Sound Script (Ezb) icon to add the control to your project.

Manual

Execute a script when sound is played out of the EZB speaker. This robot skill will also set 3 variables for the sound level that your script loop can access. The variables include Min Level, Max Level, and Average Level.

Because the script is executed once when audio is started to play, it is advised that your on-going script is contained within a loop. Once the audio has stopped playing, the script will cancel and therefore stop running your loop.

*Note: To avoid infinite recursive run-away loops, never play an audio file or speech from the script within this skill. This means do not speak or send a ControlCommand to another control that plays audio. Doing so will call itself, which calls itself, which calls itself, which calls itself, which calls itself, which calls itself...

A simple example would be to loop and display the min, max, and average audio level values. This will be executed when the audio is started to play out of the EZB, and will stop when the audio is stopped. 

Code:


print("Audio started, beginning loop");

while (true) {

print("Min level" + getVar("$EZBAudioMinLevel"));
print("Max level" + getVar("$EZBAudioMaxLevel"));
print("Avg level" + getVar("$EZBAudioAvgLevel"));
}