SynthLab SDK
SynthLab::XFader Class Reference

Crossfades two values (from A to B) More...

#include <synthbase.h>

Public Member Functions

 XFader ()
 simple construction
 
 XFader (uint32_t _xfadeTime_Samples)
 Constructs the object with initial crossfade time in samples. More...
 
void reset ()
 Resets object to initialized state. More...
 
void setXFadeTime (uint32_t _xfadeTime_Samples)
 Set the current crossfade time. More...
 
void startCrossfade ()
 
void stopCrossfade ()
 
bool isCrossfading ()
 
bool crossfade (XFadeType xfadeType, double inputA, double inputB, double &output)
 Perform crossfade FROM A to B on a pair of input values to oroduce a single output value. More...
 

Protected Attributes

uint32_t xfadeTime_Samples = 4410
 the target crossfade time
 
uint32_t xfadeTime_Counter = 0
 counter for timer
 
bool running = false
 state variable
 

Detailed Description

Crossfades two values (from A to B)

  • specified with crossfade time in samples
  • crossfade() function accepts two values, A and B and then returns a single value that is the combination of the two as a result of the crossfade
  • after the crossfade is complete, the crossfade() function will always return 100% B
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included and described in further detail in Designing Software Synthesizer Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2021 / 04 / 26

Constructor & Destructor Documentation

◆ XFader()

SynthLab::XFader::XFader ( uint32_t  _xfadeTime_Samples)

Constructs the object with initial crossfade time in samples.

Parameters
_xfadeTime_Samplesthe time in samples

Member Function Documentation

◆ crossfade()

bool SynthLab::XFader::crossfade ( XFadeType  xfadeType,
double  inputA,
double  inputB,
double &  output 
)

Perform crossfade FROM A to B on a pair of input values to oroduce a single output value.

  • output is retured via pass-by-reference
Parameters
xfadeTypespecifies the kind of crossfade XFadeType::kConstantPower, kSquareLaw, kLinear
inputAinput value for the A channel that is crossfaded FROM
inputBinput value for the B channel that is crossfaded TO
outputoutput value returned from function
Returns
TRUE if the crossfade is still going (needs more samples) or FALSE if the crossfade is finished (done)

◆ reset()

void SynthLab::XFader::reset ( )

Resets object to initialized state.

initialization

◆ setXFadeTime()

void SynthLab::XFader::setXFadeTime ( uint32_t  _xfadeTime_Samples)

Set the current crossfade time.

fader functions

  • this may be done at any time and may stop the crossfade

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