示例#1
0
        private static float[] MakeChebychevWindow(int length, double attenuation)
        {
            double num = Math.Pow(10.0, attenuation / 20.0);

            float[] array = new float[length];
            float   num2  = 0f;
            double  num3  = Math.Cosh(FilterBuilder.ACosh(num) / (double)(length - 1));
            double  num4  = (double)((length - 1) / 2);

            if (length % 2 == 0)
            {
                num4 += 0.5;
            }
            for (int i = 0; i < length / 2 + 1; i++)
            {
                double num5 = (double)i - num4;
                double num6 = 0.0;
                for (int j = 1; (double)j <= num4; j++)
                {
                    num6 += FilterBuilder.ChebychevPoly(length - 1, num3 * Math.Cos(3.1415926535897931 * (double)j / (double)length)) * Math.Cos(2.0 * num5 * 3.1415926535897931 * (double)j / (double)length);
                }
                array[i] = (float)(num + 2.0 * num6);
                array[length - i - 1] = array[i];
                if (array[i] > num2)
                {
                    num2 = array[i];
                }
            }
            float num7 = 1f / num2;

            for (int k = 0; k < length; k++)
            {
                array[k] *= num7;
            }
            return(array);
        }