Not both transmitting voice, but just the client that was started last

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Not both transmitting voice, but just the client that was started last

Philipp
2016-07-13 18:40:42

Does any possible explanation for this behavior come to mind?

  • I have 2 clients to test -- whichever I start first will be able to hear the other, but the other won't be able to transmit to the first
  • when I then stop the Unity client who started, then run it again, finally both will transmit their audio (auto disconnect is set to off)

Thanks!

Comments

JohnTube
2016-07-14 07:34:03

Hi @Philipp,

To describe the issue:
When you start 2 clients: first one does not transmit sound or second does not play received sound; you hear sound in first client only. But when you restart first client everything works. Is that it?

We are going to need more information in order to reproduce this, like:

  • Versions: Unity, PUN, PUN Voice
  • Target Platform

And if possible any Unity Editor logs or other logs (logcat etc.).

Philipp
2016-07-14 08:06:01

Thanks John. To clarify, the first client started does not even transmit the sound. It's voice.IsTransmitting is false and it looks like it's failing to detect anything from the audio stream, even though recorder and speaker had been set up for it. But as soon as I restart that first Unity session (while the formerly second client still runs and holds on to that created voice room) then it all works suddenly in both directions. I've tried all of this both with voice detection on and off, or really low thresholds, always the same.

I'm using the very latest versions -- downloaded the currently newest Voice wrapper which also seems to come with the network utlities and such, so it's now PUN v1.72 and Voice v1.4 -- and it runs on Windows 10, Unity 5.4.

Philipp
2016-07-14 08:14:15

( Here's what we're working on... this doesn't explain the issue, but maybe it entertains! https://www.youtube.com/watch?v=0M4XBe5GqFM )

JohnTube
2016-07-14 11:09:28

Very nice! I really like the concept of Anyland. Good job!

We will try to reproduce the issue and let you know.
If we don't, we may need you to send us a repro project via email.

vadim
2016-07-14 11:47:01

Hi Philipp,

Logs from failing client can help us find out the reason.

Did you try same scenarios for demos? Does they fail the same way?
When voice autodetection is off (right option for debugging), voice.IsTransmitting can be false only if voice.Transmit set to false. PhotonVoice initializes the latter property with PhotonVoiceSettings.AutoTransmit. Make sure that it's set to true via this setting or explicit call in your code.

Philipp
2016-07-14 11:52:39

Thanks. Transmit was set to true, and yes, the demo worked. Some of our issues may be that we had to rewrite quite a bit of your voice code to get it to work for non-prefabs, which we are dealing with in our case... we're also using SteamVR and their user objects.

Thanks again, we now tried switching to DFVoice for the moment (that works on non-prefabs and was easy to include, and it's also using Photon), but if we go back to Photon Voice maybe there's a way to send you guys the code then.

Would be lovely to get a reply to my question here in any case:
http://forum.photonengine.com/discussion/8020/photon-voice-compared-to-dfvoice#latest

mahmoud93p
2016-07-20 13:12:02

@JohnTube wrote:

Hi @Philipp,

To describe the issue:
When you start 2 clients: first one does not transmit sound or second does not play received sound; you hear sound in first client only. But when you restart first client everything works. Is that it?

We are going to need more information in order to reproduce this, like:

  • Versions: Unity, PUN, PUN Voice
  • Target Platform

And if possible any Unity Editor logs or other logs (logcat etc.).

exactly this problem , but how to solve this issues !

mahmoud93p
2016-07-21 20:34:02

anyone solve this problem ?

JohnTube
2016-07-29 13:39:56

Hi @mahmoud93p,

I apologize about the delay.

Can you please send us a reproduction project to [email protected] so we can help you as we can't reproduce this.

drohack
2016-08-24 17:57:18

Was this ever solved? I am having a similar issue. (Unity 5.4. PUN 1.74, and PhotonVoice 1.5.... I see that both of these have newer versions as of last night.)

I am using the Photon Lobby to make a room and for people to join. Then when the game starts it loads all players in the room to a new Game scene. Currently voice is only enabled for this Game scene as the new scene loads the player prefab that has the Photon audio scripts attached to it (only enabling the recorder for the current player).

Issue:
After the Game scene is loaded for the first time no players can hear each other.
If a player leaves the game and re-enters OR if a new player enters the game after it has already started (the Game scene is already created) all players can hear the returning/new player.

No error or debug messages are being thrown.

I have not checked what the voice.isTransmitting is set to in these situations.

I did put a PhotonVoiceSettings script in both the Lobby and Game scene so I can edit those settings (if not the default one is created in the _singleton). And when I start the game I see the PhotonVoiceNetwork object is created in the _singleton (DontDestroyOnLoad) (this is present in the Lobby and Game scene. I'm not entirely sure what's creating it in the Lobby.).

The Push-To-Talk Demo worked just fine, but for some reason the other Demo did not work (I did not look deeply into why this one did not work).

Also as a side note the game isn't set up for players to join already running games. These will be closed in the future, but during development it has been useful to have this enabled for debugging.

drohack
2016-08-25 02:08:06

More information.
I updated to the latest versions of both PUN (1.75) and PhotonVoice (1.6). The issue still persists.

I turned on logging and checked the voice.isTransmitting variable and when players first join in the game the voice.isTransmitting variable is always "false". When a player re-joins a game (or enters and existing game) the voice.isTransmitting turns to "true" when it detects audio.

Here are my logs:

START APPLICATION (join Lobby):
PUNVoice: connecting to region us
UnityEngine.Debug:LogFormat(String, Object[])
PhotonVoiceNetwork:Connect() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:114)
UnityVoiceClient:OnStateChange(ClientState) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:536)
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:set_State(ClientState) (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:283)
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Disconnect() (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:796)
UnityVoiceClient:Reconnect() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:343)
PhotonVoiceNetwork:OnJoinedRoom() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:254)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
NetworkingPeer:SendMonoMessage(PhotonNetworkingMessage, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2588)
NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2329)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:153)

