This page has not yet been reviewed for compatibility with version 0.9.0. Details may now be incorrect.
Indigo's audio support is fairly unsophisticated, but probably good enough for the kind of games Indigo was designed for. The authors are not audio experts, please feel free to raise issues if you have any suggestions for improvements.
There are two kinds of audio support in Indigo:
- Sound effects
- Background music
Indigo uses web technologies, so you should refer to current recommended practices for audio formats. That being said, anything a browser will play Indigo will play, and most of the existing demos and examples just use MP3 files, but that is a fairly dated format these days.
Please refer to the assets documentation for information on how to load audio files.
Sound effects are tiny clips of sound that you will play many times, and are often triggered by some event in your game, such as a character jumping or a button push.
To play a sound effect you simply need to emit an event at the end of an update or scene draw and Indigo will do the rest, e.g.:
Background music must be added as part of your scene description, as follows:
SceneUpdateFragment(mySceneNodes) .withAudio( SceneAudio( SceneAudioSource( BindingKey("My bg music"), PlaybackPattern.SingleTrackLoop(Track(AssetName("music"))) ) ) )
SceneAudio can describe up to three music channels at once, called
SceneAudioSource specifics a
BindingKey to keep track of what is being played and it's progression state, and a playback pattern which at the moment can only be either
SingleTrackLoop takes a
Track which is very similar to the
PlaySound type above, taking an
AssetName to tell it what to play, and optionally a