cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to spatialize the remote talker voice (AudioComponent)

m_milazzo
Level 4
I'm trying to spatialize players' voice by attaching their voice to their character.
I succeeded in doing this with the Null subsystem with the following code:
TArray<UAudioComponent*> USessionVoiceManager::GetAudioComponents() {
TArray<UAudioComponent*> audioComponents = TArray<UAudioComponent*>();
TArray<FActiveSound*> activeSounds = MyGameInstance->GetEngine()->GetMainAudioDevice()->GetActiveSounds();
for (int i = 0; i < activeSounds.Num(); i++) {
FActiveSound* activeSound = activeSounds;
UAudioComponent *audioComponent = UAudioComponent::GetAudioComponentFromID(activeSound->GetAudioComponentID());
if (audioComponent != nullptr) {
activeSound->bAlwaysPlay = true;
activeSound->bIsUISound = false;
activeSound->bAllowSpatialization = true;

audioComponents.Add(audioComponent);
}
}

return audioComponents;
}

i.e. I take all the active sounds, I search for those associated with an AudioComponent and, only on these, I set some boolean properties (is not UI sound, allow spatialization).

In my blueprint I call this function and, for each AudioComponent, I attach it to the relative player.
Before of attaching it I apply to the AudioComponent the following Attenuation Settings.
0xouqn0exsse.jpg

It works very well with the Null subsystem. Sounds are spatialized and attenuated relatively to the players' positions. But neither spatialization nor attenuation work when changing the subsystem with the Oculus' one (I correctly retrieve the AudioComponent, but it seems it ignore my Attenuation Settings).

Is there something else I need to do in order to let it work with Oculus?
2 REPLIES 2

m_milazzo
Level 4
Hi @imperativity
this seems to solve our problem. The AudioComponent is not created by me, so I performed the following steps around the attenuation settings:
- Deactivate();
- SetUISound(false)
- bAllowSpatialization = true;
- setted the attenuation settings
- Activate();

Another related question: is there a way to know which player is responsible for a particular AudioComponent?
The OnlineVoiceOculus.h contains a private field named RemoteTalkerBuffers:
typedef TMap<class FUniqueNetIdOculus, FRemoteTalkerDataOculus> FRemoteTalkerData;
/** Data from network playing on an audio component. */
FRemoteTalkerData RemoteTalkerBuffers; 
The class FRemoteTalkerDataOculus has a reference to the player's AudioComponent.
This field, RemoteTalkerBuffers, is actually used in the OnlineVoiceOculus.cpp to manage the remote talker's AudioComponent.

So, is there a way to access these map's data (since the map is private) to know what is the AudioComponent of a specific remote talker?

Thanks for your help!

m_milazzo
Level 4
Hi @imperativity
we are stuck on this problem. Is there something we can do (maybe not now but in the next future) to map AudioComponents to FUniqueNetIds?