/// <summary>
 /// Creates a new ACM frame decompressor
 /// </summary>
 /// <param name="sourceFormat">The MP3 source format</param>
 public AcmMp3FrameDecompressor(WaveFormat sourceFormat)
 {
     this.pcmFormat = AcmStream.SuggestPcmFormat(sourceFormat);
     try
     {
         conversionStream = new AcmStream(sourceFormat, pcmFormat);
     }
     catch (Exception)
     {
         disposed = true;
         GC.SuppressFinalize(this);
         throw;
     }
 }
        /// <summary>
        /// Create a new WaveFormat conversion stream
        /// </summary>
        /// <param name="targetFormat">Desired output format</param>
        /// <param name="sourceStream">Source stream</param>
        public WaveFormatConversionStream(WaveFormat targetFormat, WaveStream sourceStream)
        {
            this.sourceStream = sourceStream;
            this.targetFormat = targetFormat;

            conversionStream = new AcmStream(sourceStream.WaveFormat, targetFormat);
            /*try
            {
                // work out how many bytes the entire input stream will convert to
                length = conversionStream.SourceToDest((int)sourceStream.Length);
            }
            catch
            {
                Dispose();
                throw;
            }*/
            length = EstimateSourceToDest((int)sourceStream.Length);

            position = 0;
            preferredSourceReadSize = Math.Min(sourceStream.WaveFormat.AverageBytesPerSecond, conversionStream.SourceBuffer.Length);
            preferredSourceReadSize -= (preferredSourceReadSize%sourceStream.WaveFormat.BlockAlign);
        }
 /// <summary>
 /// Disposes this stream
 /// </summary>
 /// <param name="disposing">true if the user called this</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Release managed resources.
         if (conversionStream != null)
         {
             conversionStream.Dispose();
             conversionStream = null;
         }
         if (sourceStream != null)
         {
             sourceStream.Dispose();
             sourceStream = null;
         }
     }
     else
     {
         System.Diagnostics.Debug.Assert(false, "WaveFormatConversionStream was not disposed");
     }
     // Release unmanaged resources.
     // Set large fields to null.
     // Call Dispose on your base class.
     base.Dispose(disposing);
 }