SoundEngine
This is an archived page! This page is very old and the content is not up to date. Not everything (if any) which is written here will be in the final game! |
This is the Core of the sound and music in orxonox.
library
First of all: We use openAL for rendering of Music and Sound. This is because first of all it suits our framework the best (eg. PNode) and secondly because it is the only usefull 3D-sound-Engine that is cross-platform compatible
usage
openAL is very easy to use, and the interface is even easier
Orxonox-SoundEngine-openAL has three classes:
- SoundBuffers: Buffers that alocate the memory for playing sound. (they only hold the data, but cannot play)
- SoundSources: Play the Buffers at a certain position
- Listeners: Listen to the music from some position (usually camera)
Now orxonox implements initialisation of the SoundEngine for itself, so you do not have to worry about it. But there are some interessting functions in it:
SoundSource* createSource(const char* fileName, PNode* sourceNode);
used like this:
SoundSource* testSound = SoundEngine::getInstance()->createSource("sound/somesound.wav", this->localPlayer);
this automatically binds the Buffer read in from "sound/somesond.wav" onto the localPlayer
alternatively do something like:
SoundBuffer* newBuf = (SoundBuffer*)ResourceManager::getInstance()->load("file.wav", WAV); SoundSource* source = (newBuf, this->localPlayer);
this does the same thing, but is not really used, because one can flush the Buffers via the SoundEngine.
SoundSources
important functions for SoundSources
void play(); void stop(); void pause(); void rewind();
less important, but not to forget:
void setRolloffFactor(ALfloat rolloffFactor);
And thats about it.