Ways to encode Stream data using NSpeex

Apr 1, 2013 at 8:06 AM
Hi balistof,

I am looking for ways to encode Stream data using NSpeex.

I tried to cast the data like this.
 private Stream waveIn_DataAvailable(Stream rawData)
            // convert to short
            byte[] data = new byte[1024];

            rawData.Read(data, 0, data.Length);

            // note: the number of samples per frame must be a multiple of encoder.FrameSize

            short[] converter = Array.ConvertAll(data, b => (short)b);
            byte[] encodedData = new byte[2048];

            encoder.Encode(converter, 0, converter.Length, encodedData, 0, encodedData.Length);

            return (new MemoryStream(encodedData) ); 
However, I got an error IndexOutOfRangeException at the line of encoder.Enocde() during execution. Anyone know how to solve it?