Esempio n. 1
0
        /// <summary>Begins the decoding process.</summary>
        /// <param name="source">The source.</param>
        /// <exception cref="NotSupportedException">Only Layer 3 Audio is supported!.</exception>
        /// <exception cref="Exception">Decoding already started!.</exception>
        public override void BeginDecode(IFrameSource source)
        {
            if (m_FrameDecoder != null)
            {
                Close();
            }

            SourceName = source.Name;
            m_Source   = source;

            // get first audio frame
            MP3AudioFrame l_MP3Frame = ReadNextAudioFrame();

            if (l_MP3Frame.Header.Layer != MP3AudioFrameLayer.Layer3)
            {
                throw new NotSupportedException("Source " + SourceName + ": Only Layer 3 Audio is supported!");
            }

            // prepare decoder
            m_OutputChannels = l_MP3Frame.Header.ChannelCount;
            float[] isEqualizerFactors = m_Equalizer.GetFactors();
            m_Filter1 = new MP3AudioSynthesisFilter(0, 32000.0f, isEqualizerFactors);
            if (m_OutputChannels == 2)
            {
                m_Filter2 = new MP3AudioSynthesisFilter(1, 32000.0f, isEqualizerFactors);
            }

            m_SamplingRate = l_MP3Frame.Header.SamplingRate;
            m_OutputBuffer = new MP3AudioStereoBuffer(m_SamplingRate);
            m_FrameDecoder = new MP3AudioLayerIIIDecoder(l_MP3Frame.Header, m_Filter1, m_Filter2, m_OutputBuffer, (int)MP3AudioOutputMode.Both);

            DecodeFrame(l_MP3Frame);
        }
Esempio n. 2
0
 /// <summary>Closes this instance and the underlying stream.</summary>
 public override void Close()
 {
     m_FrameDecoder = null;
     m_Source.Close();
 }
Esempio n. 3
0
 /// <summary>Closes this instance and the underlying stream.</summary>
 public override void Close()
 {
     frameDecoder = null;
     source.Close();
 }