Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 23 (modified by erwin, 16 years ago) (diff)

Sound

TracNav(TracNav/TOC_Development)? Presented to you by Erwin Herrsche?

(everything works only for the sound2 branch)

User Guide

Configuring available sounds

Configuration of soundfiles is done in the XML files. You just have to add the specific attribut to your class tag. The value has to be the filepath relative to the [mediapath]/audio directory.

Current possible sounds:

Class Soundattribute(s) Looped?
Level ambientsound Yes
Engine sound Yes

Configuration of the mainmenu ambient sound is done in the config file, as the mainmenu loads no level.

[SoundMainMenu]
filename_=<soundpath>

The soundpath is relative to the [mediapath]/audio directory, too. Default is ambient/mainmenu.wav.

Make more soundattributes available

Here are some instructions:

  1. Look at the implementaion of the above classes. You should be able to copy a most of the things.
  2. Add a new XMLPort macro to the XMLPort function of the class the sound belongs to(most likely XMLPortLoadOnly), name the function loadFooSound or something similar
  3. Implement the load function, for some examples look at the above classes
  4. Add the needed members to the class (at least one SoundBase pointer)
  5. Add the calls to SondBase::play(bool loop) where you want to have the sound being played
  • Add the class/sound to the above list and that's it

Development

Sound uses the OpenAL library.

Classes

SoundManager: ← Tickable

  • manages the OpenAL device and context
  • manages the listener position
  • updates all registred sounds every tick

SoundBase:

  • base class for all sounds
  • manages OpenAL buffer and source
  • has to be attached to a WorldEntity
  • can load a sound sample form a file (via alut, all alut supported sound formats; via fallback handler, ogg vorbis files)

SoundMainMenu: ← SoundBase, OrxonoxClass

  • used to load the configured mainmenu ambient sound

Future projects

  • implement sound device configuration
  • implement fallback loaders for other file types
  • implement streaming abilites for large files
  • implement context handling for multiple Levels/SoundManagers