Class: SPCore::FlatTopWindow
- Inherits:
-
Object
- Object
- SPCore::FlatTopWindow
- Defined in:
- lib/spcore/windows/flat_top_window.rb
Overview
For more info, see en.wikipedia.org/wiki/Window_function#Flat_top_window.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(size) ⇒ FlatTopWindow
constructor
A new instance of FlatTopWindow.
Constructor Details
#initialize(size) ⇒ FlatTopWindow
Returns a new instance of FlatTopWindow.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spcore/windows/flat_top_window.rb', line 11 def initialize size @data = Array.new(size) a0, a1, a2, a3, a4 = 1.0, 1.93, 1.29, 0.388, 0.032 size.times do |n| @data[n] = a0 - a1 * Math::cos((TWO_PI * n)/(size - 1)) + a2 * Math::cos((FOUR_PI * n)/(size - 1)) - a3 * Math::cos((SIX_PI * n)/(size - 1)) + a4 * Math::cos((EIGHT_PI * n)/(size - 1)) end max = @data.max # normalize to max of 1.0 @data.each_index do |i| @data[i] /= max end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/spcore/windows/flat_top_window.rb', line 10 def data @data end |