Esempio n. 1
0

        
Esempio n. 2
0

        
        /// <summary>
        /// Initialize parameters of the Butterworth filter
        /// </summary>
        public FilterButterworth(double frequency, int sampleRate, ButterworthPassType passType)
        {
            //this.resonance = resonance;

            /*
             * -  we used a 1st order, low-pass Butterworth filter set to 0.05 Hz to extract the tonic signal.
             */
            this.frequency  = frequency;
            this.sampleRate = sampleRate;
            this.passType   = passType;

            switch (passType)
            {
            case ButterworthPassType.Lowpass:
                c  = 1.0 / Math.Tan(Math.PI * frequency / sampleRate);
                a1 = 1.0 / (1.0 + c * c);
                //a1 = 1.0 / (1.0 + resonance * c + c * c);
                a2 = 2.0 * a1;
                a3 = a1;
                b1 = 2.0 * (1.0 - c * c) * a1;
                //b2 = (1.0 + c * c) * a1;
                b2 = (1.0 - resonance * c + c * c) * a1;
                break;

            case ButterworthPassType.Highpass:
                c  = Math.Tan(Math.PI * frequency / sampleRate);
                a1 = 1.0 / (1.0 + c * c);
                //a1 = 1.0 / (1.0 + resonance * c + c * c);
                a2 = -2.0 * a1;
                a3 = a1;
                b1 = 2.0 * (c * c - 1.0) * a1;
                //b2 = (1.0 + c * c) * a1;
                b2 = (1.0 - resonance * c + c * c) * a1;
                break;
            }
        }
Esempio n. 4
0