There are three Audio Incidents provided by MotorCortex:
The AudioPlayback Incident selects a sound (via the use of selector) that has been loaded on its Clip’s audioSources and executes it. The AudioPlayback takes one argument (only the props) which is an object supporting the following keys:
- selector (string)
- startFrom (int / millisecond)
- duration (int / millisecond)
The AudioPlayback Incident of this example will play audioSource with id=”my-mp3” starting from millisecond 12000 and for 60000 milliseconds. Notice the “~” on the start of the selector. This character in the beginning of the selector indicates that the selector is targeting an audioSource. The selector continues with the common CSS-like syntax with the “#” character indicating we are selecting by id, followed by the id name. If we want to select audioSources by class we could use a syntax such as ~.rock
The AudioEffect Incident allows us to apply effects on two attributes of audioSources:
“gain” refers to the volume of the audioSource (with values from 0 to 1) while “pan” to the stereo pan of it (with supported values from -1 for left to 1 for right). Be default all audioSources have initial values 1 for gain and 0 (middle) for pan, unless if you set different startValues on the audioSources of the Clip.
AudioEffect can be defined and added to the Clip exactly as any other Incident:
AudioClip is a kind of Clip that can only accept audioSources, nothing else. Its only context consists of audioSources. AudioClips do not take selectors and they can be added on any other Clip’s or AudioClip’s timeline.