Recent Changes - Search:

Main.SideBar (edit)

PmWiki

Audio

boson uses OpenAL for audio, see www.openal.org OpenAL is a 3d sound library which is in particular useful for 3d games. The OpenAL library from now on replaces the arts/kdemultimedia dependancy completely (and therefore removes all of our arts problems at once).

A few problems have come up with OpenAL until now:

  • The output code of OpenAL for arts is broken. A patch has been sent to OpenAL. When you suspend arts before starting boson audio will work anyway.
  • The MP3 code of OpenAL only supports a frequency of 44100Hz. Other frequencies make the program crash, so boson disallows them.

boson uses a separate process for audio playing - the bosonaudioprocess (see code/bosound). This adds additional problems, especially concerning latency, the reason for this design comes from the old arts code. Arts is really evil and there was no other way to make sound work. Since arts is not used anymore, the bosonaudioprocess may vanish once someone has some time to do that.

There are two different audio parts in boson - music and sound. Music is pretty easy - you load exactly one file, play it exactly once and once it stops you load another file (as a special case the next file may be the same that was loaded before). The interesting part with music playing is at a higher level (which music should when be played; volume; looping; ...) but the actual audio code is pretty simple.

The Sound part on the other hand is not so easy and is a lot more important.

  • We want to be able to play multiple sounds (e.g. effects, speeches, ...) at once.
  • Also we don't want to reload the sound file to play it once again (sidenote from an arts hater: this is impossible with arts).
  • In a perfect solution we would be able to play the same sound file twice without waiting the first one to stop playing. Without loading the file a 2nd time I mean.
  • Preloading all sound files on startup (or on demand) and keeping them in memory to use them once required would be nice, too. To save memory we could implement caching strategies (e.g. unload the file when it isnt played after some time)

All of this is possible and actually even very easy using OpenAL (once again a sidenote from an arts hater: most of this is impossible using arts). A BosonSound object is created for every species in the game. A BosonSound Object is primarily a collection of sound IDs. Such IDs can be

  • Integer IDs (used for general event sounds, such as minimap activation)
  • String IDs, "Names" (used for unit event sounds, i.e. everything that is produced by a unit such as "selected" or "attacking" sounds)

Every ID references a sound. Note that sometimes an ID can reference a list of sounds, i.e. several alternative sound files for the same event. In boson every sound file is currently represented by exactly one BoPlayObject object. These objects originally came from the implementation using arts and they will probably stay as they are pretty useful.

In the OpenAL notation a BoPlayObject is exactly one buffer. Therefore every BoPlayObject can be referenced by none or by multiple sources. Note that the current implementation differs from this (as of 04/3/15) as there is always exactly one source for every BoPlayObject - this _will_ change.

Edit - History - Print - Recent Changes - Search
Page last modified on November 11, 2005, at 22:04