godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.88k stars 20.15k forks source link

Doppler Effect Cuts off at Certain Speed #38143

Open ngreve opened 4 years ago

ngreve commented 4 years ago

Godot version: v3.2.2.beta.custom_build.c7ad8f539

OS/device including version: Linux

Issue description: When using the Doppler effect on an AudioStreamPlayer3D the audio gets cut off, when the object its used on reaches a certain speed.

This video shows a cube accelerating towards the camera, while playing a rocket engine sound. At the ~3rd second the Doppler effect stops abruptly. doppler_audio_bug.zip

Steps to reproduce:

  1. Add AudioStreamPlayer3D to RigidBody
  2. Continue to call add_central_force() on the object while playing a sound with doppler_tracking activated (Idle or Physics).

Minimal reproduction project: doppler_audio_bug.zip

ellenhp commented 3 years ago

I think this was intentional. The current doppler tracking code cuts out after shifting the sound three octaves. The tricky part is that at some point you have to do more than just pitch shift to accurately portray doppler shift. The easiest way to conceptualize this to think about how a sonic boom is more than just a pitch shift. As a workaround you can try and do that acoustic modeling yourself and adjust pitch_scale. It seems tricky though.

Calinou commented 2 years ago

Should the doppler effect be clamped to 3 octaves instead of being cut abruptly? If not, I guess we should just document this in the class reference.

ellenhp commented 2 years ago

It is currently clamped, yeah. It's just hard to justify getting much closer to the speed of sound without actually doing the math to determine what it sounds like at that speed. https://github.com/godotengine/godot/blob/43cc6dd4798a348f35da5e404d4b2cd8ff8a9042/scene/3d/audio_stream_player_3d.cpp#L489