Class: Digiproc::HighpassFilter

Inherits:
DigitalFilter show all
Defined in:
lib/filters/highpass_filter.rb

Overview

Creates a highpass filter via the windowing method

Constant Summary

Constants inherited from DigitalFilter

DigitalFilter::PI

Instance Attribute Summary collapse

Attributes inherited from DigitalFilter

#fft, #size, #weights, #window

Instance Method Summary collapse

Methods inherited from DigitalFilter

#calculate_ideal, #set_fft_size, #to_ds

Constructor Details

#initialize(size:, window: RectangularWindow, wc:, correct: true) ⇒ HighpassFilter

Inputs

size
Integer

number of datapoints window should be

window
Digiproc::WindowStrategy

desired window strategy

wo
Float

center frequency in radians

bw
Float

bandwidth in radians

correct
Boolean

perform frequency corrections to make frequency points more accurate. Defaults to true

Digiproc::BandpassFilter.new(size: 1000, wo: Math::PI / 4, bw: Math::PI / 10)



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/filters/highpass_filter.rb', line 15

def initialize(size:, window: RectangularWindow, wc: , correct: true)
    super(size: size, window: window)
    wc = wc - @window.transition_width * PI if correct
    @equation = ->(n){ 
        n == 0 ?  (( PI - wc) / PI) :  (-1 * (Math.sin( wc * n) / (PI * n)))
    }
    ideal_filter = calculate_ideal
    @weights = self.window.values.times ideal_filter
    @fft = FFT.new(data: self.weights)
    @fft.calculate
end

Instance Attribute Details

#equationObject

Returns the value of attribute equation.



4
5
6
# File 'lib/filters/highpass_filter.rb', line 4

def equation
  @equation
end