// Token: 0x06000471 RID: 1137 RVA: 0x000165C4 File Offset: 0x000147C4
    private void ProcessPendingEncode(float[] pcm)
    {
        int num;

        byte[] encodedData = MoPhoGames.USpeak.Core.USpeakAudioClipCompressor.CompressAudioData(pcm, 1, out num, this.lastBandMode, this.codecMgr.Codecs[this.lastCodec], global::USpeaker.LocalGain);
        MoPhoGames.USpeak.Core.USpeakFrameContainer item = default(MoPhoGames.USpeak.Core.USpeakFrameContainer);
        item.Samples     = (ushort)num;
        item.encodedData = encodedData;
        this.sendBuffer.Add(item);
    }
 // Token: 0x06000463 RID: 1123 RVA: 0x00015A28 File Offset: 0x00013C28
 public void ReceiveAudio(byte[] data)
 {
     if (this.settings == null)
     {
         Debug.LogWarning("Trying to receive remote audio data without calling InitializeSettings!\nIncoming packet will be ignored");
         return;
     }
     if (global::USpeaker.MuteAll || this.Mute || (this.SpeakerMode == global::SpeakerMode.Local && !this.DebugPlayback))
     {
         return;
     }
     if (this.SpeakerMode == global::SpeakerMode.Remote)
     {
         this.talkTimer = 1f;
     }
     byte[] @byte;
     for (int i = 0; i < data.Length; i += @byte.Length)
     {
         int num = BitConverter.ToInt32(data, i);
         @byte = MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.GetByte(num + 6);
         Array.Copy(data, i, @byte, 0, @byte.Length);
         MoPhoGames.USpeak.Core.USpeakFrameContainer uspeakFrameContainer = default(MoPhoGames.USpeak.Core.USpeakFrameContainer);
         uspeakFrameContainer.LoadFrom(@byte);
         MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.Return(@byte);
         float[] array = MoPhoGames.USpeak.Core.USpeakAudioClipCompressor.DecompressAudio(uspeakFrameContainer.encodedData, (int)uspeakFrameContainer.Samples, 1, false, this.settings.bandMode, this.codecMgr.Codecs[this.Codec], global::USpeaker.RemoteGain);
         float   num2  = (float)array.Length / (float)this.audioFrequency;
         this.received += (double)num2;
         Array.Copy(array, 0, this.receivedData, this.index, array.Length);
         MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.Return(array);
         this.index += array.Length;
         if (this.index >= base.audio.clip.samples)
         {
             this.index = 0;
         }
         base.audio.clip.SetData(this.receivedData, 0);
         if (!base.audio.isPlaying)
         {
             this.shouldPlay = true;
             if (this.playDelay <= 0f)
             {
                 this.playDelay = num2 * 2f;
             }
         }
     }
 }
Пример #3
0
 private void ProcessPendingEncode(float[] pcm)
 {
     int num;
     byte[] numArray = USpeakAudioClipCompressor.CompressAudioData(pcm, 1, out num, this.lastBandMode, this.codecMgr.Codecs[this.lastCodec], USpeaker.LocalGain);
     USpeakFrameContainer uSpeakFrameContainer = new USpeakFrameContainer()
     {
         Samples = (ushort)num,
         encodedData = numArray
     };
     this.sendBuffer.Add(uSpeakFrameContainer);
 }
Пример #4
0
 public void ReceiveAudio(byte[] data)
 {
     byte[] num = null;
     if (this.settings == null)
     {
         UnityEngine.Debug.LogWarning("Trying to receive remote audio data without calling InitializeSettings!\nIncoming packet will be ignored");
         return;
     }
     if (USpeaker.MuteAll || this.Mute || this.SpeakerMode == SpeakerMode.Local && !this.DebugPlayback)
     {
         return;
     }
     if (this.SpeakerMode == SpeakerMode.Remote)
     {
         this.talkTimer = 1f;
     }
     for (int i = 0; i < (int)data.Length; i = i + (int)num.Length)
     {
         int num1 = BitConverter.ToInt32(data, i);
         num = USpeakPoolUtils.GetByte(num1 + 6);
         Array.Copy(data, i, num, 0, (int)num.Length);
         USpeakFrameContainer uSpeakFrameContainer = new USpeakFrameContainer();
         uSpeakFrameContainer.LoadFrom(num);
         USpeakPoolUtils.Return(num);
         float[] singleArray = USpeakAudioClipCompressor.DecompressAudio(uSpeakFrameContainer.encodedData, (int)uSpeakFrameContainer.Samples, 1, false, this.settings.bandMode, this.codecMgr.Codecs[this.Codec], USpeaker.RemoteGain);
         float length = (float)((int)singleArray.Length) / (float)this.audioFrequency;
         USpeaker uSpeaker = this;
         uSpeaker.received = uSpeaker.received + (double)length;
         Array.Copy(singleArray, 0, this.receivedData, this.index, (int)singleArray.Length);
         USpeakPoolUtils.Return(singleArray);
         USpeaker length1 = this;
         length1.index = length1.index + (int)singleArray.Length;
         if (this.index >= base.audio.clip.samples)
         {
             this.index = 0;
         }
         base.audio.clip.SetData(this.receivedData, 0);
         if (!base.audio.isPlaying)
         {
             this.shouldPlay = true;
             if (this.playDelay <= 0f)
             {
                 this.playDelay = length * 2f;
             }
         }
     }
 }