Module: DSP::Parabolic

Defined in:
lib/dsprb/parabolic.rb,
sig/dsprb.rbs

Constant Summary collapse

FLAT_TOLERANCE =

Returns:

  • (::Float)
1e-12

Class Method Summary collapse

Class Method Details

.vertex_offset(previous, current, following) ⇒ ::Float

Offset in samples of the vertex of the parabola through three equally spaced points, used to refine a discrete extremum to sub-sample accuracy.

Parameters:

  • (::Float)
  • (::Float)
  • (::Float)

Returns:

  • (::Float)


11
12
13
14
15
16
# File 'lib/dsprb/parabolic.rb', line 11

def vertex_offset(previous, current, following)
  curvature = (2.0 * current) - previous - following
  return 0.0 if curvature.abs < FLAT_TOLERANCE

  0.5 * (following - previous) / curvature
end