Confusion in encoding....

Aug 7, 2011 at 2:07 PM

While using NSpeex encoding, i encountered a problem.... My Scenario is like this

int encodedBytes = encoder.Encode(data, 0, sampleIndex, encodedData, 0, bytesRecorded);
while checking the size i found that the size of encodedData is almost same to that of the raw data whereas encodedBytes 
shows 10 times less in size than the raw data.....
In the decoder encodedData is used.... which is almost same in size as the raw audio data... 
decoder.Decode(encodedData, 0, encodedData.Length, decodedFrame, 0, false);
Can anyone help me in this??
Aug 8, 2011 at 11:55 AM

Yes, this is correct. When you pass in a pre-allocated encodedData array you can use the same array over an over again with the need to allocate and free the required memory as the encoder simply overrides the data in the array with the new encoded data. In order to know the exact size if bytes of the output you have to use the result encodedBytes.

The same principal goes for the decode.