Class: Digiproc::WindowStrategy
- Inherits:
-
Object
- Object
- Digiproc::WindowStrategy
- Defined in:
- lib/strategies/window/window.rb
Overview
Parent class to all types of windows
Direct Known Subclasses
BlackmanWindow, HammingWindow, HanningWindow, KaiserWindow, RectangularWindow
Constant Summary collapse
- PI =
Math::PI
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#equation ⇒ Object
readonly
Returns the value of attribute equation.
-
#size ⇒ Object
Returns the value of attribute size.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#calculate ⇒ Object
No input args calculate the window values.
-
#initialize(size:) ⇒ WindowStrategy
constructor
Initialize with size: Numeric (numnber of datapoints in window).
-
#make_odd(num) ⇒ Object
Make the number of datapoints in the window odd so that it can be used for all types of filters.
-
#to_signal ⇒ Object
Return window values as a Digiproc::DigitalSignal.
Constructor Details
#initialize(size:) ⇒ WindowStrategy
Initialize with size: Numeric (numnber of datapoints in window)
13 14 15 16 |
# File 'lib/strategies/window/window.rb', line 13 def initialize(size: ) @size = size @equation = lambda { |n| 1 } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/strategies/window/window.rb', line 10 def data @data end |
#equation ⇒ Object (readonly)
Returns the value of attribute equation.
10 11 12 |
# File 'lib/strategies/window/window.rb', line 10 def equation @equation end |
#size ⇒ Object
Returns the value of attribute size.
9 10 11 |
# File 'lib/strategies/window/window.rb', line 9 def size @size end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
10 11 12 |
# File 'lib/strategies/window/window.rb', line 10 def values @values end |
Instance Method Details
#calculate ⇒ Object
No input args calculate the window values
21 22 23 24 25 26 27 28 |
# File 'lib/strategies/window/window.rb', line 21 def calculate values = [] for n in 0...size values << @equation.call(n) end @values = values @data = values end |
#make_odd(num) ⇒ Object
Make the number of datapoints in the window odd so that it can be used for all types of filters
33 34 35 |
# File 'lib/strategies/window/window.rb', line 33 def make_odd(num) num.odd? ? num : num + 1 end |
#to_signal ⇒ Object
Return window values as a Digiproc::DigitalSignal
38 39 40 |
# File 'lib/strategies/window/window.rb', line 38 def to_signal Digiproc::DigitalSignal.new(data: values) end |