This document is about: FUSION 1
SWITCH TO

このページは編集中です。更新が保留になっている可能性があります。

Dynamic Audio group


Available in the Industries Circle
Circle
Fusion Industries prototyping Addons

Dynamic Audio group

The dynamic audio group feature allows to discuss with all the remote users around the local one, without using bandwidth or adding noise from user afar.
Users beyond a defined distance are not heard.
Coupled with a adapted sound spatialization and attenuation, this provides a natural listening sensation.

The current implementation is based on Photon Voice interest groups.

Each user will speak in one unique interest group and it will never be changed.
However, the list of groups he listens to is dynamically modified according to the proximity of the other players limiting the needed bandwidth.
Moreover, isolated people don't send their voice over the network to even further avoid consuming bandwidth.

This feature rely on the DynamicAudioGroupMember class.

DynamicAudioGroupMember

DynamicAudioGroupMember is located on each network player prefab
In the Spawned(), a unique audio GroupId is computed for the player (in other words, each player has it own GroupId).
Then, the local player Recorder audio interest group is configured with this GroupId and the voice client is configured to listen it.

C#

async void SpeakAndListenOnlyToGroup(byte groupId)
{
...
    recorder.InterestGroup = groupId;
    fusionVoiceClient.Client.OpChangeGroups(groupsToRemove: new byte[] { }, groupsToAdd: new byte[] { groupId });
...
}

To update the groups the player listens to, we check if other players are within the defined distance during the Update().

C#

private void Update()
{
    CheckProximity();
}

For each player found at proximity, the local player starts to listen the GroupId of the remote player.

C#

private void CheckProximity()
{
...
    if(DistanceSqr(member) < proximityDistanceSqr)
    {
    ...
        ListentoGroupId(member.GroupId);
    }
...
}

C#

async void ListentoGroupId(byte groupId)
{
    if (!Object.HasStateAuthority) return;
    while (!IsPhotonVoiceready || !isSpeakInitialized) await Task.Delay(10);
    fusionVoiceClient.Client.OpChangeGroups(groupsToRemove: null, groupsToAdd: new byte[] { groupId });
}

Conversely, if a remote player is no longer in the proximity perimeter, then he is no longer listened to thanks to the StopListeningToGroupId() method.

Because these operations are performed by all the players, a two-way conversation is possible although each player sends his voice only in his own GroupId.

Also, because the player may be close to another player but in a different closed room, CheckProximity() checks whether the member should stop listening to another member if the room is isolated (the additionalGroupFilter parameter is set in AudioRoomMember when a user is in an isolated room).

C#

if(additionalGroupFilter != member.additionalGroupFilter)
    {
    // No matching filter
    StopListeningToMember(member);
    }

Demo

To illustrate the usage, a demo scene can be found in Assets\Photon\FusionAddons\DynamicAudioGroup\Demo\Scenes\DynamicAudioGroup.unity.

Fusion Industries Addon Dynamic Audio Group

Connect multiple clients and observe the information panel associated with each player.
Each player is surrounded by two spheres.
The green sphere is the area that will start listening to another player as soon as his head enters it.
Listening will stop as soon as the head leaves the red sphere.

Download

This addon latest version is included into the addon project

Supported topologies

  • shared mode

Changelog

  • Version 1.0.2: Fix error in DisplayDynamicAudioGroupInfos when listened member disconnected
  • Version 1.0.1: Add demo scene + add namespace
  • Version 1.0.0: First release
Back to top