START GAME (enter into new Game scene):
PUNVoice: Setting recorder's microphone device to
UnityEngine.Debug:LogFormat(String, Object[])
PhotonVoiceRecorder:Start() (at Assets/PUNVoice/Scripts/PhotonVoiceRecorder.cs:243)

PUNVoice: Player 2 voice # 1 speaker created.
UnityEngine.Debug:LogFormat(String, Object[])
UnityVoiceClient:linkVoice(Int32, Byte, VoiceInfo, PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:405)
UnityVoiceClient:OnRemoteVoiceInfo(Int32, Byte, VoiceInfo) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:435)
ExitGames.Client.Photon.Voice.Client:onVoiceInfo(EventData, Object) (at Assets/Plugins/PhotonVoiceApi/Client.cs:773)
ExitGames.Client.Photon.Voice.Client:onEventActionVoiceClient(EventData) (at Assets/Plugins/PhotonVoiceApi/Client.cs:674)
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnEvent(EventData) (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:2446)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:Service()
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Service() (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:845)
ExitGames.Client.Photon.Voice.Client:Service() (at Assets/Plugins/PhotonVoiceApi/Client.cs:421)
PhotonVoiceNetwork:Update() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:202)

LEAVE GAME (return to Lobby):
PUNVoice: Player 2 voice # 1 speaker unlinked.
UnityEngine.Debug:LogFormat(String, Object[])
UnityVoiceClient:UnlinkSpeakerFromRemoteVoice(PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:488)
PhotonVoiceNetwork:UnlinkSpeakerFromRemoteVoice(PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:296)
PhotonVoiceSpeaker:OnDestroy() (at Assets/PUNVoice/Scripts/PhotonVoiceSpeaker.cs:184)

RE-JOIN GAME (re-enter Game scene):
PUNVoice: Setting recorder's microphone device to
UnityEngine.Debug:LogFormat(String, Object[])
PhotonVoiceRecorder:Start() (at Assets/PUNVoice/Scripts/PhotonVoiceRecorder.cs:243)

PUNVoice: Player 2 voice # 1 speaker created.
UnityEngine.Debug:LogFormat(String, Object[])
UnityVoiceClient:linkVoice(Int32, Byte, VoiceInfo, PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:405)
UnityVoiceClient:LinkSpeakerToRemoteVoice(PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:449)
PhotonVoiceNetwork:LinkSpeakerToRemoteVoice(PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:288)
PhotonVoiceSpeaker:Awake() (at Assets/PUNVoice/Scripts/PhotonVoiceSpeaker.cs:63)
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
NetworkingPeer:DoInstantiate(Hashtable, PhotonPlayer, GameObject) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3055)
NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2386)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:153)

PUNVoice: Player 2 voice # 1 speaker unlinked.
UnityEngine.Debug:LogFormat(String, Object[])
UnityVoiceClient:OnRemoteVoiceRemove(Int32, Byte) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:463)
ExitGames.Client.Photon.Voice.Client:clearRemoteVoices() (at Assets/Plugins/PhotonVoiceApi/Client.cs:716)
ExitGames.Client.Photon.Voice.Client:onEventActionVoiceClient(EventData) (at Assets/Plugins/PhotonVoiceApi/Client.cs:640)
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnEvent(EventData) (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:2446)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:Service()
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Service() (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:845)
ExitGames.Client.Photon.Voice.Client:Service() (at Assets/Plugins/PhotonVoiceApi/Client.cs:421)
PhotonVoiceNetwork:Update() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:202)

