Delphi

OpenAL

Tutorials

Lesson #12 (EAX environment)

Depracted. A tutrial on the new EFX extension will follow.

As you know openal can use extensions. Like the .ogg extension we used in lesson #9.

Now we take the usage of extension a step further and access the EAX2.0 extension to OpenAL. More specificaly we go using sound environments like the Hangar effect.

For that you need to download the eax.pas file at downloads and place it in the same directory as the al.pas file.

Again we take the lesson#1 as a basis for this tutorial. To the uses line you need to add the eax unit.

Before we can call any eax functions we need to initialise them. So add the following lines at the end of your formcreate procedure:

  // Check for EAX 2.0 support
  alIsExtensionPresent(’EAX2.0’);
  FnName := ’EAXSet’;
  eaxSet := alGetProcAddress(FnName);
  FnName := ’EAXGet’;
  eaxGet := alGetProcAddress(FnName);

So first you check if the extension is available and next you link the eaxSet and eaxGet functions at runtime so you can use them in your program like. By using the eaxGet and eaxSet functions you can read the eax environment or set the eax environment.

  //set the effect
  Env := EAX_ENVIRONMENT_HANGAR;
  eaxSet(DSPROPSETID_EAX20_ListenerProperties,
         DSPROPERTY_EAXLISTENER_ENVIRONMENT or
         DSPROPERTY_EAXLISTENER_DEFERRED,
         0, @Env, sizeof(TALuint));
  // Commit settings on source 0
  eaxSet(DSPROPSETID_EAX20_BufferProperties,
         DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS,
         source, nil, 0);
  // Commit Listener settings
  eaxSet(DSPROPSETID_EAX20_ListenerProperties,
         DSPROPERTY_EAXLISTENER_COMMITDEFERREDSETTINGS, 0, nil, 0);

Here we set the eax environment to HANGAR giving some nice echo’s to the sound. Try setting the Env to EAX_ENVIRONMENT_UNDERWATER to get some underwater effect to sound played on your first source.

Only setting the effect is not enough you have to commit them aswell to a source and to a listener.

As you see you can set a specific effect to an individual source. This is not directly usefull for setting an environment, but it is usefull for occluding source and make them sound like they are behind a concrete or wooden wall. But more on that will be in the next EAX tutorial.