Ejemplo n.º 1
0
        private float Utility(ref ComplexF[] iq, float phase, float gain)
        {
            float[] spectrum = new float[4096];
            Array.Copy(iq, 0, fftPtr, 2048, 2048);
            //Array.Copy(zero, 0, fftPtr, 0, 2048);

            for (var i = 0; i < 2048; i++)
            {
                fftPtr[i].Im += phase * fftPtr[i].Re;
                fftPtr[i].Re *= gain;
                fftPtr[i].Re *= window[i];
                fftPtr[i].Im *= window[i];
            }

            fft.FFT_Quick(fftPtr, 4096, FourierDirection.Forward);
            SpectrumPower(ref fftPtr, ref spectrumPtr, 4096, 50.0f);
            Array.Copy(spectrumPtr, 0, spectrum, 2048, 2048);
            Array.Copy(spectrumPtr, 2048, spectrum, 0, 2048);

            /*Array.Copy(spectrumPtr, 0, DX.new_display_data, 2048, 2048);
             * Array.Copy(spectrumPtr, 2048, DX.new_display_data, 0, 2048);
             * Array.Copy(DX.new_display_data, DX.new_waterfall_data, 4096);*/

            var result = 0.0f;

            for (var i = 0; i < 4096 / 2; i++)
            {
                var distanceFromCenter = 4096 / 2 - i;

                if (distanceFromCenter > (0.05f * 4096 / 2))
                {
                    result += Math.Abs(spectrum[i] - spectrum[4096 - 2 - i]);
                }
            }

            Array.Copy(iq, 0, fftPtr, 0, 2048);

            return(result);
        }