jamestunnell / spcore

Signal processing basics, including a I/O port scheme to control data flow
MIT License
5 stars 1 forks source link

No parent class specified for Window classes #4

Open jamestunnell opened 8 years ago

jamestunnell commented 8 years ago

The Window classes don't have any parent class specified. A common Window superclass could be provided, or even the Array or Signal class might be appropriate superclasses. What is probable appropriate is a Window superclass, like this:

class Window
  attr_reader :data
  def initialize data
    @data = data
  end

  # Produces a Cosine window of a given size (number of samples).
  # For more info, see https://en.wikipedia.org/wiki/Window_function#Cosine_window.
  class Cosine < Window
    def initialize size
      data = Array.new(size) do |n|
        Math::sin((Math::PI * n)/(size - 1))
      end
      super(data)
    end
  end

  ...
end