Class: Noyes::DoubleDeltaFilter
- Inherits:
-
Object
- Object
- Noyes::DoubleDeltaFilter
- Includes:
- NoyesFilterDSL
- Defined in:
- lib/ruby_impl/delta.rb,
lib/common/noyes_dsl.rb
Overview
Takes an m x n array and makes an m x 3 x n array. The original inner array is duplicated followed by its delta and it’s double delta.
Instance Method Summary collapse
- #<<(cepstra) ⇒ Object
-
#final_estimate ⇒ Object
If there is no more data we can estimate a couple more frames by copying the final frame 3 times.
-
#initialize ⇒ DoubleDeltaFilter
constructor
A new instance of DoubleDeltaFilter.
Methods included from NoyesFilterDSL
Constructor Details
#initialize ⇒ DoubleDeltaFilter
Returns a new instance of DoubleDeltaFilter.
5 6 7 |
# File 'lib/ruby_impl/delta.rb', line 5 def initialize @previous = nil end |
Instance Method Details
#<<(cepstra) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_impl/delta.rb', line 8 def << cepstra @previous = [cepstra.first] * 3 unless @previous buf = @previous + cepstra result = [] for i in 3...(buf.size-3) delta = Array.new(buf[i].size) {|k| buf[i+2][k] - buf[i-2][k]} double_delta = Array.new(buf[i].size) do |k| buf[i+3][k] - buf[i-1][k] - buf[i+1][k] + buf[i-3][k] end result << [buf[i], delta, double_delta] end @previous = buf[-6..-1] result end |
#final_estimate ⇒ Object
If there is no more data we can estimate a couple more frames by copying the final frame 3 times. Probably this is rarely necessary.
24 25 26 27 28 |
# File 'lib/ruby_impl/delta.rb', line 24 def final_estimate return [] unless @previous cepstra = [@previous.last] * 3 self.<< cepstra end |