[openal] Working with AL Soft extensions

Chris Robinson chris.kcat at gmail.com
Tue May 24 19:31:03 EDT 2016


On 05/24/2016 08:10 AM, Matthew Swartz wrote:
> Hi,
>
> I'm very new to  C++ in general and could use some help setting up the
> Doppler effect and speed of sound among other things.
>
> Here are the two files I have messed with:
>
> http://pastebin.com/EgdvtmEw
>
> http://pastebin.com/SAN7Rhf4
>
> This is from an existing game engine and I'd be more than happy to provide
> the source for the full Sound part of the solution if needed.
>
> Obviously how I set this up is not correct, and I was wondering what the
> correct way would be?

Hi.

In regards to:
     alGetFloat(AL_SPEED_OF_SOUND);
     alGetFloat(AL_DOPPLER_FACTOR);
     Listener.doppler.set(AL_DOPPLER_FACTOR);
     Listener.speed.set(AL_SPEED_OF_SOUND);

This looks suspect, although I don't know what Listener.doppler.set and 
Listener.speed.set are doing. The two alGetFloats aren't doing anything 
since the returned values aren't being stored anywhere (they return the 
values last set by alSpeedOfSound and alDopplerFactor respectively).

The doppler effect requires non-0 velocity values for the listener 
and/or sources to work. This is the number of units per second the 
listener and/or sources are traveling at a given point in time. Note: 
the listener and sources do not move automatically, the specified 
velocities are just for the purposes of calculating the doppler shift.

The speed of sound is the number of units per second that sound waves 
are assumed to travel, and so affects how strong or weak the pitch shift 
is given the velocity difference. The default is 343.3, which is a 
realistic value if sound is traveling over air and the unit scale is 
meters (if not, it needs to be changed as appropriate, e.g. if your 
units are in feet it would need to be set to 1126.3 instead).

The doppler factor acts as a simple scaling for the velocity values 
themselves, for the listener and all sources, which exaggerates or 
deemphasizes the effect. This can be useful if your objects move faster 
or slower than would be appropriate for sound propagation. For example, 
the Doom Marine moves much faster than a normal person, and using the 
velocities calculated from that movement would create an excessively 
strong pitch shift (which would be realistic for someone moving that 
fast, but is disconcerting to the player since sounds shift up or down 
much more than is comfortable for play). So reducing the doppler factor 
can deemphasize the effect making it less severe, while not having to 
get rid of it completely.

The speed of sound and doppler factor generally only need to be set once 
on initialization and can be left alone after that. They only need to be 
changed if the world unit scale or such changes.

> As you can see there is still some leftover EAX stuff in there as
> originally this game was using OpenAL, but I recently changed over to
> OpenAL Soft.

This can be converted to EFX, although from the looks of it, it will 
also require changes to whatever's calling CSoundRender_CoreA since it 
assumes an EAX-like API.


More information about the openal mailing list