resonance-audio / resonance-audio-unity-sdk

Resonance Audio SDK for Unity
https://resonance-audio.github.io/resonance-audio/develop/unity/getting-started
Other
297 stars 38 forks source link

Reverb always at full volume at any distance #35

Open AtomicJoe1 opened 6 years ago

AtomicJoe1 commented 6 years ago

I set up a Resonance Audio Room of 100m3, put an audio source with it's Resonance Audio Source component in the middle of the room. As I go away from the audio source, the direct audio volume from the source goes down but the reverb volume is always at full blast, even at 50m of distance. I don't know if this is a bug or the intended functionality. I understand reverb are reflections on the walls of the virtual room and you could argue this is how reverb works in real life, but the effect is not realistic since it removes any spatialization of the sound and all sound sources inside a virtual room will sound equally louder at ANY distance, turning the reverb into pure background noise composed of all sound sources at all distances mixed together at the same volume. Unity 2017.4.3f1 with resonance v1.2.1

yeroro commented 6 years ago

Hi,

This is the intended behavior. As the reverb is the effect of high-order reflections, it should be almost the same everywhere in the room. In fact, the ratio of the direct sound vs reverb is an important cue for humans to feel how far the sound source is.

With that said, I understand why you feel it is not realistic. Here are my thoughts:

  1. A 100m^3 room is rather large, so if the materials are rather reflective (e.g. marble), you'd expect that the reverb tail is really long.
  2. However, since it's so large, the sound energy should spread "thinner" in the room, which means the "amplitude" should be lower. This can be achieved by adjusting the "Reverb Gain" of the Audio Room.

So the effect that's closest to a real life experience would be a dim (low energy) reverb, but lasting very long.

We didn't provide the functionality to automatically adjust the gain based on the room size. Perhaps this can be added in the future.

AtomicJoe1 commented 6 years ago

I understand your point and although it is correct, in practice, we need more control over our audio sources effect on the room reverb. I have modified the ResonanceAudioSource.cs script to account for the Reverb Zone Mix curve in the audio source component, since it is ignored by resonance audio. The reverb contribution now can be managed using the "Reverb Zone Mix" slider in the audio source directly or using a custom reverb curve in the editor. Just as the regular Unity reverb does. The only changes are in

ResonanceAudio/Scripts/ResonanceAudioSource.cs in the UpdateSource method: line 175-176:

        bypassRoomEffects ? 0.0f
                          : ResonanceAudioRoomManager.ComputeRoomEffectsGain(transform.position) * audioSource.GetCustomCurve(AudioSourceCurveType.ReverbZoneMix).Evaluate( Mathf.Max( 0f, Vector3.Distance( transform.position, ResonanceAudio.ListenerTransform.position ) / audioSource.maxDistance ) ) );

Maybe you could integrate this mod since I think it will be useful to other people.

Now, if you set a curve for the reverb zone mix in the audio source, the reverb of this specific audio source lowers as the distance to the listener increases: (yellow curve)

audiosource reverb curve