Class: DSP::Lpc::Model

Inherits:
Data
  • Object
show all
Defined in:
lib/dsprb/lpc.rb,
sig/dsprb.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#coefficientsObject (readonly)

Returns the value of attribute coefficients

Returns:

  • (Object)

    the current value of coefficients



10
11
12
# File 'lib/dsprb/lpc.rb', line 10

def coefficients
  @coefficients
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



10
11
12
# File 'lib/dsprb/lpc.rb', line 10

def error
  @error
end

Class Method Details

.newModel

Parameters:

  • coefficients: (::Array[::Float])
  • error: (::Float)

Returns:



232
# File 'sig/dsprb.rbs', line 232

def self.new: (coefficients: ::Array[::Float], error: ::Float) -> Model

Instance Method Details

#envelope(points:) ⇒ ::Array[::Float]

Magnitude of the all-pole transfer function 1 / |A(e^w)|^2 sampled over [0, pi], the spectral envelope the predictor implies.

Parameters:

  • points: (::Integer)

Returns:

  • (::Array[::Float])

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dsprb/lpc.rb', line 15

def envelope(points:)
  raise ArgumentError, "points must be at least two, got #{points}" unless points >= 2

  span = points - 1

  Array.new(points) do |index|
    real, imaginary = response(Math::PI * index / span)
    denominator = (real * real) + (imaginary * imaginary)
    denominator < DENOMINATOR_FLOOR ? UNBOUNDED_MAGNITUDE : 1.0 / denominator
  end
end

#order::Integer

Returns:

  • (::Integer)


11
# File 'lib/dsprb/lpc.rb', line 11

def order = coefficients.length - 1