VISR  0.11.8
Versatile Interactive Scene Renderer
visr::rbbl::GainFader< ElementType > Class Template Reference

#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
 

Detailed Description

template<typename ElementType>
class visr::rbbl::GainFader< ElementType >

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.

Template Parameters
ElementTypeThe data type used for the audio samples and the gain values. The class template is explicitly instantiated for element types float and double.

Constructor & Destructor Documentation

template<typename ElementType >
visr::rbbl::GainFader< ElementType >::GainFader ( std::size_t  blockSize,
std::size_t  interpolationSteps,
std::size_t  alignment = 0 
)
explicit

Constructor, sets up the internal data structures

Parameters
blockSizeThe number of samples processed in a single process() call.
interpolationStepsThe number of samples used to interpolate to the end value.
alignmentthe minimum alignment for the input and output vectors as well as the internally stored data members, given as a number of samples.
template<typename ElementType >
visr::rbbl::GainFader< ElementType >::~GainFader ( )
default

Destructor.

Member Function Documentation

template<typename ElementType >
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.

template<typename ElementType >
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..

template<typename ElementType>
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).

Parameters
inputa buffer containing input samples. Must provide mBlockSize elements. sample vector must contain at least blockLength elements.
[out]outputArray to write the scaled output signals. Must provide space for mBlockSize samples.
startGainGain value at the begin of the transition (the complete transition, not the current block)
endGainGain value at the end of the transition (the complete transition, not the current block)
blockIndexblock 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.
template<typename ElementType>
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).

Parameters
inputa buffer containing input samples. Must provide mBlockSize elements. sample vector must contain at least blockLength elements.
[in,out]outputAccArray to write the scaled output signals. Must provide space for mBlockSize samples.
startGainGain value at the begin of the transition (the complete transition, not the current block)
endGainGain value at the end of the transition (the complete transition, not the current block)
blockIndexblock 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.

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