Class: Digiproc::LowpassFilter
- Inherits:
-
DigitalFilter
- Object
- DigitalFilter
- Digiproc::LowpassFilter
- Defined in:
- lib/filters/lowpass_filter.rb
Overview
Creates a Lowpass filter via the windowing method
Constant Summary
Constants inherited from DigitalFilter
Instance Attribute Summary collapse
-
#equation ⇒ Object
Returns the value of attribute equation.
Attributes inherited from DigitalFilter
#fft, #size, #weights, #window
Instance Method Summary collapse
-
#initialize(size:, window: RectangularWindow, wc:, correct: true) ⇒ LowpassFilter
constructor
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.
Methods inherited from DigitalFilter
#calculate_ideal, #set_fft_size, #to_ds
Constructor Details
#initialize(size:, window: RectangularWindow, wc:, correct: true) ⇒ LowpassFilter
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)
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/filters/lowpass_filter.rb', line 16 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 ? (wc / PI) : (Math.sin(wc * n) / (PI * n)) } ideal_filter = calculate_ideal @weights = self.window.values.times ideal_filter @fft = Digiproc::FFT.new(time_data: self.weights) @fft.calculate end |
Instance Attribute Details
#equation ⇒ Object
Returns the value of attribute equation.
5 6 7 |
# File 'lib/filters/lowpass_filter.rb', line 5 def equation @equation end |