Signalsmith Audio's DSP Library  1.6.0
Useful C++ classes/templates for audio effects
Nested Classes | Types | Methods | Attributes
signalsmith::curves::CubicSegmentCurve< Sample > Class Template Reference

#include <curves.h>

Detailed Description

template<typename Sample = double>
class signalsmith::curves::CubicSegmentCurve< Sample >

Smooth interpolation (optionally monotonic) between points, using cubic segments.

Example curve including a repeated point and an instantaneous jump. The curve is flat beyond the first/last points.

To produce a sharp corner, use a repeated point. The gradient is flat at the edges, unless you use repeated points at the start/end.

Types

using Segment = Cubic< Sample >
 

Methods

void clear ()
 Clear existing points and segments. More...
 
CubicSegmentCurveadd (Sample x, Sample y, bool corner=false)
 Add a new point, but does not recalculate the segments. corner just writes the point twice, for convenience. More...
 
void update (bool monotonic=false, bool extendGrad=true, Sample monotonicFactor=3)
 Recalculates the segments. More...
 
Sample operator() (Sample x) const
 Reads a value out from the curve. More...
 
CubicSegmentCurve dx () const
 
Sample dx (Sample x) const
 
std::vector< Segment > & segments ()
 
const std::vector< Segment > & segments () const
 

Attributes

Sample lowGrad = 0
 
Sample highGrad = 0
 

Method Details

◆ add()

template<typename Sample = double>
CubicSegmentCurve& signalsmith::curves::CubicSegmentCurve< Sample >::add ( Sample  x,
Sample  y,
bool  corner = false 
)
inline

Add a new point, but does not recalculate the segments. corner just writes the point twice, for convenience.

◆ clear()

template<typename Sample = double>
void signalsmith::curves::CubicSegmentCurve< Sample >::clear ( )
inline

Clear existing points and segments.

◆ operator()()

template<typename Sample = double>
Sample signalsmith::curves::CubicSegmentCurve< Sample >::operator() ( Sample  x) const
inline

Reads a value out from the curve.

◆ update()

template<typename Sample = double>
void signalsmith::curves::CubicSegmentCurve< Sample >::update ( bool  monotonic = false,
bool  extendGrad = true,
Sample  monotonicFactor = 3 
)
inline

Recalculates the segments.