How to use ChangeAudioGroups?

For reference, I already have photon voice working using push to talk. I want to be able to assign private chat groups though rather than everyone talking on the main channel when they push to talk. I was wondering is someone could help shed some light on the problem I am having with Photon Voice Audio groups? Specifically adding and removing them as done using:

PhotonVoiceNetwork.Client.ChangeAudioGroups(byte[] groupsToRemove, byte[] groupsToAdd);

I have read over this page many times as well as going to the documentation for the Photon with the related process for the server

I have tried creating a byte array and used most every other reference I could find to assigning bytes in C# (using Unity). Either I am missing something or this is an area in which I need to improve my understanding. While I am not asking anyone to write my code for me, could someone please provide a working example (or more documentation) of how to implement adding and removing groups in photon voice?

Thank you in advance to anyone willing to help enlighten me on how to do this.


  • If you use single group, same for sending and listening, then simply set anytime:
    PhotonVoiceNetwork.Client.GlobalAudioGroup = private_room_nr.

    private_room_nr should be a byte unique for each pair of actorid's.

    TestVoice app has sample of GlobalAudioGroup property usage.

    GlobalAudioGroup was introduced to simplify group usage for most common case, so you do not need to deal with arrays designed for more general multiple groups case.
  • Thank you for the quick reply Vadim,

    While that information was helpful in clarifying some things for me, I was partially aware of that function. Specifically, I had already tested GlobalAudioGroup to successfully change the transmit channel of a player, however I did not notice it made a binary pair for switching the receive also since I was only looking at the console feedback. I have tested this function and it works as you described, however I am still in need of the players being able to receive on more than one channel.

    The best way to describe this would be imagine a tactical squad that can pair off into smaller teams of 2 or more but that any player can also put out an emergency call to all players on that team. So while the binary pair function of GlobalAudioGroup can handle the separate channels for the team splitting up, how would I make it so that they could also receive an emergency call on top of the one they might already be on?

    I was hoping this is what I could do by using ChangeAudioGroups since it says a player can listen to more than one group at a time, which I am basically trying to do it seems.

    Thanks again for the help.
  • PhotonVoiceNetwork.Client.ChangeAudioGroups method gives you full control on groups which client listens.
    The parameters described quite clear in documentation:
    groupsToRemove: Groups to remove from listened. Null will not leave any. A byte[0] will remove all.
    groupsToAdd: Groups to add to listened. Null will not add any. A byte[0] will add all current.

    To reset group list and add new groups you need to call something like this:
    ChangeAudioGroups(new byte[0], new byte[]{g1, g2, g3})

    Don't forget also to set group where client sends audio data (only 1 output group supported) via PhotonVoiceRecorder.AudioGroup property.
    You may need to temporary switch this group before 'emergency' call.
Sign In or Register to comment.