2. Sources and EFX

Sources
Sources represent the parameters how a Buffer Object is played back. These parameters include the Source's Position, Velocity, Gain (Volume amplification) and more. The settings can be set/get by using AL.Source and AL.GetSource functions.

Continuation of the sourcecode from previous page:

uint[] MySources = new uint[2];
AL.GenSources( 2, out MySources ); // gen 2 Source Handles
 
AL.Source( TestSources[0], ALSourcei.Buffer, (int)MyBuffers[0] ); // attach the buffer to a source
 
AL.SourcePlay( MySources[0]); // start playback
AL.Source( MySources[0], ALSourceb.Looping, true ); // source loops infinitely
 
AL.Source( MySources[1], ALSourcei.Buffer, (int)MyBuffers[1] );
Vector3 Position = new Vector3( 1f, 2f, 3f ); 
AL.Source( MySources[1], ALSource3f.Position, ref Position );
AL.Source( MySources[1], ALSourcef.Gain, 0.85f );
AL.SourcePlay( MySources[1] );
 
Console.ReadLine(); // wait for keystroke before exiting
 
AL.SourceStop( MySources[0] ); // halt playback
AL.SourceStop( MySources[1] );
 
AL.DeleteSources( 2, ref MySources ); // free Handles
// now delete Buffer Objects and dispose the AudioContext

EFX

I'm sorry to do this, but if you want to work with EFX there is no other way. All I can give here is a brief overview that might help you make the decision if EFX is what you need. You will have to download the OpenAL SDK to get a copy of "Effects Extension Guide.pdf" from Creative labs, for in-depth information about programming with DSPs.

My advice is ignoring EFX, unless your game project is in 1st Person 3D. Environmental effects might look nice as a "selling point" on paper, but do not add any gameplay value to a Strategy game, or a 2D platform game.

The addition to OpenAL with EFX Extension is the rerouting of output signals.

  • In vanilla OpenAL you load a Buffer, attach it to a Source and besides the Source's parameters that's all the influence you have about what ends up in the mixer.
  • With EFX you may reroute a source's output through Filters and/or into Auxiliary Effect Slots. This allows more fine control about how a Source sounds when played, which is useful to achieve the effect of obstruction, occlusion or exclusion of a sound due to environment features like walls, obstacles or doors.

The new OpenAL Objects that come with EFX are "Effect", "Auxiliary Effect Slot" and "Filter".

An Effect Object stores the type of effect and the values for parameters of that effect. Types of Effects are for example Echo, Distortion, Chorus, Flanger, etc.

Auxiliary Effect Slots are containers for Effect Objects, whose output goes directly into the final output mix. The Slots are only used if there is a valid Effect Object attached to them, binding the reserved Handle 0 to a Slot will detach the previously bound Effect Object from it.

A Filter can be attached to a source, and either filter the "dry signal" that goes directly into the output mixer, or filter the "wet signal" that is forwarded to an Auxiliary Effect Slot.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

I'm really a noob at OpenAL (and in fact in sound programming for the PC in general), so please bear with me if this is a lame question:

Is there any way to "emulate" the EFX, eg. doing reverb, "manually" without the Creative Labs SDK?

I know computing the "enchanced wave" numerically is possible, but this either consumes lots of memory/discspace (precomputing all possible wave/effect combinations) or lots of cpu (computing the buffer on-demand in runtime).

I mean, is there something similar to Vertex/Fragment Programs in OpenAL? (which execute on the sound card or something..)

the Fiddler's picture

OpenAL Soft can do EFX effects in software. It is likely that it will become the default OpenAL implementation on Linux (hopefully, because the current one sucks!), but will run on Windows too.

Creative is likely preparing something "audio shaders", but not many things are publicly known at this point. There have been several discussions on the OpenAL mailling list, and we may see such extensions being added to OpenAL Soft in the future.

Inertia's picture

At least the 'Generic Software' OpenAL device for windows has the EFX Reverb (Effect) and lowpass (Filter) available. Also stated at: http://www.opentk.com/doc/chapter/2/openal

Assuming you are looking for a way to change the engine sound of your airplanes, Efx is probably a step too far already. With ALSourcef.RolloffFactor, ALSourcef.Pitch, ALSourcef.Gain, and the command AL.DopplerFactor() - or a combination between those - it should be possible to tweak a looping sound to give the effect you are looking for.

objarni's picture

Inertia, you're quite right :)

Cool, nice there's other ways to do the engine sound then.

But can I have the engine sound played at the same time as eg. explosions/cannon shots ? I mean won't they too be affected if I change the source-properties?

Edit: Aha I read up a little. The listener is just one, the sources may be many :)

Thanks !

snocrash's picture

Why limit this to a game only library? I for one am interested in making an audio program with this. Anyway keep on rocking. I just got here, and so for i like what i see. :)

the Fiddler's picture

Who said this is a game only library? :)

For example, I'm using it for a virtual reality / brain-computer interface. It's also found its way into CAD, modelers, ...

The original design was to have graphics, audio and input completely independent from each other, but that's not 100% possible yet (input and graphics are interwined). However you can ignore everything but the audio part, if you wish - no problem!

(edit: but this is a discussion for the forums)