コード例 #1
0
 public void Stop()
 {
     try
     {
         if (mBufferedStream != null)
         {
             mBufferedStream.Dispose();
             mBufferedStream = null;
         }
         if (mConvStream != null)
         {
             mConvStream.Dispose();
             mConvStream = null;
         }
     }
     catch (Exception ex)
     {
         SubDebug(string.Format("Converter stop fail.\t{0}", ex.Message));
     }
 }
コード例 #2
0
        public void PrepareConvert(EVLVoiceFormat format)
        {
            SubDebug(string.Format("Call PrepareConvert,source wave format:{0}", format));
            Stop();
            try
            {
                mFormat = format;
                switch (mFormat)
                {
                case EVLVoiceFormat.MT_MSGSM:
                    mSrcWaveFormat = new Gsm610WaveFormat();
                    break;

                case EVLVoiceFormat.MT_MP3_32K_STEREO:
                    mSrcWaveFormat = new Mp3WaveFormat(8000, 2, 288, 32000);
                    break;

                default:
                    SubDebug(string.Format("Format not support,source wave format:{0}", mFormat));
                    return;
                }
                if (mSrcWaveFormat.Channels == 2)
                {
                    mPcmWaveFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, 8000, 2, 32000, 4, 16);
                }
                else
                {
                    mPcmWaveFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, 8000, 1, 16000, 2, 16);
                }
                mBufferedStream = new BufferedWaveStream(mSrcWaveFormat);
                mConvStream     = new WaveFormatConversionStream(mPcmWaveFormat, mBufferedStream);
                SubDebug(string.Format("Convertor prepared,source wave format:{0},dest wave format:{1}", mSrcWaveFormat, mPcmWaveFormat));
            }
            catch (Exception ex)
            {
                SubDebug(string.Format("PrepareConvert fail.\t{0}", ex.Message));
            }
        }