Class: Digiproc::HanningWindow
- Inherits:
-
WindowStrategy
- Object
- WindowStrategy
- Digiproc::HanningWindow
- Defined in:
- lib/strategies/window/hanning_window.rb
Overview
Hanning Window Used to improve digital filters by using a non-retangular frequency domain window
Constant Summary
Constants inherited from WindowStrategy
Instance Attribute Summary
Attributes inherited from WindowStrategy
#data, #equation, #size, #values
Instance Method Summary collapse
-
#find_size(freq) ⇒ Object
Given a freqency, return the required size of a HanningWindow.
-
#initialize(size: nil, norm_trans_freq: nil) ⇒ HanningWindow
constructor
Input Args size (Optional):: Numeric (default: nil), how many datapoings the window should have norm_trans_freq:: Numeric (default: nil), the desired transition frequency If you know what size of the the window that you need, you can input size without norm_trans_freq If you kow the desired transition frequency, the necessary size will be calculated for you based off of the window type so it is not necessary to enter the size.
-
#transition_width ⇒ Object
Return the transition width (in rad/s) based off of the size.
Methods inherited from WindowStrategy
#calculate, #make_odd, #to_signal
Constructor Details
#initialize(size: nil, norm_trans_freq: nil) ⇒ HanningWindow
Input Args
- size (Optional)
-
Numeric (default: nil), how many datapoings the window should have
- norm_trans_freq
-
Numeric (default: nil), the desired transition frequency
If you know what size of the the window that you need, you can input size without norm_trans_freq If you kow the desired transition frequency, the necessary size will be calculated for you based off of the window type so it is not necessary to enter the size
13 14 15 16 17 18 19 |
# File 'lib/strategies/window/hanning_window.rb', line 13 def initialize(size: nil , norm_trans_freq: nil) super(size: norm_trans_freq.nil? ? size : find_size(norm_trans_freq)) size = @size + 2 @equation = lambda { |n| 0.5 - 0.5 * Math.cos(2 * PI * (n + 1) / (size - 1)) } calculate @values = @values.take(@size) end |
Instance Method Details
#find_size(freq) ⇒ Object
Given a freqency, return the required size of a HanningWindow
22 23 24 25 |
# File 'lib/strategies/window/hanning_window.rb', line 22 def find_size(freq) size = 3.1 / freq make_odd(size.ceil) end |
#transition_width ⇒ Object
Return the transition width (in rad/s) based off of the size
28 29 30 |
# File 'lib/strategies/window/hanning_window.rb', line 28 def transition_width 3.1 / @size end |