⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voiceencoding.cs

📁 Gibphone is CSharp Program, it can tell you how to design p2p chat.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace GPCore.Vocoders
{
    /// <summary>
    /// An abstract class to extend for voice encoding/decoding for use by Phones.
    /// </summary>
    public abstract class Vocoder : IVocoder
    {
        /// <summary>
        /// The current sample-rate of the Vocoder, set by the initialize funtion.
        /// </summary>
        protected int SAMPLE_RATE;

        /// <summary>
        /// Encode an array of bytes.
        /// </summary>
        public abstract void Encode(byte[] a);

        /// <summary>
        /// Decode an array of bytes.
        /// </summary>
        public abstract void Decode(byte[] a);

        /// <summary>
        /// Call this to initialize the vocoder.
        /// </summary>
        /// <param name="samplerate">The sample rate this vocoder will have.</param>
        public virtual void Initialize(int sampleRate)
        {
            this.SAMPLE_RATE = sampleRate;
        }

        abstract public event ByteDelegate DataEncoded;
        abstract public event ByteDelegate DataDecoded;

        #region IDisposable Members
        /// <summary>
        /// Disposes of this object's resources.
        /// </summary>
        public abstract void Dispose();

        #endregion
    }

    /// <summary>
    /// An abstract class to extend for voice encoding/decoding for use by Phones.
    /// </summary>
    public interface IVocoder : IDisposable
    {
        /// <summary>
        /// Call this to start the vocoder.
        /// </summary>
        /// <param name="samplerate">The samplerate you want this vocoder to have.</param>
        void Initialize(int samplerate);

        /// <summary>
        /// Call this to Encode the bytes in a. 
        /// </summary>
        /// <param name="a">Non-Encoded bytes to encode, after the funcion is over it
        /// contains the new bytes.</param>
        void Encode(byte[] a);

        /// <summary>
        /// Call this to Decode the bytes in a. 
        /// </summary>
        /// <param name="a">Encoded bytes to encode, after the funcion is over it
        /// contains the new bytes.</param>
        void Decode(byte[] a);

        /// <summary>
        /// Event signifying that data has been encoded.
        /// </summary>
        event ByteDelegate DataEncoded;

        /// <summary>
        /// Event signifying that data has been decoded.
        /// </summary>
        event ByteDelegate DataDecoded;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -