Exemplo n.º 1
0
 public sealed override void Unquantify(float[] exc, int es, int nsf, Bits bits)
 {
     for (int i = 0; i < this.nb_subvect; i++)
     {
         if (this.have_sign != 0)
         {
             this.signs[i] = bits.Unpack(1);
         }
         else
         {
             this.signs[i] = 0;
         }
         this.ind[i] = bits.Unpack(this.shape_bits);
     }
     for (int i = 0; i < this.nb_subvect; i++)
     {
         float num = 1f;
         if (this.signs[i] != 0)
         {
             num = -1f;
         }
         for (int j = 0; j < this.subvect_size; j++)
         {
             exc[es + this.subvect_size * i + j] += num * 0.03125f * (float)this.shape_cb[this.ind[i] * this.subvect_size + j];
         }
     }
 }
Exemplo n.º 2
0
        public void Init(Bits bits)
        {
            float num = 1f;

            if (bits.Unpack(1) != 0)
            {
                num = -1f;
            }
            int num2 = bits.Unpack(5);

            this.balance = (float)Math.Exp((double)num * 0.25 * (double)num2);
            num2         = bits.Unpack(2);
            this.e_ratio = Stereo.e_ratio_quant[num2];
        }
Exemplo n.º 3
0
        protected internal void UnpackPlus(float[] lsp, int[] tab, Bits bits, float k, int ti, int li)
        {
            int num = bits.Unpack(6);

            for (int i = 0; i < ti; i++)
            {
                lsp[i + li] += k * (float)tab[num * ti + i];
            }
        }
