rigs-of-rods
rigs-of-rods copied to clipboard
:bug: Update/fix Doppler effect for OpenAL 1.1 implementations
The doppler effect was already reported as defective in #313. Turns out OpenAL 1.1 changed the way how the doppler effect is handled from OpenAL 1.0. Using the old way did not break the build as demanded by the spec but disabled the effect for at least the OpenAL Soft implementation.
With this small change, the doppler effect works with OpenAL Soft again. I chose to drop support for the OpenAL 1.0 way of setting up the doppler effect since I don't think such old implementations see widespread use anymore.
Anyway, during testing I noticed the effect to be unstable for motor sounds when vehicle become unstable under high force conditions. I don't remember this to be the case from the RoR 0.38 days. I'm not sure if this is because I run RoR in a VM (might introduce timing issues) or use the OpenGL renderer (there were some physics instabilities with OpenGL that were not present with DirectX almost 10 years ago, but they have been fixed back in the day. I'm not sure if there are still any differences between rendering systems).
Also note that the value for alDopplerVelocity
seems to have been incorrect all this time, assuming that 1 RoR unit represents 1 meter. The formula for the frequency shift caused by the doppler effect changed with OpenAL 1.1 and if I'm not mistaken, alSpeedOfSound = alDopplerVelocity * 343.3f
.
I'd appreciate it if somebody using Windows could test with DirectX and provide feedback. Best way to see if the effect is unstable is by making sharp turns with a fast vehicle (I used Nissan GT-R
and BMW E36 Polizei Sedan
for testing).
Regardless, It might make sense to make the effect an optional setting, what do you think?