public void PlayAudio(OpusData opusData)
 {
     if (currentAudioFrameCount != opusData.FrameCount)
     {
         currentAudioFrameCount = opusData.FrameCount;
         m_OpusPlayer.PlayAudio(opusData);
     }
 }
 void OnEncoded(byte[] data, int length, int frameCount)
 {
     voiceData = new OpusData
     {
         Bytes         = data,
         EncodedLength = length,
         FrameCount    = frameCount
     };
     client.PlayerDataAsync(playerParts, voiceData);
 }
Beispiel #3
0
        public void PlayAudio(OpusData opusData)
        {
            if (opusData == null)
            {
                return;
            }

            var pcmLength = decoder.Decode(opusData.Bytes, opusData.EncodedLength, pcmBuffer);

            if (audioClipData == null || audioClipData.Length != pcmLength)
            {
                audioClipData = new float[pcmLength];
            }
            Array.Copy(pcmBuffer, audioClipData, pcmLength);
            audioSource.clip.SetData(audioClipData, head);
            head += pcmLength;

            if (!audioSource.isPlaying && head > audioClipLength / 2)
            {
                audioSource.Play();
            }
            head %= audioClipLength;
        }
 public async Task PlayerDataAsync(Part[] parts, OpusData voiceData)
 {
     self.Parts     = parts;
     self.VoiceData = voiceData;
     BroadcastExceptSelf(room).OnPlayerData(self);
 }
Beispiel #5
0
 public Task PlayerDataAsync(Part[] parts, OpusData voiceData)
 {
     return(client.PlayerDataAsync(parts, voiceData));
 }