Perspective - Need help with Audio Component Event onEnded Script

Hello,

I'll start off by saying that this Audio component in Perspective in 8.1.22 is working correctly and plays the audio just fine. It is a 1 second "Critical Alarm" sound that plays whenever a critical-level alarm is active and unacknowledged.

Currently, I am trying to introduce a 1-second delay between the looping of that alarm audio so that the sound is not as jarring. I know that time-based delays are typically frowned-upon in scripting, so I've tried scripting the "onEnded" Component Event on the Audio component to change the volume to 0 if the current volume is 100% and to 100% if the volume is 0 (basically playing a 1 second muted audio), but the audio volume never changes. It just loops at the same volume.

Any help with this current problem, or maybe a better way to approach this would be greatly appreciated.
Thanks!

Other

  • The audio component "props.play" binding uses an expression to detect critical alarms, works fine.
  • The "props.loop" property is set to True, always.
  • The "props.volume" property had an old binding tied to a "Mute" button, but that's been removed.

Are you sure the event is even happening? (It would seem logical to me that looping would prevent it from ever ending?)

I'd modify the audio file and add in some silence at the end.

  • Download Audacity.
  • Import the audio file.
  • I think you can drag the end of the file to the right to extend it with silence.
  • You also have the option to add a short fade-in / fade-out if you wish.

Now you can play on infinite loop without sleep().

2 Likes