Exemplo n.º 4
0
        public virtual int Decode(Bits bits, float[] xout)
        {
            int num = this.lowdec.Decode(bits, this.x0d);

            if (num != 0)
            {
                return(num);
            }
            bool dtx = this.lowdec.Dtx;

            if (bits == null)
            {
                this.DecodeLost(xout, dtx);
                return(0);
            }
            int num2 = bits.Peek();

            if (num2 != 0)
            {
                num2           = bits.Unpack(1);
                this.submodeID = bits.Unpack(3);
            }
            else
            {
                this.submodeID = 0;
            }
            for (int i = 0; i < this.frameSize; i++)
            {
                this.excBuf[i] = 0f;
            }
            if (this.submodes[this.submodeID] != null)
            {
                float[] piGain = this.lowdec.PiGain;
                float[] exc    = this.lowdec.Exc;
                float[] innov  = this.lowdec.Innov;
                this.submodes[this.submodeID].LsqQuant.Unquant(this.qlsp, this.lpcSize, bits);
                if (this.first != 0)
                {
                    for (int i = 0; i < this.lpcSize; i++)
                    {
                        this.old_qlsp[i] = this.qlsp[i];
                    }
                }
                for (int j = 0; j < this.nbSubframes; j++)
                {
                    float num3 = 0f;
                    float num4 = 0f;
                    int   num5 = this.subframeSize * j;
                    float num6 = (1f + (float)j) / (float)this.nbSubframes;
                    for (int i = 0; i < this.lpcSize; i++)
                    {
                        this.interp_qlsp[i] = (1f - num6) * this.old_qlsp[i] + num6 * this.qlsp[i];
                    }
                    Lsp.Enforce_margin(this.interp_qlsp, this.lpcSize, 0.05f);
                    for (int i = 0; i < this.lpcSize; i++)
                    {
                        this.interp_qlsp[i] = (float)Math.Cos((double)this.interp_qlsp[i]);
                    }
                    this.m_lsp.Lsp2lpc(this.interp_qlsp, this.interp_qlpc, this.lpcSize);
                    if (this.enhanced)
                    {
                        float lpcEnhK  = this.submodes[this.submodeID].LpcEnhK1;
                        float lpcEnhK2 = this.submodes[this.submodeID].LpcEnhK2;
                        float gamma    = lpcEnhK - lpcEnhK2;
                        Filters.Bw_lpc(lpcEnhK, this.interp_qlpc, this.awk1, this.lpcSize);
                        Filters.Bw_lpc(lpcEnhK2, this.interp_qlpc, this.awk2, this.lpcSize);
                        Filters.Bw_lpc(gamma, this.interp_qlpc, this.awk3, this.lpcSize);
                    }
                    num6            = 1f;
                    this.pi_gain[j] = 0f;
                    for (int i = 0; i <= this.lpcSize; i++)
                    {
                        num4            += num6 * this.interp_qlpc[i];
                        num6             = -num6;
                        this.pi_gain[j] += this.interp_qlpc[i];
                    }
                    float value = piGain[j];
                    value = 1f / (Math.Abs(value) + 0.01f);
                    num4  = 1f / (Math.Abs(num4) + 0.01f);
                    float num7 = Math.Abs(0.01f + num4) / (0.01f + Math.Abs(value));
                    for (int i = num5; i < num5 + this.subframeSize; i++)
                    {
                        this.excBuf[i] = 0f;
                    }
                    if (this.submodes[this.submodeID].Innovation == null)
                    {
                        int   num8 = bits.Unpack(5);
                        float num9 = (float)Math.Exp(((double)num8 - 10.0) / 8.0);
                        num9 /= num7;
                        for (int i = num5; i < num5 + this.subframeSize; i++)
                        {
                            this.excBuf[i] = this.foldingGain * num9 * innov[i];
                        }
                    }
                    else
                    {
                        int num10 = bits.Unpack(4);
                        for (int i = num5; i < num5 + this.subframeSize; i++)
                        {
                            num3 += exc[i] * exc[i];
                        }
                        float num11 = (float)Math.Exp((double)(0.270270258f * (float)num10 - 2f));
                        float num12 = num11 * (float)Math.Sqrt((double)(1f + num3)) / num7;
                        this.submodes[this.submodeID].Innovation.Unquantify(this.excBuf, num5, this.subframeSize, bits);
                        for (int i = num5; i < num5 + this.subframeSize; i++)
                        {
                            this.excBuf[i] *= num12;
                        }
                        if (this.submodes[this.submodeID].DoubleCodebook != 0)
                        {
                            for (int i = 0; i < this.subframeSize; i++)
                            {
                                this.innov2[i] = 0f;
                            }
                            this.submodes[this.submodeID].Innovation.Unquantify(this.innov2, 0, this.subframeSize, bits);
                            for (int i = 0; i < this.subframeSize; i++)
                            {
                                this.innov2[i] *= num12 * 0.4f;
                            }
                            for (int i = 0; i < this.subframeSize; i++)
                            {
                                this.excBuf[num5 + i] += this.innov2[i];
                            }
                        }
                    }
                    for (int i = num5; i < num5 + this.subframeSize; i++)
                    {
                        this.high[i] = this.excBuf[i];
                    }
                    if (this.enhanced)
                    {
                        Filters.Filter_mem2(this.high, num5, this.awk2, this.awk1, this.subframeSize, this.lpcSize, this.mem_sp, this.lpcSize);
                        Filters.Filter_mem2(this.high, num5, this.awk3, this.interp_qlpc, this.subframeSize, this.lpcSize, this.mem_sp, 0);
                    }
                    else
                    {
                        for (int i = 0; i < this.lpcSize; i++)
                        {
                            this.mem_sp[this.lpcSize + i] = 0f;
                        }
                        Filters.Iir_mem2(this.high, num5, this.interp_qlpc, this.high, num5, this.subframeSize, this.lpcSize, this.mem_sp);
                    }
                }
                this.filters.Fir_mem_up(this.x0d, Codebook_Constants.h0, this.y0, this.fullFrameSize, 64, this.g0_mem);
                this.filters.Fir_mem_up(this.high, Codebook_Constants.h1, this.y1, this.fullFrameSize, 64, this.g1_mem);
                for (int i = 0; i < this.fullFrameSize; i++)
                {
                    xout[i] = 2f * (this.y0[i] - this.y1[i]);
                }
                for (int i = 0; i < this.lpcSize; i++)
                {
                    this.old_qlsp[i] = this.qlsp[i];
                }
                this.first = 0;
                return(0);
            }
            if (dtx)
            {
                this.DecodeLost(xout, true);
                return(0);
            }
            for (int i = 0; i < this.frameSize; i++)
            {
                this.excBuf[i] = 0f;
            }
            this.first = 1;
            Filters.Iir_mem2(this.excBuf, this.excIdx, this.interp_qlpc, this.high, 0, this.frameSize, this.lpcSize, this.mem_sp);
            this.filters.Fir_mem_up(this.x0d, Codebook_Constants.h0, this.y0, this.fullFrameSize, 64, this.g0_mem);
            this.filters.Fir_mem_up(this.high, Codebook_Constants.h1, this.y1, this.fullFrameSize, 64, this.g1_mem);
            for (int i = 0; i < this.fullFrameSize; i++)
            {
                xout[i] = 2f * (this.y0[i] - this.y1[i]);
            }
            return(0);
        }
