Class: Digiproc::KaiserWindow

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

Overview

kaiser Window Used to improve digital filters by using a non-retangular frequency domain window NOT COMPLETE TODO: Finish this Window

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:, stopband_db: nil, beta: nil) ⇒ KaiserWindow

Returns a new instance of KaiserWindow.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/strategies/window/kaiser_window.rb', line 9

def initialize(size: , stopband_db: nil, beta: nil)
    raise ArgumentError.new("Must have a stopband or a beta") if stopband_db.nil? && beta.nil?
    super(size: size)
    size = @size
    @equation = lambda { |n|  }
    calculate
    @values = @values.take(@size)
end

Instance Method Details

#beta_for_db(db) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/strategies/window/kaiser_window.rb', line 18

def beta_for_db(db)
    if db <= 21
        return 0
    elsif db < 50
        return 0.5842*((db - 21) ** 0.4) + 0.07886 * (db - 21)
    else
        return 0.1102*(db - 8.7)
    end
end