Class: SPCore::BlackmanWindow
- Inherits:
-
Object
- Object
- SPCore::BlackmanWindow
- Defined in:
- lib/spcore/windows/blackman_window.rb
Overview
For more info, see en.wikipedia.org/wiki/Window_function#Blackman_windows.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(size) ⇒ BlackmanWindow
constructor
A new instance of BlackmanWindow.
Constructor Details
#initialize(size) ⇒ BlackmanWindow
Returns a new instance of BlackmanWindow.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spcore/windows/blackman_window.rb', line 6 def initialize size @data = Array.new size alpha = 0.16 a0 = (1 - alpha) / 2.0 a1 = 0.5 a2 = alpha / 2.0 size.times do |n| @data[n] = a0 - (a1 * Math::cos((TWO_PI * n)/(size - 1))) + (a2 * Math::cos((FOUR_PI * n)/(size - 1))) end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/spcore/windows/blackman_window.rb', line 5 def data @data end |