示例#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
        private void compute_pc_samples14(ABuffer buffer)
        {
            float[] vp = _ActualV;

            //int inc = v_inc;
            float[] tmpOut = _TmpOut;
            int     dvp    = 0;

            // fat chance of having this loop unroll
            for (int i = 0; i < 32; i++)
            {
                float[] dp = _d16[i];
                float   pcSample;

                pcSample =
                    (vp[14 + dvp] * dp[0] + vp[13 + dvp] * dp[1] + vp[12 + dvp] * dp[2] + vp[11 + dvp] * dp[3] +
                     vp[10 + dvp] * dp[4] + vp[9 + dvp] * dp[5] + vp[8 + dvp] * dp[6] + vp[7 + dvp] * dp[7] +
                     vp[6 + dvp] * dp[8] + vp[5 + dvp] * dp[9] + vp[4 + dvp] * dp[10] + vp[3 + dvp] * dp[11] +
                     vp[2 + dvp] * dp[12] + vp[1 + dvp] * dp[13] + vp[0 + dvp] * dp[14] + vp[15 + dvp] * dp[15]) *
                    _Scalefactor;

                tmpOut[i] = pcSample;

                dvp += 16;
            }
            // for
        }
示例#3
0
        /// <summary>
        /// Calculate 32 PCM samples and put the into the Obuffer-object.
        /// </summary>
        internal void calculate_pc_samples(ABuffer buffer)
        {
            ComputeNewValues();
            compute_pc_samples(buffer);

            _ActualWritePos = (_ActualWritePos + 1) & 0xf;
            _ActualV        = _ActualV == _V1 ? _V2 : _V1;

            // initialize samples[]:
            //for (register float *floatp = samples + 32; floatp > samples; )
            // *--floatp = 0.0f;

            // MDM: this may not be necessary. The Layer III decoder always
            // outputs 32 subband samples, but I haven't checked layer I & II.
            for (int p = 0; p < 32; p++)
            {
                _Samples[p] = 0.0f;
            }
        }
示例#4
0
        private void compute_pc_samples3(ABuffer buffer)
        {
            float[] vp = _ActualV;

            float[] tmpOut = _TmpOut;
            int     dvp    = 0;

            for (int i = 0; i < 32; i++)
            {
                float[] dp       = _d16[i];
                float   pcSample = (vp[3 + dvp] * dp[0] + vp[2 + dvp] * dp[1] + vp[1 + dvp] * dp[2] + vp[0 + dvp] * dp[3] +
                                    vp[15 + dvp] * dp[4] + vp[14 + dvp] * dp[5] + vp[13 + dvp] * dp[6] + vp[12 + dvp] * dp[7] +
                                    vp[11 + dvp] * dp[8] + vp[10 + dvp] * dp[9] + vp[9 + dvp] * dp[10] + vp[8 + dvp] * dp[11] +
                                    vp[7 + dvp] * dp[12] + vp[6 + dvp] * dp[13] + vp[5 + dvp] * dp[14] + vp[4 + dvp] * dp[15]) *
                                   _Scalefactor;

                tmpOut[i] = pcSample;

                dvp += 16;
            }
        }
示例#5
0
        private void compute_pcm_samples4(ABuffer buffer)
        {
            float[] vp = actual_v;

            float[] tmpOut = _tmpOut;
            int dvp = 0;

            for (int i = 0; i < 32; i++)
            {
                float[] dp = d16[i];
                float pcm_sample = ((vp[4 + dvp]*dp[0]) + (vp[3 + dvp]*dp[1]) + (vp[2 + dvp]*dp[2]) + (vp[1 + dvp]*dp[3]) +
                                    (vp[0 + dvp]*dp[4]) + (vp[15 + dvp]*dp[5]) + (vp[14 + dvp]*dp[6]) + (vp[13 + dvp]*dp[7]) +
                                    (vp[12 + dvp]*dp[8]) + (vp[11 + dvp]*dp[9]) + (vp[10 + dvp]*dp[10]) + (vp[9 + dvp]*dp[11]) +
                                    (vp[8 + dvp]*dp[12]) + (vp[7 + dvp]*dp[13]) + (vp[6 + dvp]*dp[14]) + (vp[5 + dvp]*dp[15]))*
                                   scalefactor;

                tmpOut[i] = pcm_sample;

                dvp += 16;
            }
            // for
        }
