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

PhilippPhilipp
edited July 2016 in Photon Voice
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!
«1

Comments

  • 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.).
  • PhilippPhilipp
    edited July 2016
    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.
  • ( Here's what we're working on... this doesn't explain the issue, but maybe it entertains! https://www.youtube.com/watch?v=0M4XBe5GqFM )
  • 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.
  • vadimvadim ✭✭✭
    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.
  • PhilippPhilipp
    edited July 2016
    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
  • JohnTube said:

    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 !
  • anyone solve this problem ?
  • JohnTubeJohnTube mod
    edited August 2018
    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.
  • 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.
  • 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)

  • drohackdrohack
    edited August 2016
    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?
  • Thanks for posting your update drohack!
  • JohnTubeJohnTube mod
    edited August 2016
    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.)
  • drohack said:

    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
  • Hi @angecroft,

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

    @mahmoud93p and @Philipp what about you?
  • Yes, I have a different scene for the lobby and the room. When I have joined a room, I load the scene.
  • 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]?
  • 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.
  • 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.");
                }
            }
  • 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.
  • 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)
  • @Alex333: Did you check this with the latest PUN Voice package? Does it work now?
  • 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?
  • 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.
  • During the game, in the hierarchy appears PhotonVoiceNetworkSingleton. As it is possible to change the settings and save???
  • vadimvadim ✭✭✭
    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.
  • 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.
  • Alex333Alex333
    edited November 2016
    my problem isn't solved
  • vadimvadim ✭✭✭
    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.
Sign In or Register to comment.