Problem: players hear only the master-client's sounds

Hello, dear friends!

I have creates voice communication between players in the room as in documentation. But I find out several problems.

1) A problem #1:
After applications' launch the first player doesn't hear in general whose sounds. All others (which have started after master-client) hear only the first (only master-client). Why it so, I can't understand...

2) Problem #2:
I would like that each player would hear sounds of others like usual AudioSource. That is at a long distance from a sound source the player shouldn't hear a sound of other player. And vice versa - at approach to other player my player has to hear how the loudness of other player increases. Whether it is possible to make it?

3) Problem #3:
When changing the audioclip at the PhotonVoiceRecorder component this component continues to broadcast the first audioclip which was we will appoint to it at start of the application. How it is possible to solve this problem?

4) Main task:
The main task for me is that each player heard a voice or playing of the audioclip of all other players. At the same time I would like that the sound at each player was heard taking distance of sources of a sound of all other players.

Here in the pictures is my settings and a script for understanding:
https://drive.google.com/open?id=0B-tYImH-leb-UlFrZzd3TldiSFk
https://drive.google.com/open?id=0B-tYImH-leb-RHBEWDJ5VnVkZXM
https://drive.google.com/open?id=0B-tYImH-leb-cTVzQUtsdGVHN00

In the picture with three applications top application is Master-client (runned first). Apparently on the picture, at the master-client the sound from other players is false. At the same time at other players their audioclips are played, but AudioDetector either shows a false, or isn't created (null) at all:
https://drive.google.com/open?id=0B-tYImH-leb-UnRodnZFLTltNHM

Dear friends, I will be very grateful to you for your help.
I wish you success too!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2017
    Hi @SN_007,

    1) Safety check (PUN): Are you sure all players are on the same AppId / AppVersion / Region ? Add those to your console / visual logs. And you can take a look at our "Matchmaking Checklist".

    2) This is handled by Unity's built-in component. We do not provide something out-of-the box in Photon Voice but it does not require anything extra since PUN can sync. the positions. You only need to tweak the "3D Sound Settings" of Audio Source component.

    3) Why do you need to switch AudioClip? And how do you do it (show us some code)?

    4) I did not quite understand the use case...

    Try removing or disabling NetworkVoiceClient component and see if it fixes the issues.
    Why do you explicitly set the microphone? We do that for you as it seems you are using the default (first element in array) as well.
  • SN_007
    SN_007
    edited August 2017
    Hello, John! Thank You very much for Your attention and Your help. I did all tasks above. I once again could be convinced what excellent product the Photon. However, there is one thing which You could improve in the Photon.

    I make the project in VR (HTC Vive). As You know, player's position is different in comparison his camera's position in VR. This difference can be about 1-2 meters. This is very important value for the realistic sound's imitation in 3D space. In that case existence of a AudioSource directly at the player is undesirable.

    Therefore (please, pardon me) I have been compelled to make a little changes of PhotonVoiceRecorder (I removed the string [RequireComponent(typeof(AudioSource))]) and PhotonVoiceSpeaker's script like the fragment below:

    using UnityEngine;
    /// <summary>
    /// Component representing remote audio stream in local scene. Automatically attached to the PUN object which owner's instance has streaming Recorder attached.
    /// </summary>
    [DisallowMultipleComponent]
    [AddComponentMenu("Photon Voice/Photon Voice Speaker")]
    [HelpURL("https://doc.photonengine.com/en-us/voice/current/getting-started/voice-for-pun#the__audio_source__prefab")]
    public class PhotonVoiceSpeaker : Photon.MonoBehaviour {
    
        [SerializeField]
        private AudioSource audio_source;
    
        private AudioStreamPlayer player;
    
        /// <summary>Time when last audio packet was received for the speaker.</summary>
        public long LastRecvTime { get; private set; }
    
        /// <summary>Is the speaker playing right now.</summary>
        public bool IsPlaying { get { return this.player.IsPlaying; } }
    
        /// <summary>Smoothed difference between (jittering) stream and (clock-driven) player.</summary>
        public int CurrentBufferLag { get { return this.player.CurrentBufferLag; } }
    
        /// <summary>Is the speaker linked to the remote voice (info available and streaming is possible).</summary>
        public bool IsVoiceLinked { get { return this.player != null && this.player.IsStarted; } }
    
        void Awake()
        {
            if( audio_source == null ) audio_source = NetworkPlayer.Instance.Local_player.Player_collider_transform.GetComponentInChildren<AudioSource>( true );
    
            this.player = new AudioStreamPlayer( audio_source, "PUNVoice: PhotonVoiceSpeaker:", PhotonVoiceSettings.Instance.DebugInfo);
            PhotonVoiceNetwork.LinkSpeakerToRemoteVoice(this);
        }
    
    //...
    }


    Think, please: maybe this decision will better for many other programmers? And You can make such changes in further versions? (As You see, such approach very simple, but much more flexible). Because the ideal hierarchy for my VR project looks as on this picture: https://drive.google.com/open?id=0B-tYImH-leb-SkNfSWVsSVYzemM

    Thank You for Your help!
    Best regsrds!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @SN_007,

    Sorry for the delay, I was on vacation last week.

    So moving the AudioSource fixed your problem?
    You are the only customer requesting this and I do not see a reason why we should change this for everyone right now.
  • Hello, John! Thank You :) This was simple my suggestion... The suggestion can let You to make more convinient and flexible script for users. But, as You want... In any case - thank You for Your excellent product!
  • JohnTube said:

    Hi @SN_007,

    So moving the AudioSource fixed your problem?

    Yes - the moving of the AudioSource fixed my problem.