Class: Noyes::Preemphasizer

Inherits:
Object
  • Object
show all
Includes:
Math, NoyesFilterDSL
Defined in:
lib/ruby_impl/preemphasis.rb,
lib/common/noyes_dsl.rb

Overview

A simple high pass filter. It takes an array of size n and returns an array of size n.

Instance Method Summary (collapse)

Methods included from Math

#dot_product, log2, max, min

Methods included from NoyesFilterDSL

#+, #|

Constructor Details

- (Preemphasizer) initialize(factor = 0.97)

Returns a new instance of Preemphasizer



6
7
8
9
# File 'lib/ruby_impl/preemphasis.rb', line 6

def initialize factor=0.97
  @factor = factor
  @prior = 0
end

Instance Method Details

- (Object) <<(data)



11
12
13
14
15
16
17
18
19
# File 'lib/ruby_impl/preemphasis.rb', line 11

def << data
  prior = @prior
  @prior = data.last 
  data.map do |x|
     y = x - @factor * prior
     prior = x
     y
  end
end