Example #1
0
        private int EncodeFrames([NotNull] IVoiceEncoder encoder, int maxCount)
        {
            var count = 0;

            //Read frames of resampled samples (as many as we can, we want to keep this buffer empty and latency low)
            var encoderInput = new ArraySegment <float>(_plainSamples, 0, encoder.FrameSize);

            while (_output.Read(encoderInput) && count < maxCount)
            {
                //Encode it
                var encoded = encoder.Encode(encoderInput, new ArraySegment <byte>(_encodedBytes));

                //Transmit it
                _net.SendVoice(encoded);
                count++;
            }

            return(count);
        }
Example #2
0
        private void EncodeFrames()
        {
            //Read frames of resampled samples (as many as we can, we want to keep this buffer empty and latency low)
            var encoderInput = new ArraySegment <float>(_plainSamples, 0, _encoder.FrameSize);

            while (_output.Read(encoderInput))
            {
                if (_preEncodeDiagnosticOutput != null)
                {
                    _preEncodeDiagnosticOutput.WriteSamples(encoderInput);
                }

                //Encode it
                var encoded = _encoder.Encode(encoderInput, new ArraySegment <byte>(_encodedBytes));

                //Transmit it
                _net.SendVoice(encoded);
            }
        }