Example #1
0
        private void DoAMPLL()
        {
            int   blocksize = s.DSPBlockSize;
            float alpha     = pll_internal_state.alpha;
            float beta      = pll_internal_state.beta;
            float lowlimit  = PLLLowLimit;
            float hilimit   = PLLHighLimit;

            for (int i = 0; i < blocksize; i++)
            {
                float tempCos = (float)Math.Cos(pll_internal_state.phase);
                float tempSin = (float)Math.Sin(pll_internal_state.phase);

                float delay_real = tempCos * d.cpx[i].real + tempSin * d.cpx[i].imaginary;
                float delay_imag = -tempSin * d.cpx[i].real + tempCos * d.cpx[i].imaginary;

                float difference = d.GetMagnitude(i) *
                                   (float)Math.Atan2(delay_imag, delay_real);

                PLLFrequency += beta * difference;

                if (PLLFrequency < lowlimit)
                {
                    PLLFrequency = lowlimit;
                }
                if (PLLFrequency > hilimit)
                {
                    PLLFrequency = hilimit;
                }

                pll_internal_state.phase += PLLFrequency + alpha * difference;

                while (pll_internal_state.phase >= this.TWOPI)
                {
                    pll_internal_state.phase -= this.TWOPI;
                }
                while (pll_internal_state.phase < 0)
                {
                    pll_internal_state.phase += this.TWOPI;
                }

                pll_internal_state.lockcurrent  = 0.999F * pll_internal_state.lockcurrent + 0.001F * (float)Math.Abs(delay_real);
                pll_internal_state.lockprevious = pll_internal_state.lockcurrent;
                pll_internal_state.dc           = 0.9999F * pll_internal_state.dc + 0.0001F * delay_real;
                d.tmp_cpx_1[i].real             = delay_real - pll_internal_state.dc;
                d.tmp_cpx_1[i].imaginary        = d.tmp_cpx_1[i].real;
            }
            d.CopyTemp1BotToMainBot();
        }
Example #2
0
        public void Process()
        {
            if (this.localoscon && (this.lofrequency != 0.0f))
            {
                int blocksize = s.DSPBlockSize;

                this.frequencyTone = this.lofrequency / s.DSPSampleRate;
                this.stepTone      = this.frequencyTone * this.TWO_PI;

                for (int i = 0; i < blocksize; i++)
                {
                    if (this.phaseTone >= this.TWO_PI)
                    {
                        this.phaseTone -= this.TWO_PI;
                    }
                    if (this.phaseTone < 0)
                    {
                        this.phaseTone += this.TWO_PI;
                    }

                    this.CosN = Math.Cos(this.phaseTone);
                    this.SinN = Math.Sin(this.phaseTone);

                    d.tmp_cpx_1[i].real      = (float)((this.CosN * d.cpx[i].real) - (this.SinN * d.cpx[i].imaginary)) * this.magnitudeTone;
                    d.tmp_cpx_1[i].imaginary = (float)((this.CosN * d.cpx[i].imaginary) + (this.SinN * d.cpx[i].real)) * this.magnitudeTone;

                    this.phaseTone += this.stepTone;
                }
                d.CopyTemp1BotToMainBot();
            }
            else
            {
                return;
            }
        }
Example #3
0
        private void DoOutputMix()
        {
            int blocksize = s.DSPBlockSize;

            for (int i = 0; i < blocksize; i++)
            {
                d.tmp_cpx_1[i].real      = d.cpx[i].real * this.volume_left + d.cpx[i].imaginary * this.volume_right;
                d.tmp_cpx_1[i].imaginary = d.cpx[i].real * this.volume_right + d.cpx[i].imaginary * this.volume_left;
            }
            d.CopyTemp1BotToMainBot();
        }