How to implement both 2D and 3D spatial audio effect in one room?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Voice.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How to implement both 2D and 3D spatial audio effect in one room?
Danhua
2020-12-08 01:31:08
Greetings,
I'm using Photon Voice and have implemented 3D spatial audio effect by setting "Audio Source -> Spatial Blend" of Speaker to 1. Now I want to have one player in the room who can hear every other user's voice without moving close to them. But how can I implement this feature while not influencing 3D spatial effect?
I'm using Unity 2019.4.11 & Photon Voice 2.22.2
The setting of Photon Voice is the same as suggested in the tutorial: https://doc.photonengine.com/en-us/voice/current/getting-started/voice-for-pun#suggested_workflow
Thanks in advance!
Comments
Hi @Danhua,
Thank you for choosing Photon!
Depending on the use case you can achieve this in different ways.
I want to have one player in the room who can hear every other user's voice without moving close to them
In this case you just need to set, for this specific player who should hear everyone else regardless of distance, the audioSource.spatialBlend on all AudioSource components attached to the same GameObject as its local Speaker components, back to 0 to disable the 3D effect and revert back to the default 2D.
For other cases, you can have two recorders (outgoing streams) per client one for 2D and one for 3D and make use of interest groups to not have them both at the same time.
Thanks for answering my question! Sorry I didn't follow up timely.
Hope you won't mind if I didn't understand you correctly. Since each player has its own speaker and each speaker has an audio source component, changing each player's speaker by one client will affect the sound effect on other users' end, right? I didn't get what you mean by "the same GameObject". The only objects that have audio source in the scene are the players.
@JohnTube wrote: »
you just need to set, for this specific player who should hear everyone else regardless of distance, the audioSource.spatialBlend on all AudioSource components attached to the same GameObject as its local Speaker components, back to 0 to disable the 3D effect and revert back to the default 2D.
Also, it's my bad that I didn't describe the question accurately. The 3D audio effect doesn't affect the sound attenuation. What I really want to implement is that outside the scope of the Max Distance from other players, I still want one player to hear their voice, while others cannot. It seems to me that the sound attenuation is implemented on speakers rather than listeners and this is where I'm stuck.
Hi @Danhua,
changing each player's speaker by one client will affect the sound effect on other users' end, right?
No it does not. Changing Speaker or respective AudioSource attached to the same GameObject will not have any effect on remote clients but only locally.
I didn't get what you mean by "the same GameObject". The only objects that have audio source in the scene are the players.
The Speaker component is attached to a GameObject that has an AudioSource. that's what I meant.
So what I suggested is to disable 3D sound settings locally on player A using the Speaker/AudioSource component that is playing the sound from player B where you want player A to hear player B no matter what (no matter the distance etc.).
Of course you can do this for more than one player/Speaker.
The 3D audio effect doesn't affect the sound attenuation.
Yes it does, maybe you used the wrong setting or did not test this properly?
It seems to me that the sound attenuation is implemented on speakers rather than listeners and this is where I'm stuck.
Yes that's how it works. The AudioSource defines the behaviour of sound and its effects, it's like an analogy to the actual physical wave, the emitter/source has control over it.
Thanks for your response! This is just what I want to learn!
Back to topNo it does not. Changing Speaker or respective AudioSource attached to the same GameObject will not have any effect on remote clients but only locally.