Exemplo n.º 1
0
        private unsafe float Utility(float phase, float gain)
        {
            byte *   ptr  = stackalloc byte[(int)(uint)(1024 * sizeof(Complex) + 16)];
            Complex *ptr2 = (Complex *)((long)ptr + 15 & -16);
            byte *   ptr3 = stackalloc byte[4112];
            float *  ptr4 = (float *)((long)ptr3 + 15 & -16);

            Utils.Memcpy(ptr2, this._iqPtr, 1024 * sizeof(Complex));
            IQBalancer.Adjust(ptr2, 1024, phase, gain);
            Fourier.ApplyFFTWindow(ptr2, this._windowPtr, 1024);
            Fourier.ForwardTransform(ptr2, 1024, true);
            Fourier.SpectrumPower(ptr2, ptr4, 1024, 0f, false);
            float num = 0f;

            for (int i = 0; i < 512; i++)
            {
                int num2 = 512 - i;
                if ((float)num2 > 25.6f && (float)num2 < 486.4f)
                {
                    int num3 = 1022 - i;
                    if (ptr4[i] - this._averagePower > 20f || ptr4[num3] - this._averagePower > 20f)
                    {
                        float num4 = ptr4[i] - ptr4[num3];
                        num += num4 * num4;
                    }
                }
            }
            return(num);
        }
Exemplo n.º 2
0
 public unsafe void Process(Complex *iq, int length)
 {
     if (this._removeDC || this._autoBalanceIQ)
     {
         this.remDC(iq, length);
     }
     if (this._autoBalanceIQ && length >= 1024)
     {
         this._iqPtr = iq;
         this.EstimateImbalance();
     }
     if (this._gain == 1f && this._phase == 0f)
     {
         return;
     }
     IQBalancer.Adjust(iq, length, this._phase, this._gain);
 }