Class: SpectrumAnalyzer::WindowFunctions

Inherits:
Object
  • Object
show all
Defined in:
lib/spectrum-analyzer/clients/window_functions.rb

Instance Method Summary collapse

Constructor Details

#initialize(window_size) ⇒ WindowFunctions

Returns a new instance of WindowFunctions.



3
4
5
# File 'lib/spectrum-analyzer/clients/window_functions.rb', line 3

def initialize(window_size)
  @window_size = window_size
end

Instance Method Details

#hanningObject



6
7
8
9
10
11
12
# File 'lib/spectrum-analyzer/clients/window_functions.rb', line 6

def hanning
  hannified_array = Array.new
  i=0
  (0..@window_size).each { |x| hannified_array[i] = 0.5 - 0.5 * Math.cos(2 * Math::PI * i / @window_size) ; i+=1}

  hannified_array
end

#rectangleObject



14
15
16
# File 'lib/spectrum-analyzer/clients/window_functions.rb', line 14

def rectangle
  Array.new(@window_size, 1)
end