CUGL 2.0
Cornell University Game Library
Static Public Member Functions | Static Public Attributes | List of all members
cugl::dsp::DSPMath Class Reference

#include <CUDSPMath.h>

Static Public Member Functions

static size_t add (float *input1, float *input2, float *output, size_t size)
 
static size_t multiply (float *input1, float *input2, float *output, size_t size)
 
static size_t scale (float *input, float scalar, float *output, size_t size)
 
static size_t scale_add (float *input1, float *input2, float scalar, float *output, size_t size)
 
static size_t slide (float *input, float start, float end, float *output, size_t size)
 
static size_t slide_add (float *input1, float *input2, float start, float end, float *output, size_t size)
 
static size_t clamp (float *data, float min, float max, size_t size)
 
static size_t ease (float *data, float bound, float knee, size_t size)
 

Static Public Attributes

static bool VECTORIZE
 

Detailed Description

This class is a collection of static methods for basic DSP calculations

As with the DSP filters, this class supports vector optimizations for SSE and Neon 64. Our implementation is limited to 128-bit words. While 256-bit (e.g. AVX) are more performant, they are not better for DSP filters and so we keep the optimizations at the same level.

This class is not thread safe. External locking may be required when the filter is shared between multiple threads (such as between an audio thread and the main thread).

Member Function Documentation

◆ add()

static size_t cugl::dsp::DSPMath::add ( float *  input1,
float *  input2,
float *  output,
size_t  size 
)
static

Adds two input signals together, storing the result in output

It is safe for output to be the same as one of the two input buffers.

Parameters
input1The first input buffer
input2The second input buffer
outputThe output buffer
sizeThe number of elements to add
Returns
the number of elements successfully added

◆ clamp()

static size_t cugl::dsp::DSPMath::clamp ( float *  data,
float  min,
float  max,
size_t  size 
)
static

Hard clamps the data stream to the range [min,max]

Parameters
dataThe stream buffer
minThe minimum allowed value
maxThe maximum allowed value
sizeThe number of elements to clamp
Returns
the number of elements successfully clamped

◆ ease()

static size_t cugl::dsp::DSPMath::ease ( float *  data,
float  bound,
float  knee,
size_t  size 
)
static

Soft clamps the data stream to the range [-bound,bound]

The clamp is a soft knee. Values in the range [-knee, knee] are not affected. Values outside this range are asymptotically clamped to the range [-bound,bound] with the formula

y = (bound*x - knee+knee*knee)/x
Parameters
dataThe stream buffer
boundThe asymptotic bound
kneeThe soft knee bound
sizeThe number of elements to clamp
Returns
the number of elements successfully clamped

◆ multiply()

static size_t cugl::dsp::DSPMath::multiply ( float *  input1,
float *  input2,
float *  output,
size_t  size 
)
static

Multiplies two input signals together, storing the result in output

It is safe for output to be the same as one of the two input buffers.

Parameters
input1The first input buffer
input2The second input buffer
outputThe output buffer
sizeThe number of elements to multiply
Returns
the number of elements successfully multiplied

◆ scale()

static size_t cugl::dsp::DSPMath::scale ( float *  input,
float  scalar,
float *  output,
size_t  size 
)
static

Scales an input signal, storing the result in output

It is safe for output to be the same as the input buffer.

Parameters
inputThe input buffer
scalarThe scalar to mutliply by
outputThe output buffer
sizeThe number of elements to multiply
Returns
the number of elements successfully multiplied

◆ scale_add()

static size_t cugl::dsp::DSPMath::scale_add ( float *  input1,
float *  input2,
float  scalar,
float *  output,
size_t  size 
)
static

Scales an input signal and adds it to another, storing the result in output

It is safe for output to be the same as one of the two input buffers.

Parameters
input1The first input buffer
input2The second input buffer
scalarThe scalar to mutliply input1 by
outputThe output buffer
sizeThe number of elements to process
Returns
the number of elements successfully processed

◆ slide()

static size_t cugl::dsp::DSPMath::slide ( float *  input,
float  start,
float  end,
float *  output,
size_t  size 
)
static

Scales an input signal, storing the result in output

The scalar is a sliding factor linearly interpolated between start to end. It will use start for the first element of input and end for the size element.

It is safe for output to be the same as the input buffer.

Parameters
inputThe input buffer
startThe initial scalar value
endThe final scalar value
outputThe output buffer
sizeThe number of elements to multiply
Returns
the number of elements successfully multiplied

◆ slide_add()

static size_t cugl::dsp::DSPMath::slide_add ( float *  input1,
float *  input2,
float  start,
float  end,
float *  output,
size_t  size 
)
static

Scales an input signal and adds it to another, storing the result in output

The scalar is a sliding factor linearly interpolated between start to end. It will use start for the first element of input1 and end for the size element.

It is safe for output to be the same as one of the two input buffers.

Parameters
input1The first input buffer
input2The second input buffer
startThe initial scalar value
endThe final scalar value
outputThe output buffer
sizeThe number of elements to process
Returns
the number of elements successfully processed

Member Data Documentation

◆ VECTORIZE

bool cugl::dsp::DSPMath::VECTORIZE
static

Whether to use a vectorization algorithm (Access not thread safe)


The documentation for this class was generated from the following file: