public override byte[] Encode(byte[] data) { int num = data.Length / 320; byte[] numArray = new byte[num * 7]; for (int index = 0; index < num; ++index) { Buffer.BlockCopy((Array)data, 320 * index, (Array)this.encoderInput, 0, 320); int num2 = (int)AMBEConverter.DSPINI_DMR_Voc_Enc(Marshal.UnsafeAddrOfPinnedArrayElement <byte>(this.encoderWorkingBuffer, 0), Marshal.UnsafeAddrOfPinnedArrayElement <short>(this.encoderInput, 0), Marshal.UnsafeAddrOfPinnedArrayElement <bool>(this.encoderOutput, 0)); this.ConvertOutput(numArray, 7 * index); } return(!Array.Exists <byte>(numArray, (Predicate <byte>)(byte_0 => byte_0 > (byte)0)) ? (byte[])null : numArray); }
#pragma warning restore IDE0044 // Add readonly modifier //Uses DSP Inovations vocoder. To decode the audio you need to get your own copy... public AMBEConverter() : base() { this.decoderWorkingBuffer = new byte[3608]; this.decoderWorkingBufferHandle = GCHandle.Alloc((object)this.decoderWorkingBuffer, GCHandleType.Pinned); this.decoderInput = new byte[49]; this.decoderInputHandle = GCHandle.Alloc((object)this.decoderInput, GCHandleType.Pinned); this.decoderOutput = new short[160]; this.decoderOutputHandle = GCHandle.Alloc((object)this.decoderOutput, GCHandleType.Pinned); AMBEConverter.DSPINI_DMR_Decoder_Init(Marshal.UnsafeAddrOfPinnedArrayElement <byte>(this.decoderWorkingBuffer, 0), (short)1); this.encoderWorkingBuffer = new byte[7924]; this.encoderWorkingBufferHandle = GCHandle.Alloc((object)this.encoderWorkingBuffer, GCHandleType.Pinned); this.encoderOutput = new bool[49]; this.encoderOutputHandle = GCHandle.Alloc((object)this.encoderOutput, GCHandleType.Pinned); this.encoderInput = new short[160]; this.encoderInputHandle = GCHandle.Alloc((object)this.encoderInput, GCHandleType.Pinned); AMBEConverter.DSPINI_DMR_Encoder_Init(Marshal.UnsafeAddrOfPinnedArrayElement <byte>(this.encoderWorkingBuffer, 0), 0, 1); }
private void BlockDecode(byte[] src, int srcOffset, byte[] dest, int destOffset) { this.CreateDecoderInput(src, srcOffset); AMBEConverter.DSPINI_DMR_Voc_Dec(Marshal.UnsafeAddrOfPinnedArrayElement <byte>(this.decoderWorkingBuffer, 0), Marshal.UnsafeAddrOfPinnedArrayElement <byte>(this.decoderInput, 0), Marshal.UnsafeAddrOfPinnedArrayElement <short>(this.decoderOutput, 0)); Buffer.BlockCopy((Array)this.decoderOutput, 0, dest, destOffset, 320); }