/ Used to apply an peak-filter to a signal. Public HighShelfFilter(int sampleRate, double frequency, double gainDB)Ī0 = (v + Math.Sqrt(2 * v) * k + k * k) * norm Ī2 = (v - Math.Sqrt(2 * v) * k + k * k) * norm / Used to apply a highshelf-filter to a signal. Public LowShelfFilter(int sampleRate, double frequency, double gainDB)ĭouble v = Math.Pow(10, Math.Abs(GainDB) / 20.0) Ī0 = (1 + Math.Sqrt(2 * v) * k + v * k * k) * norm Ī2 = (1 - Math.Sqrt(2 * v) * k + v * k * k) * norm / Used to apply a lowshelf-filter to a signal. Public NotchFilter(int sampleRate, double frequency) / Used to apply a notch-filter to a signal. Public BandpassFilter(int sampleRate, double frequency) / Used to apply a bandpass-filter to a signal. Public HighpassFilter(int sampleRate, double frequency) / Used to apply a highpass-filter to a signal. Protected override void CalculateBiQuadCoefficients()ĭouble k = Math.Tan(Math.PI * Frequency / SampleRate) Public LowpassFilter(int sampleRate, double frequency) / Used to apply a lowpass-filter to a signal. Protected abstract void CalculateBiQuadCoefficients() / The result of the calculation gets stored within the array. / Processes a single sample and returns the result. Protected BiQuad(int sampleRate, double frequency, double q) : this(sampleRate, frequency, 1.0 / Math.Sqrt(2)) Protected BiQuad(int sampleRate, double frequency) / Initializes a new instance of the class. / value The samplerate has to be bigger than 2 * frequency. Here is one it has many modes, HP LP BP peak, and so forth, it is a BiQuad perhaps 2 pole static filter something of that kind, it is a particular filter and has a certain kind of digital result: To create a clean output you need to set the resonance to sqrt(2). Note that this filter was created for audio DSP purposes. Public FilterButterworth(float frequency, int sampleRate, PassType passType, float resonance)Ĭ = 1.0f / (float)Math.Tan(Math.PI * frequency / sampleRate) Ī1 = 1.0f / (1.0f + resonance * c + c * c) ī2 = (1.0f - resonance * c + c * c) * a1 Ĭ = (float)Math.Tan(Math.PI * frequency / sampleRate) įloat newOutput = a1 * newInput + a2 * this.inputHistory + a3 * this.inputHistory - b1 * this.outputHistory - b2 * this.outputHistory / Array of output values, latest are in front / Array of input values, latest are in front Private readonly float c, a1, a2, a3, b1, b2
Median filter using dsp builder software#
I implemented the filter in semicode above as follows in our sEMG analyzer software and it works great.