Class: Digiproc::RectangularWindow

Inherits:
WindowStrategy show all
Defined in:
lib/strategies/window/rectangular_window.rb

Overview

A basic ReactangularWindow used when making a digital filter

Constant Summary

Constants inherited from WindowStrategy

WindowStrategy::PI

Instance Attribute Summary

Attributes inherited from WindowStrategy

#data, #equation, #size, #values

Instance Method Summary collapse

Methods inherited from WindowStrategy

#calculate, #make_odd, #to_signal

Constructor Details

#initialize(size:) ⇒ RectangularWindow

Initialize with a size: Integer Number of datapoints



7
8
9
10
# File 'lib/strategies/window/rectangular_window.rb', line 7

def initialize(size: )
    super(size: size)
    calculate
end

Instance Method Details

#find_size(freq) ⇒ Object

Find the size given an input frequency in rad/s



13
14
15
16
# File 'lib/strategies/window/rectangular_window.rb', line 13

def find_size(freq)
    size = 0.9 / freq
    make_odd(size.ceil)
end

#transition_widthObject

Return the transition width based on the @size



19
20
21
# File 'lib/strategies/window/rectangular_window.rb', line 19

def transition_width
    0.9 / @size
end