Sha256: 09ab7643f38a56f06e4b9fff77a298620567fe3908462017767adfa468660df9

Contents?: true

Size: 402 Bytes

Versions: 9

Compression:

Stored size: 402 Bytes

Contents

module SPCore
# Produces a triangular window of a given size (number of samples).
# Endpoints are zero. Midpoint is one. There is a linear slope between endpoints and midpoint.
class BartlettWindow
  attr_reader :data
  def initialize size
    @data = Array.new(size)
    size.times do |n|
      @data[n] = (2.0 / (size - 1)) * (((size - 1) / 2.0) - (n - ((size - 1) / 2.0)).abs)
    end
  end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spcore-0.2.1 lib/spcore/windows/bartlett_window.rb
spcore-0.2.0 lib/spcore/windows/bartlett_window.rb
spcore-0.1.9 lib/spcore/windows/bartlett_window.rb
spcore-0.1.8 lib/spcore/windows/bartlett_window.rb
spcore-0.1.7 lib/spcore/windows/bartlett_window.rb
spcore-0.1.6 lib/spcore/windows/bartlett_window.rb
spcore-0.1.5 lib/spcore/windows/bartlett_window.rb
spcore-0.1.4 lib/spcore/windows/bartlett_window.rb
spcore-0.1.3 lib/spcore/windows/bartlett_window.rb