Пример #1
0
        private double GetExpBandAmplitude(
            double depth,
            Dictionary <int, double> sideBandAmplitudeCache,
            int band)
        {
            if (sideBandAmplitudeCache.ContainsKey(band))
            {
                return(sideBandAmplitudeCache[band]);
            }

            double amplitude;

            double argument = depth * Math.Log(10.0) / 20.0;

            if (band == 0)
            {
                amplitude = Bessel.Bessi(
                    argument: argument,
                    order: 0,
                    cache: besselCache);
            }
            else if (Math.Abs(band) % 2 == 0)
            {
                //Even
                double sign = (Math.Abs(band) / 2) % 2 == 1 ? -1.0 : 1.0;
                amplitude = sign * Bessel.Bessi(
                    argument: argument,
                    order: Math.Abs(band),
                    cache: besselCache);
            }
            else
            {
                //Odd
                double sign = ((Math.Abs(band) - 1) / 2) % 2 == 1 ? -1.0 : 1.0;

                if (band > 0)
                {
                    sign *= -1.0;
                }

                amplitude = sign * Bessel.Bessi(
                    argument: argument,
                    order: Math.Abs(band),
                    cache: besselCache);
            }

            sideBandAmplitudeCache[band] = amplitude;

            return(amplitude);
        }