Esempio n. 1
0
        /// <summary>
        /// Compute complex analytic signal, single precision
        /// </summary>
        /// <param name="samples">Array of samples</param>
        /// <param name="norm">Normalize by fft size</param>
        /// <returns>Complex analytic signal</returns>
        public Tuple <float[], float[]> AnalyticSignal(float[] samples, bool norm = true)
        {
            var sre = new DiscreteSignal(1, samples, allocateNew: true);
            var sim = new DiscreteSignal(1, samples.Length);

            var re = sre.Samples;
            var im = sim.Samples;

            _fft32.Direct(re, im);

            for (var i = 1; i < re.Length / 2; i++)
            {
                re[i] *= 2;
                im[i] *= 2;
            }

            for (var i = re.Length / 2 + 1; i < re.Length; i++)
            {
                re[i] = 0.0f;
                im[i] = 0.0f;
            }

            _fft32.Inverse(re, im);

            if (norm)
            {
                sre.Attenuate(re.Length);
                sim.Attenuate(im.Length);
            }

            return(new Tuple <float[], float[]>(re, im));
        }