Jump to content
C4 Forums | Control4

Random Audio Announcement


eggzlot

Recommended Posts

Currently I use a .wav file for the doorbell sounds which play through a C4 Amp to a few rooms in my house.  If I had 2-3 audio wav files and I wanted it to randomly pick 1 of the 2 or 3, how would I do that in programming.  Basically looking for an "or" statement or something if you will

Link to comment
Share on other sites


There is no explicit OR statement but you can achieve the same result using the IF statement and variables

 

variable = variable + 1

IF variable = 1

  use audio1.wav

IF variable = 2

  use audio2.wav

IF variable = 3

  use audio3.wav

  variable = 0

 
Not sure about random, as never seen any random functionality, but I'm sure you could write a small piece of code based on a timer to randomly set a variable value.
Link to comment
Share on other sites

When Doorbell Press

->Set to Random Value Between (min 1 max 3)

 

When Variable changes

->if variable equal to 1

->->Execute Announcement 1

->if variable equal to 2

->->Execute Announcement 2

->if variable equal to 3

->->Execute Announcement 3

Link to comment
Share on other sites

Hi Alan

Seems to have worked - thanks!  It is about 10 degrees outside and 8'' of snow so not standing out there testing it too much but I pressed it a few times, hit execute a few times, and I think I am good to go.

 

Thanks again!

 

No problems.  Pretty simple to do.  I used to do random 'the ring' video on my TV (with flickering lights) upon motion sensing (1/100 chance).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...