PUNVoice: Player 2 voice # 1 speaker created.
UnityEngine.Debug:LogFormat(String, Object[])
UnityVoiceClient:linkVoice(Int32, Byte, VoiceInfo, PhotonVoiceSpeaker) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:405)
UnityVoiceClient:OnRemoteVoiceInfo(Int32, Byte, VoiceInfo) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:435)
ExitGames.Client.Photon.Voice.Client:onVoiceInfo(EventData, Object) (at Assets/Plugins/PhotonVoiceApi/Client.cs:773)
ExitGames.Client.Photon.Voice.Client:onEventActionVoiceClient(EventData) (at Assets/Plugins/PhotonVoiceApi/Client.cs:674)
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnEvent(EventData) (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:2446)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:Service()
ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Service() (at Assets/Plugins/PhotonLoadbalancingApi/LoadBalancingClient.cs:845)
ExitGames.Client.Photon.Voice.Client:Service() (at Assets/Plugins/PhotonVoiceApi/Client.cs:421)
PhotonVoiceNetwork:Update() (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:202)

drohack
2016-08-25 04:16:22

We found a workaround, but don't know why it's working this way (and doesn't work normally).
In the Player object that enables the PhotonNetworkRecorder (photonView.isMine) we added this code to the Update() function:

if (photonVoiceRecorder != null && photonVoiceRecorder.enabled && !photonVoiceRecorder.Transmit)  
        {  
            Debug.Log("Turn on Transmit");  
            photonVoiceRecorder.Transmit = true;  
        }

(what's the bracket for code?)

We tried adding this to the Awake() and Start() function of the Player object, but that didn't work. It had to be delayed enough maybe?

Either way we got to this point because of the Push-To-Talk Demo which checks to see if a button is pressed and turns the Transmit to "true", but if not turn it to "false". This works correctly in our game as well. So we figured that some how Transmit wasn't being set correctly when PhotonVoiceRecorder is set to enabled (turned on) when the room is starting up? but it works if the room is already created?

Philipp
2016-08-25 05:28:45

Thanks for posting your update drohack!

JohnTube
2016-08-25 19:32:04

Hi @mahmoud93p, @Philipp, @drohack,

Thank you for your reports.

I think this may be a "timing issue", somehow the "PhotonVoiceRecorder" component of the first instantiated character misses the join event. That's why @drohack's workaround that forces transmission state fixes this. But it shouldn't be a permanent solution.

However, I can't reproduce it. Can you please send us a minimal reproduction project to [email protected]? Please put a link to this discussion and mention that Hamza asked for a reproduction project.

@drohack,

for some reason the other Demo did not work (I did not look deeply into why this one did not work).
You need to set PhotonVoiceSettings.AutoTransmit to true or toggle "Transmit" on from the scene. Please verify this and also toggle "DebugVoice" to see voice client state.
I'm not entirely sure what's creating it in the Lobby.
Starting from Photon Voice 1.5, "PhotonVoiceNetwork" singleton is created automatically without any user action. This is happening thanks to RuntimeInitializeOnLoadMethodAttribute.
(what's the bracket for code?)
(for code blocks use <pre> and <code> tags or select multiple lines and apply code style using post editor.)

angecroft
2016-08-30 14:14:58

@drohack wrote:

We found a workaround, but don't know why it's working this way (and doesn't work normally).
In the Player object that enables the PhotonNetworkRecorder (photonView.isMine) we added this code to the Update() function:

if (photonVoiceRecorder != null && photonVoiceRecorder.enabled && !photonVoiceRecorder.Transmit)  
       {  
           Debug.Log("Turn on Transmit");  
           photonVoiceRecorder.Transmit = true;  
       }

(what's the bracket for code?)

We tried adding this to the Awake() and Start() function of the Player object, but that didn't work. It had to be delayed enough maybe?

Either way we got to this point because of the Push-To-Talk Demo which checks to see if a button is pressed and turns the Transmit to "true", but if not turn it to "false". This works correctly in our game as well. So we figured that some how Transmit wasn't being set correctly when PhotonVoiceRecorder is set to enabled (turned on) when the room is starting up? but it works if the room is already created?

Hi I have EXACTLY the same issue ! The AutoTransmit is set to true, also in the Start function of the player but it does not work !

I call a StackTrace in the setter of the Transmit boolean, and all it gots is True, but anyway in Update() it prints false ! It works fine by this hack (I have done the same) but I need to sometimes let the player control if he wants to transmit his voice, mute the others ....

Last version of Unity, PUN & Photon Voice

JohnTube
2016-08-31 10:06:58

Hi @angecroft,

Do you switch scenes when joining a room as @drohack does?

@mahmoud93p and @Philipp what about you?

angecroft
2016-08-31 10:09:33

Yes, I have a different scene for the lobby and the room. When I have joined a room, I load the scene.

JohnTube
2016-09-13 12:04:01

Hi @angecroft, @drohack, @mahmoud93p, @Philipp,

I'm still assuming you all have the same issue.
Do you still have this issue in last Voice versions?

I was assuming this issue is related to changing scene. I could not produce this issue with two scenes: one to connect and switch to the other when joined. I use PhotonNetwork.LoadLevel for scene switching and I instantiate voice prefab in the 2nd scene as soon as loaded.

Could you please send us reproduction project to [email protected]?

Alex333
2016-09-21 21:05:22

We have the same problem. if done right on stage and start , voice chat works. But we have a menu with scene selection(room) scenes are downloadable. And after download scene voice chat not working.

JohnTube
2016-09-22 07:55:07

Hey @Alex333, everyone,

My colleague @vadim might have fixed this already but voice package is not updated yet.
Please check if this is the right fix for this issue, the idea is simple we should run the code that starts voice transmission when the "PhotonVoiceRecorder" is initialized (after prefab creation) and not only when we receive the voice room join event. As sometimes this event is sent before prefab instantiation.

Here is what is needed:

Either make a call to OnJoinedVoiceRoom() in PhotonVoiceRecorder.Start() or copy paste its code there:

// give user a chance to change MicrophoneDevice in Awake()  
    void Start()  
    {  
         /*  
             old init. code  
         */      
           OnJoinedVoiceRoom();  
        }

or

// give user a chance to change MicrophoneDevice in Awake()  
    void Start()  
    {  
         /*  
             old init. code  
         */      
            if (this.voice != Voice.LocalVoice.Dummy)  
            {  
                this.voice.Transmit = PhotonVoiceSettings.Instance.AutoTransmit;  
            }   
            else if (PhotonVoiceSettings.Instance.AutoTransmit)  
            {  
                Debug.LogWarning("PUNVoice: Cannot Transmit.");  
            }  
        }

Alex333
2016-09-22 15:59:12

the chat is connected everything is OK
the voice from the microphone does not send , only the sounds of the game instead of the voice.

Alex333
2016-10-30 00:13:05

Good afternoon. Decided to add a Ui on the screen to understand what was going on. and saw a top that PUN Voice - Uninitialized. How to fix it. in file serversettings added iD (there is a checkmark AutoLobby)

Tobias
2016-11-02 09:39:54

@Alex333: Did you check this with the latest PUN Voice package? Does it work now?

Alex333
2016-11-02 12:57:28

I updated Voice chat and I have 11 errors. Assets/Plugins/PhotonVoiceApi/Main/VoiceClient.CS(23,10): error CS0101: ExitGames namespace.Client.Photon.The voice' already contains a definition for EventCode' (IAudioStream, VoiceInfo , RemoteVoiceInfo ....... etc.) how to solve them?

Alex333
2016-11-02 19:19:57

I updated pun and voice chat and everything works. But there is one problem. when my character stands still , the voice is transmitted , everything is fine, but when my player starts to go , there is 2 errors. Voice chat starts to process steps of the character. -(( BUT this is related to my project.

Alex333
2016-11-02 19:49:02

During the game, in the hierarchy appears PhotonVoiceNetworkSingleton. As it is possible to change the settings and save???

vadim
2016-11-03 13:04:38

You can add PhotonVoiceSettings script in the scene and change the settings in editor. Settings are not designed to be changed in realtime. See /Assets/PUNVoice/readme.txt for details.

Alex333
2016-11-03 13:24:13

If I create a dummy with this script PhotonVoiceSettings . it still adds the game object PhotonVoiceNetworkSingleton upon accession of the player And then the error occurs.

Alex333
2016-11-03 15:33:46

my problem isn't solved

vadim
2016-11-04 08:51:24

Which problem exactly? You reported at least 2. From http://forum.photonengine.com/discussion/comment/30832/#Comment_30832 it seems like only one issue is still open but it's not related to Photon voice.

Alex333
2016-11-04 17:05:27

After some modifications , we all did. thanks for the help

Back to top