Exemplo n.º 5
0
        public virtual int Decode(Bits bits, float[] xout)
        {
            int num = 0;

            float[] array = new float[3];
            float   num2  = 0f;
            int     num3  = 40;
            float   num4  = 0f;
            float   num5  = 0f;

            if (bits == null && this.dtx_enabled != 0)
            {
                this.submodeID = 0;
            }
            else
            {
                if (bits == null)
                {
                    this.DecodeLost(xout);
                    return(0);
                }
                while (bits.BitsRemaining() >= 5)
                {
                    int num6;
                    if (bits.Unpack(1) != 0)
                    {
                        num6 = bits.Unpack(3);
                        int num7 = SbCodec.SB_FRAME_SIZE[num6];
                        if (num7 < 0)
                        {
                            throw new InvalidFormatException("Invalid sideband mode encountered (1st sideband): " + num6);
                        }
                        num7 -= 4;
                        bits.Advance(num7);
                        if (bits.Unpack(1) != 0)
                        {
                            num6 = bits.Unpack(3);
                            num7 = SbCodec.SB_FRAME_SIZE[num6];
                            if (num7 < 0)
                            {
                                throw new InvalidFormatException("Invalid sideband mode encountered. (2nd sideband): " + num6);
                            }
                            num7 -= 4;
                            bits.Advance(num7);
                            if (bits.Unpack(1) != 0)
                            {
                                throw new InvalidFormatException("More than two sideband layers found");
                            }
                        }
                    }
                    if (bits.BitsRemaining() < 4)
                    {
                        return(1);
                    }
                    num6 = bits.Unpack(4);
                    if (num6 == 15)
                    {
                        return(1);
                    }
                    if (num6 == 14)
                    {
                        this.inband.SpeexInbandRequest(bits);
                    }
                    else if (num6 == 13)
                    {
                        this.inband.UserInbandRequest(bits);
                    }
                    else if (num6 > 8)
                    {
                        throw new InvalidFormatException("Invalid mode encountered: " + num6);
                    }
                    if (num6 <= 8)
                    {
                        this.submodeID = num6;
                        goto IL_16C;
                    }
                }
                return(-1);
            }
IL_16C:
            Array.Copy(this.frmBuf, this.frameSize, this.frmBuf, 0, this.bufSize - this.frameSize);
            Array.Copy(this.excBuf, this.frameSize, this.excBuf, 0, this.bufSize - this.frameSize);
            if (this.submodes[this.submodeID] == null)
            {
                Filters.Bw_lpc(0.93f, this.interp_qlpc, this.lpc, 10);
                float num8 = 0f;
                for (int i = 0; i < this.frameSize; i++)
                {
                    num8 += this.innov[i] * this.innov[i];
                }
                num8 = (float)Math.Sqrt((double)(num8 / (float)this.frameSize));
                for (int i = this.excIdx; i < this.excIdx + this.frameSize; i++)
                {
                    this.excBuf[i] = (float)((double)(3f * num8) * (this.random.NextDouble() - 0.5));
                }
                this.first = 1;
                Filters.Iir_mem2(this.excBuf, this.excIdx, this.lpc, this.frmBuf, this.frmIdx, this.frameSize, this.lpcSize, this.mem_sp);
                xout[0] = this.frmBuf[this.frmIdx] + this.preemph * this.pre_mem;
                for (int i = 1; i < this.frameSize; i++)
                {
                    xout[i] = this.frmBuf[this.frmIdx + i] + this.preemph * xout[i - 1];
                }
                this.pre_mem    = xout[this.frameSize - 1];
                this.count_lost = 0;
                return(0);
            }
            this.submodes[this.submodeID].LsqQuant.Unquant(this.qlsp, this.lpcSize, bits);
            if (this.count_lost != 0)
            {
                float num9 = 0f;
                for (int i = 0; i < this.lpcSize; i++)
                {
                    num9 += Math.Abs(this.old_qlsp[i] - this.qlsp[i]);
                }
                float num10 = (float)(0.6 * Math.Exp(-0.2 * (double)num9));
                for (int i = 0; i < 2 * this.lpcSize; i++)
                {
                    this.mem_sp[i] *= num10;
                }
            }
            if (this.first != 0 || this.count_lost != 0)
            {
                for (int i = 0; i < this.lpcSize; i++)
                {
                    this.old_qlsp[i] = this.qlsp[i];
                }
            }
            if (this.submodes[this.submodeID].LbrPitch != -1)
            {
                num = this.min_pitch + bits.Unpack(7);
            }
            if (this.submodes[this.submodeID].ForcedPitchGain != 0)
            {
                int num11 = bits.Unpack(4);
                num2 = 0.066667f * (float)num11;
            }
            int   num12 = bits.Unpack(5);
            float num13 = (float)Math.Exp((double)num12 / 3.5);

            if (this.submodeID == 1)
            {
                int num14 = bits.Unpack(4);
                if (num14 == 15)
                {
                    this.dtx_enabled = 1;
                }
                else
                {
                    this.dtx_enabled = 0;
                }
            }
            if (this.submodeID > 1)
            {
                this.dtx_enabled = 0;
            }
            for (int j = 0; j < this.nbSubframes; j++)
            {
                int   num15 = this.subframeSize * j;
                int   num16 = this.frmIdx + num15;
                int   num17 = this.excIdx + num15;
                float num18 = (1f + (float)j) / (float)this.nbSubframes;
                for (int i = 0; i < this.lpcSize; i++)
                {
                    this.interp_qlsp[i] = (1f - num18) * this.old_qlsp[i] + num18 * this.qlsp[i];
                }
                Lsp.Enforce_margin(this.interp_qlsp, this.lpcSize, 0.002f);
                for (int i = 0; i < this.lpcSize; i++)
                {
                    this.interp_qlsp[i] = (float)Math.Cos((double)this.interp_qlsp[i]);
                }
                this.m_lsp.Lsp2lpc(this.interp_qlsp, this.interp_qlpc, this.lpcSize);
                if (this.enhanced)
                {
                    float num19    = 0.9f;
                    float lpcEnhK  = this.submodes[this.submodeID].LpcEnhK1;
                    float lpcEnhK2 = this.submodes[this.submodeID].LpcEnhK2;
                    float gamma    = (1f - (1f - num19 * lpcEnhK) / (1f - num19 * lpcEnhK2)) / num19;
                    Filters.Bw_lpc(lpcEnhK, this.interp_qlpc, this.awk1, this.lpcSize);
                    Filters.Bw_lpc(lpcEnhK2, this.interp_qlpc, this.awk2, this.lpcSize);
                    Filters.Bw_lpc(gamma, this.interp_qlpc, this.awk3, this.lpcSize);
                }
                num18           = 1f;
                this.pi_gain[j] = 0f;
                for (int i = 0; i <= this.lpcSize; i++)
                {
                    this.pi_gain[j] += num18 * this.interp_qlpc[i];
                    num18            = -num18;
                }
                for (int i = 0; i < this.subframeSize; i++)
                {
                    this.excBuf[num17 + i] = 0f;
                }
                int num20;
                if (this.submodes[this.submodeID].LbrPitch != -1)
                {
                    int lbrPitch = this.submodes[this.submodeID].LbrPitch;
                    if (lbrPitch != 0)
                    {
                        num20 = num - lbrPitch + 1;
                        if (num20 < this.min_pitch)
                        {
                            num20 = this.min_pitch;
                        }
                        int num21 = num + lbrPitch;
                        if (num21 > this.max_pitch)
                        {
                            num21 = this.max_pitch;
                        }
                    }
                    else
                    {
                        num20 = num;
                    }
                }
                else
                {
                    num20 = this.min_pitch;
                    int num21 = this.max_pitch;
                }
                int num22 = this.submodes[this.submodeID].Ltp.Unquant(this.excBuf, num17, num20, num2, this.subframeSize, array, bits, this.count_lost, num15, this.last_pitch_gain);
                if (this.count_lost != 0 && num13 < this.last_ol_gain)
                {
                    float num23 = num13 / (this.last_ol_gain + 1f);
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.excBuf[this.excIdx + i] *= num23;
                    }
                }
                num18 = Math.Abs(array[0] + array[1] + array[2]);
                num18 = Math.Abs(array[1]);
                if (array[0] > 0f)
                {
                    num18 += array[0];
                }
                else
                {
                    num18 -= 0.5f * array[0];
                }
                if (array[2] > 0f)
                {
                    num18 += array[2];
                }
                else
                {
                    num18 -= 0.5f * array[0];
                }
                num5 += num18;
                if (num18 > num4)
                {
                    num3 = num22;
                    num4 = num18;
                }
                int num24 = j * this.subframeSize;
                for (int i = num24; i < num24 + this.subframeSize; i++)
                {
                    this.innov[i] = 0f;
                }
                float num26;
                if (this.submodes[this.submodeID].HaveSubframeGain == 3)
                {
                    int num25 = bits.Unpack(3);
                    num26 = (float)((double)num13 * Math.Exp((double)NbCodec.exc_gain_quant_scal3[num25]));
                }
                else if (this.submodes[this.submodeID].HaveSubframeGain == 1)
                {
                    int num25 = bits.Unpack(1);
                    num26 = (float)((double)num13 * Math.Exp((double)NbCodec.exc_gain_quant_scal1[num25]));
                }
                else
                {
                    num26 = num13;
                }
                if (this.submodes[this.submodeID].Innovation != null)
                {
                    this.submodes[this.submodeID].Innovation.Unquantify(this.innov, num24, this.subframeSize, bits);
                }
                for (int i = num24; i < num24 + this.subframeSize; i++)
                {
                    this.innov[i] *= num26;
                }
                if (this.submodeID == 1)
                {
                    float num27 = num2;
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.excBuf[num17 + i] = 0f;
                    }
                    while (this.voc_offset < this.subframeSize)
                    {
                        if (this.voc_offset >= 0)
                        {
                            this.excBuf[num17 + this.voc_offset] = (float)Math.Sqrt((double)(1f * (float)num));
                        }
                        this.voc_offset += num;
                    }
                    this.voc_offset -= this.subframeSize;
                    num27            = 0.5f + 2f * (num27 - 0.6f);
                    if (num27 < 0f)
                    {
                        num27 = 0f;
                    }
                    if (num27 > 1f)
                    {
                        num27 = 1f;
                    }
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        float voc_m = this.excBuf[num17 + i];
                        this.excBuf[num17 + i]  = 0.8f * num27 * this.excBuf[num17 + i] * num13 + 0.6f * num27 * this.voc_m1 * num13 + 0.5f * num27 * this.innov[num24 + i] - 0.5f * num27 * this.voc_m2 + (1f - num27) * this.innov[num24 + i];
                        this.voc_m1             = voc_m;
                        this.voc_m2             = this.innov[num24 + i];
                        this.voc_mean           = 0.95f * this.voc_mean + 0.05f * this.excBuf[num17 + i];
                        this.excBuf[num17 + i] -= this.voc_mean;
                    }
                }
                else
                {
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.excBuf[num17 + i] += this.innov[num24 + i];
                    }
                }
                if (this.submodes[this.submodeID].DoubleCodebook != 0)
                {
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.innov2[i] = 0f;
                    }
                    this.submodes[this.submodeID].Innovation.Unquantify(this.innov2, 0, this.subframeSize, bits);
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.innov2[i] *= num26 * 0.454545438f;
                    }
                    for (int i = 0; i < this.subframeSize; i++)
                    {
                        this.excBuf[num17 + i] += this.innov2[i];
                    }
                }
                for (int i = 0; i < this.subframeSize; i++)
                {
                    this.frmBuf[num16 + i] = this.excBuf[num17 + i];
                }
                if (this.enhanced && this.submodes[this.submodeID].CombGain > 0f)
                {
                    this.filters.Comb_filter(this.excBuf, num17, this.frmBuf, num16, this.subframeSize, num22, array, this.submodes[this.submodeID].CombGain);
                }
                if (this.enhanced)
                {
                    Filters.Filter_mem2(this.frmBuf, num16, this.awk2, this.awk1, this.subframeSize, this.lpcSize, this.mem_sp, this.lpcSize);
                    Filters.Filter_mem2(this.frmBuf, num16, this.awk3, this.interp_qlpc, this.subframeSize, this.lpcSize, this.mem_sp, 0);
                }
                else
                {
                    for (int i = 0; i < this.lpcSize; i++)
                    {
                        this.mem_sp[this.lpcSize + i] = 0f;
                    }
                    Filters.Iir_mem2(this.frmBuf, num16, this.interp_qlpc, this.frmBuf, num16, this.subframeSize, this.lpcSize, this.mem_sp);
                }
            }
            xout[0] = this.frmBuf[this.frmIdx] + this.preemph * this.pre_mem;
            for (int i = 1; i < this.frameSize; i++)
            {
                xout[i] = this.frmBuf[this.frmIdx + i] + this.preemph * xout[i - 1];
            }
            this.pre_mem = xout[this.frameSize - 1];
            for (int i = 0; i < this.lpcSize; i++)
            {
                this.old_qlsp[i] = this.qlsp[i];
            }
            this.first           = 0;
            this.count_lost      = 0;
            this.last_pitch      = num3;
            this.last_pitch_gain = 0.25f * num5;
            this.pitch_gain_buf[this.pitch_gain_buf_idx++] = this.last_pitch_gain;
            if (this.pitch_gain_buf_idx > 2)
            {
                this.pitch_gain_buf_idx = 0;
            }
            this.last_ol_gain = num13;
            return(0);
        }
