Switchboard SDK
Loading...
Searching...
No Matches
switchboard::Ramp Class Reference

Linear ramp with fixed duration that can be used for smoothing audio samples. More...

#include <Ramp.hpp>

Public Member Functions

 Ramp ()
 Ramp constructor.
 
 ~Ramp ()
 Ramp destructor.
 
float getValue () const
 Gets the current value of the ramp.
 
void setValue (const float newValue)
 Sets the current value of the ramp. Restarts ramping.
 
float getTargetValue () const
 Gets the current target value.
 
void setTargetValue (const float newValue)
 Sets the target value. Restarts ramping.
 
uint getRampDurationSamples () const
 Gets the duration of the ramp in samples.
 
void setRampDurationSamples (const uint numberOfSamples)
 Sets the duration of the ramp in samples. Restarts ramping.
 
uint getRampDurationMs () const
 Gets the duration of the ramp in milliseconds.
 
void setRampDurationMs (const uint durationMs)
 Sets the duration of the ramp in milliseconds. Restarts ramping.
 
uint getSampleRate () const
 Gets the sample rate.
 
void setSampleRate (const uint sampleRate)
 Sets the sample rate.
 
uint getRemainingSamplesToTargetValue () const
 Gets the remaining samples until the target value in the current ramp.
 
float process (const uint numberOfSamples)
 Processes the ramp and jumps numberOfSamples steps forward.
 

Static Public Member Functions

static void rampMultiply (float *input, float *output, float start, float end, uint numberOfValues)
 Applies a linear ramp multiplier to a buffer.
 
static void rampMultiplyInterleaved (float *input, float *output, float start, float end, uint numberOfFrames, uint numberOfChannels)
 Applies a linear ramp multiplier to an interleaved buffer.
 

Detailed Description

Linear ramp with fixed duration that can be used for smoothing audio samples.

The duration of the ramp can be set specified in number of samples or in milliseconds. If milliseconds is used, the sampleRate property needs to be set too.

Member Function Documentation

◆ getRampDurationMs()

uint switchboard::Ramp::getRampDurationMs ( ) const

Gets the duration of the ramp in milliseconds.

Returns
The duration of the ramp in milliseconds.

◆ getRampDurationSamples()

uint switchboard::Ramp::getRampDurationSamples ( ) const

Gets the duration of the ramp in samples.

Returns
The duration of the ramp in samples.

◆ getRemainingSamplesToTargetValue()

uint switchboard::Ramp::getRemainingSamplesToTargetValue ( ) const

Gets the remaining samples until the target value in the current ramp.

The value changes after the process call.

Returns
The remaining samples until the target value in the current ramp.

◆ getSampleRate()

uint switchboard::Ramp::getSampleRate ( ) const

Gets the sample rate.

Returns
The sample rate.

◆ getTargetValue()

float switchboard::Ramp::getTargetValue ( ) const

Gets the current target value.

Returns
The current target value.

◆ getValue()

float switchboard::Ramp::getValue ( ) const

Gets the current value of the ramp.

Returns
The current value.

◆ process()

float switchboard::Ramp::process ( const uint numberOfSamples)

Processes the ramp and jumps numberOfSamples steps forward.

Parameters
numberOfSamplesThe number of steps to jump in the ramp.
Returns
The ramp value before advancing numberOfSamples steps.

◆ rampMultiply()

void switchboard::Ramp::rampMultiply ( float * input,
float * output,
float start,
float end,
uint numberOfValues )
static

Applies a linear ramp multiplier to a buffer.

Parameters
inputThe input buffer.
outputThe output buffer.
startThe start value of the ramp.
endThe end value of the ramp.
numberOfValuesThe number of values in the buffers.

◆ rampMultiplyInterleaved()

void switchboard::Ramp::rampMultiplyInterleaved ( float * input,
float * output,
float start,
float end,
uint numberOfFrames,
uint numberOfChannels )
static

Applies a linear ramp multiplier to an interleaved buffer.

Parameters
inputThe interleaved input buffer.
outputThe interleaved output buffer.
startThe start value of the ramp.
endThe end value of the ramp.
numberOfFramesThe number of audio frames in the buffers.
numberOfChannelsThe number of audio channels in the buffers.

◆ setRampDurationMs()

void switchboard::Ramp::setRampDurationMs ( const uint durationMs)

Sets the duration of the ramp in milliseconds. Restarts ramping.

Parameters
durationMsThe new ramp duration in milliseconds.

◆ setRampDurationSamples()

void switchboard::Ramp::setRampDurationSamples ( const uint numberOfSamples)

Sets the duration of the ramp in samples. Restarts ramping.

Parameters
numberOfSamplesThe new ramp duration in samples.

◆ setSampleRate()

void switchboard::Ramp::setSampleRate ( const uint sampleRate)

Sets the sample rate.

Parameters
sampleRateThe new sample rate.

◆ setTargetValue()

void switchboard::Ramp::setTargetValue ( const float newValue)

Sets the target value. Restarts ramping.

Parameters
newValueThe new target value.

◆ setValue()

void switchboard::Ramp::setValue ( const float newValue)

Sets the current value of the ramp. Restarts ramping.

Parameters
newValueThe new value to jump to.