示例#6
0
        private void compute_pcm_samples2(ABuffer buffer)
        {
            float[] vp = actual_v;

            //int inc = v_inc;
            float[] tmpOut = _tmpOut;
            int dvp = 0;

            // fat chance of having this loop unroll
            for (int i = 0; i < 32; i++)
            {
                float[] dp = d16[i];
                float pcm_sample;

                pcm_sample =
                    ((vp[2 + dvp]*dp[0]) + (vp[1 + dvp]*dp[1]) + (vp[0 + dvp]*dp[2]) + (vp[15 + dvp]*dp[3]) +
                     (vp[14 + dvp]*dp[4]) + (vp[13 + dvp]*dp[5]) + (vp[12 + dvp]*dp[6]) + (vp[11 + dvp]*dp[7]) +
                     (vp[10 + dvp]*dp[8]) + (vp[9 + dvp]*dp[9]) + (vp[8 + dvp]*dp[10]) + (vp[7 + dvp]*dp[11]) +
                     (vp[6 + dvp]*dp[12]) + (vp[5 + dvp]*dp[13]) + (vp[4 + dvp]*dp[14]) + (vp[3 + dvp]*dp[15]))*
                    scalefactor;

                tmpOut[i] = pcm_sample;

                dvp += 16;
            }
            // for
        }
示例#7
0
        /// <summary>
        ///     Calculate 32 PCM samples and put the into the Obuffer-object.
        /// </summary>
        public void calculate_pcm_samples(ABuffer buffer)
        {
            compute_new_v();
            compute_pcm_samples(buffer);

            actual_write_pos = (actual_write_pos + 1) & 0xf;
            actual_v = (actual_v == v1) ? v2 : v1;

            // initialize samples[]:	
            //for (register float *floatp = samples + 32; floatp > samples; )
            // *--floatp = 0.0f;  

            // MDM: this may not be necessary. The Layer III decoder always
            // outputs 32 subband samples, but I haven't checked layer I & II.
            for (int p = 0; p < 32; p++)
                m_SubbandSamples[p] = 0.0f;
        }
示例#8
0
        private void compute_pcm_samples(ABuffer buffer)
        {
            switch (actual_write_pos)
            {
                case 0:
                    compute_pcm_samples0(buffer);
                    break;

                case 1:
                    compute_pcm_samples1(buffer);
                    break;

                case 2:
                    compute_pcm_samples2(buffer);
                    break;

                case 3:
                    compute_pcm_samples3(buffer);
                    break;

                case 4:
                    compute_pcm_samples4(buffer);
                    break;

                case 5:
                    compute_pcm_samples5(buffer);
                    break;

                case 6:
                    compute_pcm_samples6(buffer);
                    break;

                case 7:
                    compute_pcm_samples7(buffer);
                    break;

                case 8:
                    compute_pcm_samples8(buffer);
                    break;

                case 9:
                    compute_pcm_samples9(buffer);
                    break;

                case 10:
                    compute_pcm_samples10(buffer);
                    break;

                case 11:
                    compute_pcm_samples11(buffer);
                    break;

                case 12:
                    compute_pcm_samples12(buffer);
                    break;

                case 13:
                    compute_pcm_samples13(buffer);
                    break;

                case 14:
                    compute_pcm_samples14(buffer);
                    break;

                case 15:
                    compute_pcm_samples15(buffer);
                    break;
            }

            if (buffer != null)
            {
                buffer.AppendSamples(m_ChannelIndex, _tmpOut);
            }
        }
示例#9
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;
        }
示例#10
0
        private void compute_pc_samples(ABuffer buffer)
        {
            switch (_ActualWritePos)
            {
            case 0:
                compute_pc_samples0(buffer);
                break;

            case 1:
                compute_pc_samples1(buffer);
                break;

            case 2:
                compute_pc_samples2(buffer);
                break;

            case 3:
                compute_pc_samples3(buffer);
                break;

            case 4:
                compute_pc_samples4(buffer);
                break;

            case 5:
                compute_pc_samples5(buffer);
                break;

            case 6:
                compute_pc_samples6(buffer);
                break;

            case 7:
                compute_pc_samples7(buffer);
                break;

            case 8:
                compute_pc_samples8(buffer);
                break;

            case 9:
                compute_pc_samples9(buffer);
                break;

            case 10:
                compute_pc_samples10(buffer);
                break;

            case 11:
                compute_pc_samples11(buffer);
                break;

            case 12:
                compute_pc_samples12(buffer);
                break;

            case 13:
                compute_pc_samples13(buffer);
                break;

            case 14:
                compute_pc_samples14(buffer);
                break;

            case 15:
                Compute_pc_samples15(buffer);
                break;
            }

            buffer?.AppendSamples(_Channel, _TmpOut);
        }