[Openal-devel] Doppler Velocity; revised
Alexandre at OzEmail.com.au
Thu Mar 10 23:40:38 PST 2005
Perhaps we could simply deprecate AL_DOPPLER_VELOCITY,
AL_DOPPLER_FACTOR, alDopplerVelocity() and alDopplerFactor() and treat
them as NOPs, since the current doppler is broken anyway? That was one
of Andrew's suggestions, I think.
I've come up with a suggestion I think is very nice. (Note the default
value for AL_VELOCITY_SCALE.) I've put down my opinions and reasoning
Feel free to comment.
VS = AL_VELOCITY_SCALE (default value 0.0)
SD = AL_SOURCE_DOPPLER (default value 1.0; per source parameter)
vl = listener velocity (scalar value along source-to-listener vector)
vs = source velocity (scalar value along source-to-listener vector)
f = frequency of sample
f' = Doppler shifted frequency
f' = f * (1 - VS * SD * vl) / (1 - VS * SD * vs)
The reason I think this is nice is that you can turn Doppler shift on
and off globally with AL_VELOCITY_SCALE, and you can turn Doppler shift
on and off on a per source basis with AL_SOURCE_DOPPLER.
Now for my reasoning.
1. Why use VELOCITY_SCALE rather than SPEED_OF_SOUND?
Using VELOCITY_SCALE gives you a way to globally turn off Doppler shift
by setting VELOCITY_SCALE to 0 (and SPEED_OF_SOUND doesn't have this
2. Why use a default of 0 for VELOCITY_SCALE?
This is a much more sensible initial value than 1.0, since a default
value of 0 allows OpenAL to optimise away Doppler calculations by
default if the application isn't using Doppler effects.
If a default of 1.0 were used instead, OpenAL would carry out all
Doppler calculations (uselessly) by default even if the application
doesn't use any doppler effects and leaves all velocity vectors as
(0,0,0). So 1.0 would be a more computationally costly default than 0.
Also a default of 1.0 wouldn't be very useful since any application
wanting to use Doppler shifting would probably have to set
AL_VELOCITY_SCALE to a different value anyway.
Another advantage to having Doppler off by default is that any
applications written for OpenAL 1.0 that used Doppler will still run
well (just with Doppler effect disabled).
3. Why the name "AL_VELOCITY_SCALE"?
The parameter simply scales all listener and source velocity vectors.
(Note: It's easy to see that AL_VELOCITY_SCALE does not scale distances
at all since the default value is 0, and the OpenAL universe has not
collapsed into a point. :)
More information about the Openal-devel