Class: Noyes::HammingWindow
- Inherits:
-
Object
- Object
- Noyes::HammingWindow
- Includes:
- Math, NoyesFilterDSL
- Defined in:
- lib/ruby_impl/hamming_window.rb,
lib/common/noyes_dsl.rb
Overview
Takes a m x n matrix and multiples each inner array by a hamming window function. Be careful to make sure your inner array length is the same as the window size.
Instance Method Summary (collapse)
- - (Object) <<(segments)
-
- (HammingWindow) initialize(window_size)
constructor
A new instance of HammingWindow.
Methods included from Math
#dot_product, log2, max, min
Methods included from NoyesFilterDSL
Constructor Details
- (HammingWindow) initialize(window_size)
A new instance of HammingWindow
7 8 9 10 11 12 13 |
# File 'lib/ruby_impl/hamming_window.rb', line 7 def initialize window_size twopi = 2 * PI @hamming_window = [] window_size.times do |i| @hamming_window << 0.54 - 0.46*cos(twopi*i/(window_size-1)) end end |
Instance Method Details
- (Object) <<(segments)
14 15 16 17 18 |
# File 'lib/ruby_impl/hamming_window.rb', line 14 def << segments segments.map do |s| s.zip(@hamming_window).map {|d, h| d*h} end end |