コード例 #1
0
        private void Initialize(Header header)
        {
            // REVIEW: allow customizable scale factor
            float scalefactor = 32700.0f;

            int mode     = header.mode();
            int layer    = header.layer();
            int channels = mode == Header.SINGLE_CHANNEL ? 1 : 2;

            // set up output buffer if not set up by client.
            if (m_Output == null)
            {
                m_Output = new SampleBuffer(header.frequency(), channels);
            }

            float[] factors = m_Equalizer.BandFactors;
            //Console.WriteLine("NOT CREATING SYNTHESIS FILTERS");
            m_LeftChannelFilter = new SynthesisFilter(0, scalefactor, factors);

            // REVIEW: allow mono output for stereo
            if (channels == 2)
            {
                m_RightChannelFilter = new SynthesisFilter(1, scalefactor, factors);
            }

            m_OutputChannels  = channels;
            m_OutputFrequency = header.frequency();

            m_IsInitialized = true;
        }
コード例 #2
0
        /// <summary>
        ///     Decodes one frame from an MPEG audio bitstream.
        /// </summary>
        /// <param name="header">
        ///     Header describing the frame to decode.
        /// </param>
        /// <param name="stream">
        ///     Bistream that provides the bits for the body of the frame.
        /// </param>
        /// <returns>
        ///     A SampleBuffer containing the decoded samples.
        /// </returns>
        public virtual ABuffer DecodeFrame(Header header, Bitstream stream)
        {
            if (!m_IsInitialized)
            {
                Initialize(header);
            }

            int layer = header.layer();

            m_Output.ClearBuffer();

            IFrameDecoder decoder = RetrieveDecoder(header, stream, layer);

            decoder.DecodeFrame();

            m_Output.WriteBuffer(1);

            return(m_Output);
        }
コード例 #3
0
ファイル: Decoder.cs プロジェクト: clashbyte/openvice
        private void Initialize(Header header)
        {
            // REVIEW: allow customizable scale factor
            float scalefactor = 32700.0f;

            int mode = header.mode();
            int layer = header.layer();
            int channels = mode == Header.SINGLE_CHANNEL ? 1 : 2;

            // set up output buffer if not set up by client.
            if (m_Output == null)
                m_Output = new SampleBuffer(header.frequency(), channels);

            float[] factors = m_Equalizer.BandFactors;
            //Console.WriteLine("NOT CREATING SYNTHESIS FILTERS");
            m_LeftChannelFilter = new SynthesisFilter(0, scalefactor, factors);

            // REVIEW: allow mono output for stereo
            if (channels == 2)
                m_RightChannelFilter = new SynthesisFilter(1, scalefactor, factors);

            m_OutputChannels = channels;
            m_OutputFrequency = header.frequency();

            m_IsInitialized = true;
        }
コード例 #4
0
ファイル: Decoder.cs プロジェクト: clashbyte/openvice
        /// <summary>
        ///     Decodes one frame from an MPEG audio bitstream.
        /// </summary>
        /// <param name="header">
        ///     Header describing the frame to decode.
        /// </param>
        /// <param name="stream">
        ///     Bistream that provides the bits for the body of the frame.
        /// </param>
        /// <returns>
        ///     A SampleBuffer containing the decoded samples.
        /// </returns>
        public virtual ABuffer DecodeFrame(Header header, Bitstream stream)
        {
            if (!m_IsInitialized)
            {
                Initialize(header);
            }

            int layer = header.layer();

            m_Output.ClearBuffer();

            IFrameDecoder decoder = RetrieveDecoder(header, stream, layer);

            decoder.DecodeFrame();

            m_Output.WriteBuffer(1);

            return m_Output;
        }