// Token: 0x06000441 RID: 1089 RVA: 0x00015474 File Offset: 0x00013674
        public byte[] Encode(short[] data, global::BandMode mode)
        {
            this.Init();
            int num = data.Length / 2;

            if (num % 2 != 0)
            {
                num++;
            }
            byte[] @byte = MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.GetByte(num);
            for (int i = 0; i < @byte.Length; i++)
            {
                if (i * 2 >= data.Length)
                {
                    break;
                }
                byte b  = this.ADPCM_Encode(data[i * 2]);
                byte b2 = 0;
                if (i * 2 + 1 < data.Length)
                {
                    b2 = this.ADPCM_Encode(data[i * 2 + 1]);
                }
                byte b3 = (byte)((int)b2 << 4 | (int)b);
                @byte[i] = b3;
            }
            return(@byte);
        }
Beispiel #2
0
        // Token: 0x06004C3F RID: 19519 RVA: 0x00197D4C File Offset: 0x0019614C
        private byte[] SpeexEncode(short[] input, global::BandMode mode)
        {
            SpeexEncoder speexEncoder = null;
            int          num          = 320;

            if (mode != global::BandMode.Narrow)
            {
                if (mode != global::BandMode.Wide)
                {
                    if (mode == global::BandMode.UltraWide)
                    {
                        speexEncoder = this.m_ultrawide_enc;
                        num          = 1280;
                    }
                }
                else
                {
                    speexEncoder = this.m_wide_enc;
                    num          = 640;
                }
            }
            else
            {
                speexEncoder = this.m_narrow_enc;
                num          = 320;
            }
            byte[] @byte = USpeakPoolUtils.GetByte(num + 4);
            int    value = speexEncoder.Encode(input, 0, input.Length, @byte, 4, @byte.Length);

            byte[] bytes = BitConverter.GetBytes(value);
            Array.Copy(bytes, @byte, 4);
            return(@byte);
        }
 // Token: 0x06000442 RID: 1090 RVA: 0x00015500 File Offset: 0x00013700
 public short[] Decode(byte[] data, global::BandMode mode)
 {
     this.Init();
     short[] @short = MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.GetShort(data.Length * 2);
     for (int i = 0; i < data.Length; i++)
     {
         byte b = data[i];
         byte originalSample  = b & 15;
         byte originalSample2 = (byte)(b >> 4);
         @short[i * 2]     = this.ADPCM_Decode(originalSample);
         @short[i * 2 + 1] = this.ADPCM_Decode(originalSample2);
     }
     return(@short);
 }
Beispiel #4
0
        // Token: 0x06004C40 RID: 19520 RVA: 0x00197DDC File Offset: 0x001961DC
        private short[] SpeexDecode(byte[] input, global::BandMode mode)
        {
            SpeexDecoder speexDecoder = null;
            int          length       = 320;

            if (mode != global::BandMode.Narrow)
            {
                if (mode != global::BandMode.Wide)
                {
                    if (mode == global::BandMode.UltraWide)
                    {
                        speexDecoder = this.m_ultrawide_dec;
                        length       = 1280;
                    }
                }
                else
                {
                    speexDecoder = this.m_wide_dec;
                    length       = 640;
                }
            }
            else
            {
                speexDecoder = this.m_narrow_dec;
                length       = 320;
            }
            byte[] @byte = USpeakPoolUtils.GetByte(4);
            Array.Copy(input, @byte, 4);
            int inCount = BitConverter.ToInt32(@byte, 0);

            USpeakPoolUtils.Return(@byte);
            byte[] byte2 = USpeakPoolUtils.GetByte(input.Length - 4);
            Buffer.BlockCopy(input, 4, byte2, 0, input.Length - 4);
            short[] @short = USpeakPoolUtils.GetShort(length);
            speexDecoder.Decode(byte2, 0, inCount, @short, 0, false);
            USpeakPoolUtils.Return(byte2);
            return(@short);
        }
        // Token: 0x0600047F RID: 1151 RVA: 0x00016978 File Offset: 0x00014B78
        public static float[] DecompressAudio(byte[] data, int samples, int channels, bool threeD, global::BandMode mode, MoPhoGames.USpeak.Codec.ICodec Codec, float gain)
        {
            int frequency = 4000;

            if (mode == global::BandMode.Narrow)
            {
                frequency = 8000;
            }
            else if (mode == global::BandMode.Wide)
            {
                frequency = 16000;
            }
            short[] array = Codec.Decode(data, mode);
            USpeakAudioClipCompressor.tmp.Clear();
            USpeakAudioClipCompressor.tmp.AddRange(array);
            MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.Return(array);
            return(USpeakAudioClipConverter.ShortsToAudioData(USpeakAudioClipCompressor.tmp.ToArray(), channels, frequency, threeD, gain));
        }
 // Token: 0x0600047E RID: 1150 RVA: 0x00016928 File Offset: 0x00014B28
 public static byte[] CompressAudioData(float[] samples, int channels, out int sample_count, global::BandMode mode, MoPhoGames.USpeak.Codec.ICodec Codec, float gain = 1f)
 {
     USpeakAudioClipCompressor.data.Clear();
     sample_count = 0;
     short[] d     = USpeakAudioClipConverter.AudioDataToShorts(samples, channels, gain);
     byte[]  array = Codec.Encode(d, mode);
     MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.Return(d);
     USpeakAudioClipCompressor.data.AddRange(array);
     MoPhoGames.USpeak.Core.Utils.USpeakPoolUtils.Return(array);
     return(USpeakAudioClipCompressor.data.ToArray());
 }
		// Token: 0x06000449 RID: 1097 RVA: 0x00015574 File Offset: 0x00013774
		public short[] Decode(byte[] data, global::BandMode mode)
		{
			return MuLawCodec.MuLawDecoder.MuLawDecode(data);
		}
		// Token: 0x06000448 RID: 1096 RVA: 0x0001556C File Offset: 0x0001376C
		public byte[] Encode(short[] data, global::BandMode mode)
		{
			return MuLawCodec.MuLawEncoder.MuLawEncode(data);
		}
Beispiel #9
0
 // Token: 0x06004C42 RID: 19522 RVA: 0x00197E9A File Offset: 0x0019629A
 public byte[] Encode(short[] data, global::BandMode mode)
 {
     return(this.SpeexEncode(data, mode));
 }
Beispiel #10
0
 // Token: 0x06004C41 RID: 19521 RVA: 0x00197E98 File Offset: 0x00196298
 public void Initialize(global::BandMode bandMode, BitRate bitrate, FrameDuration duration)
 {
 }
Beispiel #11
0
 // Token: 0x06004C43 RID: 19523 RVA: 0x00197EA4 File Offset: 0x001962A4
 public short[] Decode(byte[] data, global::BandMode mode)
 {
     return(this.SpeexDecode(data, mode));
 }