![]() |
VISR
0.12.0
Versatile Interactive Scene Renderer
|
#include <gain_fader.hpp>
Public Member Functions | |
GainFader (std::size_t blockSize, std::size_t interpolationSteps, std::size_t alignment=0) | |
~GainFader () | |
std::size_t | interpolationSamples () const |
std::size_t | interpolationPeriods () const |
void | scale (ElementType const *input, ElementType *output, ElementType startGain, ElementType endGain, std::size_t blockIndex) const |
void | scaleAndAccumulate (ElementType const *input, ElementType *outputAcc, ElementType startGain, ElementType endGain, std::size_t blockIndex) const |
Low-level Utility class to apply a linearly interpolated gain change to an audio signal. The class itself is stateless, i.e., it can be used for an arbitrary number of audio signals.
ElementType | The data type used for the audio samples and the gain values. The class template is explicitly instantiated for element types float and double. |
|
explicit |
Constructor, sets up the internal data structures
blockSize | The number of samples processed in a single process() call. |
interpolationSteps | The number of samples used to interpolate to the end value. |
alignment | the minimum alignment for the input and output vectors as well as the internally stored data members, given as a number of samples. |
|
default |
Destructor.
std::size_t visr::rbbl::GainFader< ElementType >::interpolationPeriods | ( | ) | const |
Return the number of interpolation 'buffers'/blocks, i.e., the next integer multiple of the blockSize equal or larger than the number of interpolation samples.
std::size_t visr::rbbl::GainFader< ElementType >::interpolationSamples | ( | ) | const |
Return the number of interpolation steps, i.e., the number of samples it takes to reach a newly set gain value..
void visr::rbbl::GainFader< ElementType >::scale | ( | ElementType const * | input, |
ElementType * | output, | ||
ElementType | startGain, | ||
ElementType | endGain, | ||
std::size_t | blockIndex | ||
) | const |
Process mBlockSize
samples of a single audio signal. The gain trajectory depends on the start end end gain values and the time into the current transition (denoted by blockIndex
). This method does not alter the state of the fader (and is therefore const).
input | a buffer containing input samples. Must provide mBlockSize elements. sample vector must contain at least blockLength elements. | |
[out] | output | Array to write the scaled output signals. Must provide space for mBlockSize samples. |
startGain | Gain value at the begin of the transition (the complete transition, not the current block) | |
endGain | Gain value at the end of the transition (the complete transition, not the current block) | |
blockIndex | block number denoting the current position within the current transition. In this invocation of process(), the section [blockIndex*mBlockSize..(blockIndex+1)*mBlockSize] of the interpolation ramp is applied. A value equal or larger than mInterpolationPeriods means that the signal is scaled by the constant value endGain . |
void visr::rbbl::GainFader< ElementType >::scaleAndAccumulate | ( | ElementType const * | input, |
ElementType * | outputAcc, | ||
ElementType | startGain, | ||
ElementType | endGain, | ||
std::size_t | blockIndex | ||
) | const |
Process mBlockSize
samples of a single audio signal and add to the output signal. The gain trajectory depends on the start end end gain values and the time into the current transition (denoted by blockIndex
). This method does not alter the state of the fader (and is therefore const).
input | a buffer containing input samples. Must provide mBlockSize elements. sample vector must contain at least blockLength elements. | |
[in,out] | outputAcc | Array to write the scaled output signals. Must provide space for mBlockSize samples. |
startGain | Gain value at the begin of the transition (the complete transition, not the current block) | |
endGain | Gain value at the end of the transition (the complete transition, not the current block) | |
blockIndex | block number denoting the current position within the current transition. In this invocation of process(), the section [blockIndex*mBlockSize..(blockIndex+1)*mBlockSize] of the interpolation ramp is applied. A value equal or larger than mInterpolationPeriods means that the signal is scaled by the constant value endGain . |