Exemplo n.º 6
0
        public void UserInbandRequest(Bits bits)
        {
            int num = bits.Unpack(4);

            bits.Advance(5 + 8 * num);
        }
Exemplo n.º 7
0
        public void SpeexInbandRequest(Bits bits)
        {
            switch (bits.Unpack(4))
            {
            case 0:
                bits.Advance(1);
                return;

            case 1:
                bits.Advance(1);
                return;

            case 2:
                bits.Advance(4);
                return;

            case 3:
                bits.Advance(4);
                return;

            case 4:
                bits.Advance(4);
                return;

            case 5:
                bits.Advance(4);
                return;

            case 6:
                bits.Advance(4);
                return;

            case 7:
                bits.Advance(4);
                return;

            case 8:
                bits.Advance(8);
                return;

            case 9:
                this.stereo.Init(bits);
                return;

            case 10:
                bits.Advance(16);
                return;

            case 11:
                bits.Advance(16);
                return;

            case 12:
                bits.Advance(32);
                return;

            case 13:
                bits.Advance(32);
                return;

            case 14:
                bits.Advance(64);
                return;

            case 15:
                bits.Advance(64);
                return;

            default:
                return;
            }
        }
Exemplo n.º 8
0
        public sealed override int Unquant(float[] exc, int es, int start, float pitch_coef, int nsf, float[] gain_val, Bits bits, int count_lost, int subframe_offset, float last_pitch_gain)
        {
            int num = bits.Unpack(this.pitch_bits);

            num += start;
            int num2 = bits.Unpack(this.gain_bits);

            this.gain[0] = 0.015625f * (float)this.gain_cdbk[num2 * 3] + 0.5f;
            this.gain[1] = 0.015625f * (float)this.gain_cdbk[num2 * 3 + 1] + 0.5f;
            this.gain[2] = 0.015625f * (float)this.gain_cdbk[num2 * 3 + 2] + 0.5f;
            if (count_lost != 0 && num > subframe_offset)
            {
                float num3 = Math.Abs(this.gain[1]);
                float num4 = (count_lost < 4) ? last_pitch_gain : (0.4f * last_pitch_gain);
                if (num4 > 0.95f)
                {
                    num4 = 0.95f;
                }
                if (this.gain[0] > 0f)
                {
                    num3 += this.gain[0];
                }
                else
                {
                    num3 -= 0.5f * this.gain[0];
                }
                if (this.gain[2] > 0f)
                {
                    num3 += this.gain[2];
                }
                else
                {
                    num3 -= 0.5f * this.gain[0];
                }
                if (num3 > num4)
                {
                    float num5 = num4 / num3;
                    for (int i = 0; i < 3; i++)
                    {
                        this.gain[i] *= num5;
                    }
                }
            }
            gain_val[0] = this.gain[0];
            gain_val[1] = this.gain[1];
            gain_val[2] = this.gain[2];
            for (int i = 0; i < 3; i++)
            {
                int num6 = num + 1 - i;
                int num7 = nsf;
                if (num7 > num6)
                {
                    num7 = num6;
                }
                int num8 = nsf;
                if (num8 > num6 + num)
                {
                    num8 = num6 + num;
                }
                for (int j = 0; j < num7; j++)
                {
                    this.e[i][j] = exc[es + j - num6];
                }
                for (int j = num7; j < num8; j++)
                {
                    this.e[i][j] = exc[es + j - num6 - num];
                }
                for (int j = num8; j < nsf; j++)
                {
                    this.e[i][j] = 0f;
                }
            }
            for (int i = 0; i < nsf; i++)
            {
                exc[es + i] = this.gain[0] * this.e[2][i] + this.gain[1] * this.e[1][i] + this.gain[2] * this.e[0][i];
            }
            return(num);
        }