NSpeex Audio Issues

Oct 17, 2012 at 6:08 PM

OK, so here's what I'm doing. I'm creating a voice chat system for a game engine I'm working with. This game engine provides me with a Microphone class, which I can call Microphone.Start which returns an AudioClip. I can also use Microphone.GetPosition to get the current recording position in the audio clip.

In the Update callback of my game engine, I get the newest chunk of audio into a float[], then I convert each float sample into a short (and now I have a short[]), and then I feed that short array into the speex encoding functions. Then, this data is packaged into a simple container format and passed to a user function which handles serializing over the network (my test function just passes it right back to my code). Once it's received back, the container format is decoded from a byte array, then the encoded data stored in it is fed back into the Speex decoding functions, and then the resulting short[] array is converted back into a float[] array, and then fed into a new Audio Clip which is then played.

I also have in my code the ability to turn Speex encoding/decoding off and on, so if Speex is turned off the byte array is actually just each float sample turned into a byte, and upon decoding instead of decoding with Speex it just turns each byte into a float.

Here's a sample of what it sounds like with Speex turned OFF:


And here's a sample of what it sounds like with Speex turned ON:


I heard somewhere that you need to trim off a number of samples? Is this prior to encoding, after encoding, after decoding...? How can I get rid of that annoying choppy sound??