public override void Run()
        {
            //throw new NotImplementedException();
            InputTransitionBand  /= 1000;
            InputCutOffFrequency /= 1000;
            InputFS /= 1000;

            // *********************** filters
            int           N                = calculate_N();
            List <double> window           = get_window(N);
            List <double> impulse_response = new List <double>();

            if (InputFilterType == FILTER_TYPES.LOW)
            {
                impulse_response = get_impulse_response_low_filter(N);
            }
            else if (InputFilterType == FILTER_TYPES.HIGH)
            {
                impulse_response = get_impulse_response_high_filter(N);
            }
            else if (InputFilterType == FILTER_TYPES.BAND_PASS)
            {
                impulse_response = bandpass(N);
            }
            else if (InputFilterType == FILTER_TYPES.BAND_STOP)
            {
                impulse_response = bandstop(N);
            }
            //*******************************************************


            OutputHn = new Signal(new List <float>(), new List <int>(), InputTimeDomainSignal.Periodic);

            for (int i = 0; i < impulse_response.Count; ++i)
            {
                OutputHn.SamplesIndices.Add((impulse_response.Count - i - 1) * -1);
                OutputHn.Samples.Add((float)(impulse_response[impulse_response.Count - 1 - i] * window[impulse_response.Count - 1 - i]));
            }


            for (int i = 1; i < impulse_response.Count; ++i)
            {
                OutputHn.SamplesIndices.Add(i);
                OutputHn.Samples.Add((float)(impulse_response[i] * window[i]));
            }

            DirectConvolution convolution = new DirectConvolution();

            convolution.InputSignal1 = InputTimeDomainSignal;
            convolution.InputSignal2 = OutputHn;
            convolution.Run();
            OutputYn = convolution.OutputConvolvedSignal;
            save_coefficients();
        }
        public override void Run()
        {
            #region initializations
            OutputHn = new Signal(new List <float>(), false, new List <float>(), new List <float>(), new List <float>());
            OutputYn = new Signal(new List <float>(), false, new List <float>(), new List <float>(), new List <float>());
            double delta_f = InputTransitionBand, Fc_dash = 0, f1_dash = 0, f2_dash = 0, omega_c = 0, omega_c1 = 0, omega_c2 = 0;
            #endregion

            #region get f', omega and N
            get_f_dash_and_omega(InputFilterType, delta_f, ref Fc_dash, ref f1_dash, ref f2_dash, ref omega_c, ref omega_c1, ref omega_c2);
            int N = get_N(InputStopBandAttenuation, delta_f, InputFS); // FIR coefficients
            #endregion

            #region get OutputHn
            double hd;
            double wc;
            Signal output_hn = new Signal(new List <float>(), false, new List <float>(), new List <float>(), new List <float>());
            output_hn.Samples        = Enumerable.Repeat(default(float), N).ToList();
            output_hn.SamplesIndices = Enumerable.Repeat(default(int), N).ToList();

            #region Low Case
            if (InputFilterType == FILTER_TYPES.LOW)
            {
                for (int n = 0; n <= N / 2; n++)
                {
                    if (n == 0)
                    {
                        hd = 2 * Fc_dash;
                    }
                    else
                    {
                        hd = 2 * Fc_dash * (Math.Sin(n * omega_c) / (n * omega_c));
                    }

                    if (InputStopBandAttenuation <= 21)
                    {
                        wc = 1;
                    }
                    else if (InputStopBandAttenuation <= 44)
                    {
                        wc = .5 + .5 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else if (InputStopBandAttenuation <= 53)
                    {
                        wc = .54 + .46 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else
                    {
                        wc = .42 + .5 * (Math.Cos(2 * Math.PI * n / (N - 1))) + .08 * (Math.Cos(4 * Math.PI * n / (N - 1)));
                    }

                    output_hn.Samples[N / 2 - n] = (float)(hd * wc);
                    output_hn.Samples[N / 2 + n] = (float)(hd * wc);

                    output_hn.SamplesIndices[N / 2 - n] = -n;
                    output_hn.SamplesIndices[N / 2 + n] = n;
                }
            }
            #endregion
            #region High Case
            else if (InputFilterType == FILTER_TYPES.HIGH)
            {
                for (int n = 0; n <= N / 2; n++)
                {
                    if (n == 0)
                    {
                        hd = 1 - 2 * Fc_dash;
                    }
                    else
                    {
                        hd = -2 * Fc_dash * (Math.Sin(n * omega_c) / (n * omega_c));
                    }

                    if (InputStopBandAttenuation <= 21)
                    {
                        wc = 1;
                    }
                    else if (InputStopBandAttenuation <= 44)
                    {
                        wc = .5 + .5 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else if (InputStopBandAttenuation <= 53)
                    {
                        wc = .54 + .46 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else
                    {
                        wc = .42 + .5 * (Math.Cos(2 * Math.PI * n / (N - 1))) + .08 * (Math.Cos(4 * Math.PI * n / (N - 1)));
                    }

                    output_hn.Samples[N / 2 - n] = (float)(hd * wc);
                    output_hn.Samples[N / 2 + n] = (float)(hd * wc);

                    output_hn.SamplesIndices[N / 2 - n] = -n;
                    output_hn.SamplesIndices[N / 2 + n] = n;
                }
            }
            #endregion
            #region BAND_PASS Case
            else if (InputFilterType == FILTER_TYPES.BAND_PASS)
            {
                for (int n = 0; n <= N / 2; n++)
                {
                    if (n == 0)
                    {
                        hd = 2 * (f2_dash - f1_dash);
                    }
                    else
                    {
                        hd = 2 * f2_dash * (Math.Sin(n * omega_c2) / (n * omega_c2)) - 2 * f1_dash * (Math.Sin(n * omega_c1) / (n * omega_c1));
                    }

                    if (InputStopBandAttenuation <= 21)
                    {
                        wc = 1;
                    }
                    else if (InputStopBandAttenuation <= 44)
                    {
                        wc = .5 + .5 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else if (InputStopBandAttenuation <= 53)
                    {
                        wc = .54 + .46 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else
                    {
                        wc = .42 + .5 * (Math.Cos(2 * Math.PI * n / (N - 1))) + .08 * (Math.Cos(4 * Math.PI * n / (N - 1)));
                    }

                    output_hn.Samples[N / 2 - n] = (float)(hd * wc);
                    output_hn.Samples[N / 2 + n] = (float)(hd * wc);

                    output_hn.SamplesIndices[N / 2 - n] = -n;
                    output_hn.SamplesIndices[N / 2 + n] = n;
                }
            }
            #endregion
            #region BAND_Stop Case
            else
            {
                for (int n = 0; n <= N / 2; n++)
                {
                    if (n == 0)
                    {
                        hd = 1 - 2 * (f2_dash - f1_dash);
                    }
                    else
                    {
                        hd = 2 * f1_dash * (Math.Sin(n * omega_c1) / (n * omega_c1)) - 2 * f2_dash * (Math.Sin(n * omega_c2) / (n * omega_c2));
                    }

                    if (InputStopBandAttenuation <= 21)
                    {
                        wc = 1;
                    }
                    else if (InputStopBandAttenuation <= 44)
                    {
                        wc = .5 + .5 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else if (InputStopBandAttenuation <= 53)
                    {
                        wc = .54 + .46 * (Math.Cos(2 * Math.PI * n / N));
                    }
                    else
                    {
                        wc = .42 + .5 * (Math.Cos(2 * Math.PI * n / (N - 1))) + .08 * (Math.Cos(4 * Math.PI * n / (N - 1)));
                    }

                    output_hn.Samples[N / 2 - n] = (float)(hd * wc);
                    output_hn.Samples[N / 2 + n] = (float)(hd * wc);

                    output_hn.SamplesIndices[N / 2 - n] = -n;
                    output_hn.SamplesIndices[N / 2 + n] = n;
                }
            }
            #endregion

            OutputHn = new Signal(new List <float>(output_hn.Samples), new List <int>(output_hn.SamplesIndices), false);
            #endregion

            #region et OutputYn
            DirectConvolution convolution = new DirectConvolution();
            convolution.InputSignal1 = InputTimeDomainSignal;
            convolution.InputSignal2 = output_hn;
            convolution.Run();

            OutputYn = convolution.OutputConvolvedSignal;
            #endregion
        }