コード例 #1
0
ファイル: Mp3Writer.cs プロジェクト: uzbekdev1/ispyconnect
 /// <summary>
 /// Create a Mp3Writer with specific MP3 format
 /// </summary>
 /// <param name="output">Stream that will hold the MP3 resulting data</param>
 /// <param name="inputDataFormat">PCM format of input data</param>
 /// <param name="mp3Config">Desired MP3 config</param>
 /// <param name="isStreamOwner"> </param>
 public Mp3Writer(Stream output, WaveFormat inputDataFormat, BE_CONFIG mp3Config, bool isStreamOwner)
     : base(output, inputDataFormat)
 {
     IsStreamOwner = isStreamOwner;
     try
     {
         _mMp3Config = mp3Config;
         uint lameResult = Lame_encDll.beInitStream(_mMp3Config, ref _mInputSamples, ref _mOutBufferSize, ref _mHLameStream);
         if (lameResult != Lame_encDll.BE_ERR_SUCCESSFUL)
         {
             throw new ApplicationException(string.Format("Lame_encDll.beInitStream failed with the error code {0}", lameResult));
         }
         _mInBuffer  = new byte[_mInputSamples * 2]; //Input buffer is expected as short[]
         _mOutBuffer = new byte[_mOutBufferSize];
     }
     catch
     {
         CloseStream();
         throw;
     }
 }
コード例 #2
0
 /// <summary>
 /// Create a Mp3Writer with specific MP3 format
 /// </summary>
 /// <param name="Output">Stream that will hold the MP3 resulting data</param>
 /// <param name="InputDataFormat">PCM format of input data</param>
 /// <param name="Mp3Config">Desired MP3 config</param>
 public Mp3Writer(Stream Output, WaveFormat InputDataFormat, BE_CONFIG Mp3Config, bool isStreamOwner)
     : base(Output, InputDataFormat)
 {
     IsStreamOwner = isStreamOwner;
     try
     {
         m_Mp3Config = Mp3Config;
         uint LameResult = Lame_encDll.beInitStream(m_Mp3Config, ref m_InputSamples, ref m_OutBufferSize, ref m_hLameStream);
         if (LameResult != Lame_encDll.BE_ERR_SUCCESSFUL)
         {
             throw new ApplicationException(string.Format("Lame_encDll.beInitStream failed with the error code {0}", LameResult));
         }
         m_InBuffer  = new byte[m_InputSamples * 2]; //Input buffer is expected as short[]
         m_OutBuffer = new byte[m_OutBufferSize];
     }
     catch
     {
         CloseStream();
         throw;
     }
 }