Search Unity

(Facepunch.Steamworks) Voice is not working

Discussion in 'Multiplayer' started by BurSari92, May 19, 2019.

  1. BurSari92

    BurSari92

    Joined:
    Sep 4, 2015
    Posts:
    3
    Hi,
    I am trying to get my voice in "realtime" with the Facepunch.Steamworks library -> for later use as an VOIP game client.
    But instead of hearing myself, I am getting strange beep noises only...
    I really can´t figure out, what i am missing to hear my voice.

    Here is the code i am working on right now:

    Code (CSharp):
    1.  
    2.     void Update()
    3.     {
    4.         VoiceChat();
    5.     }
    6.  
    7.     void VoiceChat()
    8.     {
    9.         var stream = new System.IO.MemoryStream();
    10.         var output= new System.IO.MemoryStream();
    11.  
    12.         SteamUser.VoiceRecord = Input.GetKeyDown(KeyCode.K);
    13.  
    14.         if (SteamUser.HasVoiceData)
    15.         {
    16.             int length = SteamUser.ReadVoiceData(stream);
    17.             SteamUser.DecompressVoice(stream, length, output);
    18.  
    19.             AudioClip audioClip = AudioClip.Create("WAV", length, 1, 22050, false);
    20.             float[] floatArray = new float[length / 2];
    21.             print(floatArray.Length);
    22.             for (int i = 0; i < floatArray.Length; i++)
    23.             {
    24.                 try
    25.                 {
    26.                     floatArray[i] = (short)(stream.GetBuffer()[i * 2] | stream.GetBuffer()[i * 2 + 1] << 8) / 32768.0f;
    27.                 }
    28.                 catch
    29.                 {
    30.                     break;
    31.                 }
    32.             }
    33.             audioClip.SetData(floatArray, 0);
    34.             GetComponent<AudioSource>().clip = audioClip;
    35.             GetComponent<AudioSource>().Play();
    36.         }
    37.     }
    I am using the newest 2.0.a1 release.

    I also unsuccessfully tried "output" instead of "stream".
    I think SteamUser.DecompressVoice is not doing anything at all.

    Could someone please help me out, fixing this issue.
    Thanks in advance!
     
  2. Weverson

    Weverson

    Joined:
    May 25, 2018
    Posts:
    1
    Did you manage to solve this problem?