NAudio + NSpeex + ZigBee

Feb 19, 2015 at 10:38 PM
Good day,

I have a question about encoding/decoding voice with NSpeex from example NetworkChat. All is ok when I am using sockets, but the same algorithm with ZigBee connected via COM is crashed on decode received bytes with message "Invalid sideband mode encountered (1st sideband): 7".

I have tried like this topic, but it is vainly, same error.

What do you think, is it problem on COM side or something wrong with Speex?

Thanks in advance.
//preparing
ZigUsbReceived.Handshake = Handshake.XOnXOff;
ZigUsbSent.Handshake = Handshake.XOnXOff;
ZigUsbReceived.Open();
ZigUsbSent.Open(); 

codec1 = new NAudioDemo.NetworkChatDemo.NarrowBandSpeexCodec();

input = new WaveIn();
input.BufferMilliseconds = 10;
input.WaveFormat = codec1.RecordFormat;
input.DataAvailable += Voice_Input;

output = new DirectSoundOut();
bufferStream = new BufferedWaveProvider(codec1.RecordFormat);
output.Init(bufferStream);

//sending
var encodedData = codec1.Encode(e.Buffer, 0, e.BytesRecorded);
ZigUsbSent.Write(encodedData, 0, 38);
//client.SendTo(encodedData, 0, 38, SocketFlags.None, remote_point); //working variant

//receiving
ZigUsbReceived.Read(data, 0, 38);
//listeningSocket.ReceiveFrom(data, ref remoteIp); //working variant
byte[] decodeData = codec.Decode(data, 0, 38);
bufferStream.AddSamples(decodeData, 0, decodeData.Length);

//crushed here
public byte[] Decode(byte[] data, int offset, int length)
{
     var outputBufferTemp = new byte[length * 320];
     var wb = new WaveBuffer(outputBufferTemp);
     int samplesDecoded = decoder.Decode(data, offset, length, wb.ShortBuffer, 0, false); // this string with error "Invalid sideband mode encountered (1st sideband): 7"
     int bytesDecoded = samplesDecoded * 2;
     var decoded = new byte[bytesDecoded];
     Array.Copy(outputBufferTemp, 0, decoded, 0, bytesDecoded);
     Debug.WriteLine(String.Format("NSpeex: In {0} bytes, decoded {1} bytes [dec frame size = {2}]", length, bytesDecoded, decoder.FrameSize));
     return decoded;
}