Sha256: 4a817ca6892b264bc26b44a7cf207d8a4406e3566e326e98879d7fbf7473c5bd

Contents?: true

Size: 463 Bytes

Versions: 9

Compression:

Stored size: 463 Bytes

Contents

module SPCore
# Produces a Lanczos window of a given size (number of samples).
# The Lanczos window is used in Lanczos resampling.
# For more info, see https://en.wikipedia.org/wiki/Window_function#Lanczos_window.
class LanczosWindow
  attr_reader :data
  def initialize size
    @data = Array.new size
    sinc = lambda {|x| (Math::sin(Math::PI * x))/(Math::PI * x) }
    size.times do |n|
      @data[n] = sinc.call(((2.0*n)/(size-1)) - 1)
    end
  end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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