The audio in BlenderCreator is used for one thing: preview the sounds you want to use in the GameEngine. The idea is that you can load a sample, listen to it, softedit some of its parameters (no operation on the sample itself, but a set of instructions for the soundlibrary, stored in a SoundObject). Basically you just set up a default setting for a sound in a soundactuator.
GameEngine
The audio in the GameEngine is used for several things: dynamic, interactive audio (like soundeffects) and static audio (like backgroundmusic). You can also speak in terms of 3D audio and 2D audio. The 3D audio are the sounds positioned in the 3D world and the 2D audio is the sound that has more of an 'overlay' function.
Usage of the current implementation
The current implementation supports future multi-scene design.
The soundmodule (SND) can be divided in several aspects:
soundobjects
the listener
the soundscene
the wavecache
A soundobject is a collection of soundrelated parameters. Things like pitch, gain and position get stored here. Note: no sample storage is done here. It is mere a container for abstract properties of sound.
The listener is the 'camera' in soundland. Where the camera sees, the listener hears. The listener is always connected to the active camera.
The soundscene is the part where all things come together: soundobjects are loaded into the scene, connected to the sample. With every update of the sound-frame the listener gets, if modified, the current values and all objects that must be played or are playing get all new values, but only if they differ from the last frame.
The wavecache is the part of SND where samples get loaded into the soundlibrary (like OpenAL). It is nothing more than a loader for samples.
But at this point there's hardly any feature at all. All kinds of parameters must get set and tweaked. (* = to be implemented)
For starters: basic playback control like play, stop, pause.
Volume (or gain): this is where the mixing of the loudness of the sound gets done. Choose a value between 0 (silence) and 1 (full gain).
Pitch: with the pitch you can change the frequency of the sound. Currently there's support for values between half the pitch (-12 semitones) and the double pitch (+12 semitones). Or in Hertz: if your sample has a frequency of 1000 Hz, the bottom value is 500 and the top 2000 Hz.
Attenuation: this is an important feature. In a 3D world you want to scale the relation between gain and distance. Ie, if a sound passes by the camera you want to set the scaling factor of how much the sound will gain if it comes towards you and how much it will diminish if it goes from you. For now, the scaling factor can be set between 0 (all positions get multiplied by 0: no matter where the source is, it will always sound as if it was playing in front of you) and 1 (a neutral state, for all positions get multiplied by 1). In the future it may become neccesary for a higher attenuation.
Looping: a sound can be set to loop. If the sample reaches the end of its data, it will start playing from the beginning.
Extended looping(*): looping sounds with a pre and postloops. A sound will start with the preloop. It then passes into the middle part and starts looping that part. When it must stop it will pass into the third part of the loop, the postloop, and play this to the end. As soon as the end of this part is reached the sound is finished and will stop.
Fixed panning(*): no matter where the sound is, it will always sound as if it where someplace relative to the listener.
End-of-sound-sensor(*): a sensor for finding out when a sound has finished playing.
Loop-sensor(*): a sensor for finding out when a sound is starting a new loop.
Interactive audio(*): 2 modes: static and dynamic interactive audio.
- static: first you compose a playlist. this is a list of N loopable elements. When triggered, the playlist finishes the current loop and then proceeds to the next loop.
- dynamic: the playlist gets composed realtime. This is also a list of N loopable elements. When triggered, the playlist finishes the current loop and then proceeds to the next loop. The trigger decides what this next loop will be, dependend on circumstances.
Multiple format support(*): currently OpenAL has only uncomprimised PCM wave support on Windows and PCM, MSADPCM, IMAADPCM, RAWADPCM MP3 and Ogg Vorbis support on Linux.
feature related stuff:
End-of-sound-sensor: OpenAL is and isn't a fire and forget library. If you play a sound you should stop it yourself. This means that if you want to keep track of a sound you have to use counters which may be costly. However, OpenAL on Windows sometimes *does* set the playstate of a sound to 'stopped' if the sample has ended.
Loop-sensor: OpenAL doesn't do callbacks. It doesn't let you know whether or not a sound is starting over again. This means that you have to keep track of a sound (see also End-of-sound-sensor).
Extended looping: must be determined whether or not we want to work with looppoints inside a sample. Pro: seamless transition from pre to loop to post, but then blender has to be able to read looppoints. Besides that it should be possible to set looppoints inside blender. Con: is asks extra knowledge of audio-editing. It would be easier if you let the user insert three different samples which will function as pre, loop and post.
Multiple format support: in my opinion it is more important to have a clean solid Soundsystem than to focus on this feature. This list will grow with time due to its open source nature. I believe it is only a matter of a few months that loki/creative have optimized format support. More formats will automatically follow if OpenAL proofs succesfull.