Exemple #1
0
        public IIRFilter(IIRFilterType Type, int Order, float SampleRate)
        {
            m_filterType = Type;

            m_order = Math.Min(16, Math.Max(1, Math.Abs(Order)));

            m_sampleRate = SampleRate;
            m_fN         = 0.5f * m_sampleRate;

            Design();
        }
Exemple #2
0
        /// <summary>
        /// Creates an instance of IIRFilter class
        /// </summary>
        /// <param name="a">A coefficients of the filter</param>
        /// <param name="b">B coefficients of the filter</param>
        /// <param name="type">Filter type</param>
        public IIRFilter(double[] aCoefficients, double[] bCoefficients, IIRFilterType type)
        {
            if (null == aCoefficients)
            {
                throw new ArgumentNullException(nameof(aCoefficients));
            }
            FilterType         = type;
            numberCoefficients = aCoefficients.Length;

            aCoef = aCoefficients;
            bCoef = bCoefficients;

            x = new double[numberCoefficients];
            y = new double[numberCoefficients];
        }
Exemple #3
0
        /// <summary>
        /// Creates an instance of IIRFilter class
        /// </summary>
        /// <param name="type">Filter type</param>
        /// <param name="order">Filter order</param>
        /// <param name="cutoffFrequency">Filter cutoff frequency in radians per second</param>
        /// <param name="samplingPeriod">Filter sampling period</param>
        public IIRFilter(IIRFilterType type, int order, double cutoffFrequency, double samplingPeriod)
        {
            aCoef = new double[2];
            bCoef = new double[2];

            cuttoffFreqRadpS = cutoffFrequency;
            FilterType       = type;

            switch (type)
            {
            case IIRFilterType.Butterworth:

                ComputeButterworth(order, cutoffFrequency, samplingPeriod);
                break;

            default:
                throw new NotImplementedException("Other filter types are not implemented yet.");
            }

            numberCoefficients = aCoef.Length;

            x = new double[numberCoefficients];
            y = new double[numberCoefficients];
        }