| 1 | = SoundEngine = |
| 2 | {{{ |
| 3 | #!html |
| 4 | <div style="border:1px outset #8c5b00;padding: 0.5em 1em 0.5em 1em;background: #ffe17b;-moz-border-radius:10px"><table style="width:100%"><tr><td align="left"> |
| 5 | }}} |
| 6 | [[Image(icons:archive.png, 50)]] |
| 7 | {{{ |
| 8 | #!html |
| 9 | </td><td align="center"><b>This is an archived page!</b><br/>This page is very old and the content is not up to date.<br/>Not everything (if any) which is written here will be in the final game!</td><td align="right"> |
| 10 | }}} |
| 11 | [[Image(icons:archive.png, 50)]] |
| 12 | {{{ |
| 13 | #!html |
| 14 | </td></tr></table></div> |
| 15 | }}} |
| 16 | |
| 17 | This is the Core of the sound and music in orxonox. |
| 18 | |
| 19 | == library == |
| 20 | First of all: We use [http://www.openal.org 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 |
| 21 | |
| 22 | == usage == |
| 23 | openAL is very easy to use, and the interface is even easier |
| 24 | |
| 25 | Orxonox-SoundEngine-openAL has three classes: |
| 26 | * SoundBuffers: Buffers that alocate the memory for playing sound. (they only hold the data, but cannot play) |
| 27 | * SoundSources: Play the Buffers at a certain position |
| 28 | * Listeners: Listen to the music from some position (usually camera) |
| 29 | |
| 30 | 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: |
| 31 | {{{ |
| 32 | SoundSource* createSource(const char* fileName, PNode* sourceNode); |
| 33 | }}} |
| 34 | |
| 35 | used like this: |
| 36 | |
| 37 | {{{ |
| 38 | SoundSource* testSound = SoundEngine::getInstance()->createSource("sound/somesound.wav", this->localPlayer); |
| 39 | }}} |
| 40 | this automatically binds the Buffer read in from "sound/somesond.wav" onto the localPlayer |
| 41 | |
| 42 | alternatively do something like: |
| 43 | {{{ |
| 44 | SoundBuffer* newBuf = (SoundBuffer*)ResourceManager::getInstance()->load("file.wav", WAV); |
| 45 | SoundSource* source = (newBuf, this->localPlayer); |
| 46 | }}} |
| 47 | this does the same thing, but is not really used, because one can flush the Buffers via the SoundEngine. |
| 48 | |
| 49 | == SoundSources == |
| 50 | important functions for SoundSources |
| 51 | {{{ |
| 52 | void play(); |
| 53 | void stop(); |
| 54 | void pause(); |
| 55 | void rewind(); |
| 56 | }}} |
| 57 | |
| 58 | less important, but not to forget: |
| 59 | {{{ |
| 60 | void setRolloffFactor(ALfloat rolloffFactor); |
| 61 | }}} |
| 62 | |
| 63 | And thats about it. |