Re[Openal] garding Doppler Effect

George Warner geowar at apple.com
Sat Sep 20 12:38:05 PDT 2008


On Sat, 13 Sep 2008 08:24:24 -0700 (PDT), OpenGeek <abhishek.s.dey at live.com>
wrote:
> I understand that the doppler effect in OpenAL is velocity dependent. But
> what if a Game scene is changing its coordinates to new one?

Then change it; the only thing that matters to the Doppler shift is the
relative velocities of the source and listener (You have to set the
velocities; OpenAL will not calculate this based on changes in position.)

As Daniel PEACOCK wrote:
>> [...] all you need to do is update each moving AL Source with a Velocity
>> vector (note velocity is *not* generated automatically based on changes in
>> Source position) and if the Listener is also moving you can also set a
>> Listener Velocity parameter too.

> How to calculate the velocity of sound using Listener's Position?

Depending on the density of the medium (air, water, wet cement, etc.) it's
traveling thru the velocity (speed) of sound is a constant. This is
independent of the positions of the source and listener (other than them
being in air, water, wet cement, etc.).

As Daniel PEACOCK wrote:
>> By default, units are assumed to be in meters (and velocities in meters
>> per second).   The AL_SPEED_OF_SOUND property therefore defaults to 343.3
>> (speed of sound travelling through the air in meters per second).

> Can Listener position be changed in alListenerfv(ListenerPos)?

Yes. (But this won't effect the Doppler shift; you have to calculate the
source and listeners velocities and set them independently of position.)

> Does it also implies that the listener has to be in constant motion to create
> Doppler Effect? 

No, the listener could be still and the source could be moving. The relative
velocities between the source and listener have to be non-zero for there to
be any Doppler shift.

> What functions are there in OpenAL to be used in Doppler shifting mechanism?

alDopplerFactor() (Old API; use alSpeedOfSound instead)
alSpeedOfSound() (Set this based on your units of measurement; 343.3 meters
per second, 767.94 miles per hour, etc.)

alListenerfv( AL_VELOCITY, velocity);
alSourcefv( gSource[idx], AL_VELOCITY, velocity);

Pull down the OpenAL specification from here:
<http://connect.creativelabs.com/openal/Documentation/oalspecs-specs.pdf>.

The Doppler info is documented in section 3.7: "Velocity Dependent Doppler
Effect".

If that doesn't clear everything up please reply back.
-- 
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)




More information about the Openal mailing list