Example #1
0
        /// <summary>
        /// Returns the next decoded frame from the buffer.
        /// </summary>
        /// <param name="decodedFrame"></param>
        public void Get(short[] decodedFrame)
        {
            if (decodedFrame == null)
            {
                throw new ArgumentNullException("decodedFrame");
            }

            if (outPacket.data == null)
            {
                outPacket.data = new byte[decodedFrame.Length * 2];
            }
            else
            {
                Array.Clear(outPacket.data, 0, outPacket.data.Length);
            }

            outPacket.len = outPacket.data.Length;

            int temp;

            if (buffer.Get(ref outPacket, 1, out temp) != JitterBuffer.JITTER_BUFFER_OK)
            {
                // no packet found
                decoder.Decode(null, 0, 0, decodedFrame, 0, true);
            }
            else
            {
                decoder.Decode(outPacket.data, 0, outPacket.len, decodedFrame, 0, false);
            }

            buffer.Tick();
        }
        public float[] Decode(byte[] data)
        {
            var decoded = decoder.Decode(data, 0, data.Length, decodeBuffer, 0, false);

            Convert(decodeBuffer, ref decodedBuffer);
            return(decodedBuffer);
        }
Example #3
0
 public static float[] DeCompress(NSpeex.SpeexDecoder speexDec, byte[] data, int dataLength)
 {
     float[] decoded     = new float[data.Length];
     short[] shortBuffer = new short[data.Length];
     speexDec.Decode(data, 0, dataLength, shortBuffer, 0, false);
     shortBuffer.ToFloatArray(decoded, shortBuffer.Length);
     return(decoded);
 }
Example #4
0
 static float[] SpeexDecompress(NSpeex.SpeexDecoder speexDec, byte[] data, int dataLength)
 {
     float[] decoded     = VoiceChatFloatPool.Instance.Get();
     short[] shortBuffer = VoiceChatShortPool.Instance.Get();
     speexDec.Decode(data, 0, dataLength, shortBuffer, 0, false);
     shortBuffer.ToFloatArray(decoded, shortBuffer.Length);
     VoiceChatShortPool.Instance.Return(shortBuffer);
     return(decoded);
 }
Example #5
0
        public static float[] NSpeexDecompress(byte[] samplesByte, int dataLength)
        {
            short[] samplesShort = new short[samplesByte.Length];
            float[] decoded      = new float[samplesByte.Length];

            nspeexDec.Decode(samplesByte, 0, dataLength, samplesShort, 0, false);
            samplesShort.ConverToFloat(decoded);

            return(decoded);
        }