Beispiel #1
0
        /// <summary>
        /// Computes the IIR coefficients for a notch Butterworth filter.
        /// </summary>
        /// <param name="centralFreq">Filter central frequency.</param>
        /// <param name="Q">Quality factor.</param>
        /// <param name="passbandRipple">Maximum allowed passband ripple.</param>
        /// <param name="stopbandAttenuation">Minimum required stopband attenuation.</param>
        /// <returns>IIR coefficients.</returns>
        /// <seealso cref="Designer.Notch(double, double, double, double)"/>
        public static (IEnumerable <double> numerator, IEnumerable <double> denominator) Notch(double centralFreq, double Q, double passbandRipple, double stopbandAttenuation)
        {
            var(n, wc1, wc2) = Designer.Notch(centralFreq, Q, passbandRipple, stopbandAttenuation);

            const double T = 2;

            var(gain, zeros, poles) = TransferFunction(n);

            wc1 = Helpers.MathFunctions.WarpFrequency(wc1, T);
            wc1 = Helpers.MathFunctions.WarpFrequency(wc2, T);
            (gain, zeros, poles) = TransferFunctionTransformer.BandStop(gain, zeros, poles, wc1, wc2);

            return(Coefficients(gain, zeros, poles, T));
        }
Beispiel #2
0
        /// <summary>
        /// Computes the IIR coefficients for a band-stop Butterworth filter.
        /// </summary>
        /// <param name="lowPassbandFreq">Lower passband corner frequency (in Hz).</param>
        /// <param name="lowStopbandFreq">Lower stopband corner frequency (in Hz).</param>
        /// <param name="highStopbandFreq">Higher stopband corner frequency (in Hz).</param>
        /// <param name="highPassbandFreq">Higher passband corner frequency (in Hz).</param>
        /// <param name="passbandRipple">Maximum allowed passband ripple.</param>
        /// <param name="stopbandAttenuation">Minimum required stopband attenuation.</param>
        /// <returns>IIR coefficients.</returns>
        /// <seealso cref="Designer.BandStop(double, double, double, double, double, double)"/>
        public static (double[] numerator, double[] denominator) BandStop(double lowPassbandFreq, double lowStopbandFreq, double highStopbandFreq, double highPassbandFreq, double passbandRipple, double stopbandAttenuation)
        {
            var(n, wc1, wc2) = Designer.BandStop(lowPassbandFreq, lowStopbandFreq, highStopbandFreq, highPassbandFreq, passbandRipple, stopbandAttenuation);

            const double T = 2;

            var(gain, zeros, poles) = TransferFunction(n);

            wc1 = Helpers.MathFunctions.WarpFrequency(wc1, T);
            wc2 = Helpers.MathFunctions.WarpFrequency(wc2, T);
            (gain, zeros, poles) = TransferFunctionTransformer.BandStop(gain, zeros, poles, wc1, wc2);

            return(Coefficients(gain, zeros, poles, T));
        }