예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mode">
        /// the mode of the encoder (0=NB, 1=WB, 2=UWB).
        /// </param>
        /// <param name="quality">
        /// the quality setting of the encoder (between 0 and 10).
        /// </param>
        /// <param name="sampleRate">
        /// the number of samples per second.
        /// </param>
        /// <param name="channels">
        ///  the number of audio channels (1=mono, 2=stereo).
        /// </param>
        /// <returns></returns>
        public bool init(int mode, int quality, int sampleRate, int channels)
        {
            switch (mode)
            {
            case 0:
                encoder = new NbEncoder();
                ((NbEncoder)encoder).nbinit();
                break;

            //Wideband
            case 1:
                encoder = new SbEncoder();
                ((SbEncoder)encoder).wbinit();
                break;

            case 2:
                encoder = new SbEncoder();
                ((SbEncoder)encoder).uwbinit();
                break;

            //*/
            default:
                return(false);
            }
            /* initialize the speex decoder */
//            encoder.setQuality(quality);
            encoder.Quality = quality;

            /* set decoder format and properties */
            this.frameSize  = encoder.FrameSize;
            this.sampleRate = sampleRate;
            this.channels   = channels;
            rawData         = new float[channels * frameSize];

            bits.Init();
            return(true);
        }