Beispiel #1
0
        /// <summary>
        /// Gets voice data from the given AudioRecorder and compresses it with this channels codec
        /// </summary>
        /// <param name="recorder">The audio source</param>
        /// <param name="data">Compressed voice data</param>
        /// <returns>Whether there is more data to send</returns>
        public bool CreateVoicePacket(AudioRecorder recorder, out byte[] data)
        {
            // TODO: Don't make a new array every time
            short[] voiceData = new short[client.User.VoiceCodec.FrameSize];
            bool    more      = recorder.GetExact(voiceData, 0, voiceData.Length);

            if (!more)
            {
                data = null;
                return(false);
            }

            data = client.User.VoiceCodec.Encode(voiceData);
            return(more);
        }