Feature Request: Doppler clamping

I’m making a dogfighting game, and doppler is used extensively.

Carefully setting the doppler levels is necessary, since any relative speed close to or above the speed of sound will lead to crackling, absent sounds or painfully high pitched instances.

The problem in our case is that the maximums speeds of all emitters, including that of the listener, is subject to rapid iteration and many edge cases.

It would be incredibly helpful to simply be able to set a maximum and minidum doppler pitch modification (equivalent to, say, 80% of the speed of sound) for the whole engine, or even per event.

A maximum calculated pitchFactor of two octaves would be dead simple:

pitchRatio=(c+signedRelativeSpeed)
clampedPitchRatio=Clamp(signedRelativeSpeed, 0.25, 4)

Setting it instead by a minimum and maximum relative speed is also easy

pitchRatio=c/(c+signedRelativeSpeed)
maxPitchRatio=c/(c-280)
minPitchRatio=c/(c+460)
clampedPitchRatio=Clamp(signedRelativeSpeed, minPitchRatio, maxPitchRatio)

a sound approaching at 280m/s would have the same pitch applied as a sound approaching at 800m/s (about 2 octaves up using default doppler value for c)

Right now, the only way to do this in unity is quite bad.

Solution 1: Every event needs a script to set the pitch by hand, either by automation or using setPitch, reimplementing the entire doppler system.

Solution 2: Every event needs a script that calls Set3DAttributes, using either the real velocity, or in case of a detected doppler overflow, invents a new velocity with the same direction but a reduced magnitude to avoid the overflow.

Hi,

I can definitely see the issue. To clarify, are you specifically looking to clamp the effect of doppler shift? Or would scaling it be sufficient? If it’s the latter, you can use System::set3DSettings to set a system-wide scaling factor for doppler shift.

Scaling it would not be enough, as it would either lead to really reducing doppler “just to be safe” or still facing potential unwanted “sonic booms”

Thanks for clarifying. Unfortunately, FMOD doesn’t have the ability to clamp doppler, but I can see the value in the functionality, so I’ve added it to our internal feature request/improvement tracker. In order to handle the clamping yourself, I would recommend going with your second solution, as it’d likely be far simpler than reimplementing the entire doppler system.

Hi there,

Just seconding the need for this - it’s also helpful in cases where you need to limit the contribution of listener velocity

For example, when cycling through differently placed game cameras the Unreal Studio Plugin computes a velocity based on the current position of the player controller’s listener, and the cached value of the FMOD listener.

A temporary workaround I’ve done is to modify FFMODStudioModule::SetListenerPosition mitigate massive shifts in velocity, but a cleaner solution would be the ability to clamp doppler effect at least globally, if not also as part of the event config alongside on/off and scale. (With automation would be nice too…)

Thanks for letting us know! I’ve noted your interested in the feature on our internal improvement tracker.

As for clamping doppler globally, one solution in the UE code side of things specifically would be to duplicate or overload FMODUtils::ConvertWorldVector to clamp the length of the returned FMOD_VECTOR, and use it in place of the existing function when setting velocity attributes - i.e. FFMODStudioModule::SetListenerPosition, UFMODAudioComponent::OnUpdateTransform, and elsewhere your own code.