SynthLab SDK
SynthFunctions

Functions

double SynthLab::doLinearInterp (double y1, double y2, double fractional_X)
 performs linear interpolation of fractional x distance between two adjacent (x,y) points; returns interpolated value More...
 
void SynthLab::copyOutputToInput (std::shared_ptr< AudioBuffer > source, std::shared_ptr< AudioBuffer > destination, uint32_t channel, uint32_t samplesToCopy)
 copies an output audio buffer to an input audio buffer More...
 
void SynthLab::copyOutputToOutput (std::shared_ptr< AudioBuffer > source, std::shared_ptr< AudioBuffer > destination, uint32_t channel, uint32_t samplesToCopy)
 copies an output audio buffer to another output audio buffer More...
 
void SynthLab::copyOutputToOutput (std::shared_ptr< AudioBuffer > source, SynthProcessInfo &destination, uint32_t channel, uint32_t samplesToCopy)
 copies an output audio buffer to the SynthProcessInfo audio output buffer More...
 
void SynthLab::copyBufferToInput (std::shared_ptr< AudioBuffer > source, std::shared_ptr< AudioBuffer > destination, uint32_t channel, uint32_t samplesToCopy)
 copies an output audio buffer to an input audio buffer More...
 
void SynthLab::copyAudioBufferOutputToSynthOutput (std::shared_ptr< AudioBuffer > source, SynthProcessInfo &destination, uint32_t channel, uint32_t samplesToCopy)
 copies an output audio buffer to the SynthProcessInfo audio output buffer More...
 
void SynthLab::copySynthOutputToAudioBufferInput (SynthProcessInfo &source, std::shared_ptr< AudioBuffer > destination, uint32_t channel, uint32_t samplesToCopy)
 Complementary function that moves audio from the SynthProcessInfo output into an audio buffer. More...
 
double SynthLab::normToLogNorm (double normalizedValue)
 normalized to Log-normalized version More...
 
double SynthLab::logNormToNorm (double logNormalizedValue)
 log-normalized to normalized version More...
 
double SynthLab::normToAntiLogNorm (double normalizedValue)
 normalized to anti-log normalized version More...
 
double SynthLab::antiLogNormToNorm (double aLogNormalizedValue)
 anti-log normalized to normalized version More...
 
double SynthLab::getModKnobValueLinear (double normalizedValue, double min, double max)
 maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max] More...
 
double SynthLab::getModKnobValueLog (double normalizedValue, double min, double max)
 maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max] logarithmically More...
 
double SynthLab::getModKnobValueAntiLog (double normalizedValue, double min, double max)
 maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max] anti-logarithmically More...
 
double SynthLab::msecToSamples (double sampleRate, double timeMSec)
 convert a time in milliseconds to a floating point sample count More...
 
void SynthLab::clampMaxValue (double &value, double maxValue)
 Bound a value to max limits. More...
 
void SynthLab::clampMinValue (double &value, double minValue)
 Bound a value to min limits. More...
 
void SynthLab::boundValue (double &value, double minValue, double maxValue)
 Bound a value to min and max limits. More...
 
void SynthLab::boundUIntValue (uint32_t &value, uint32_t minValue, uint32_t maxValue)
 Bound a uint32_t value to min and max limits. More...
 
void SynthLab::boundIntValue (int32_t &value, int32_t minValue, int32_t maxValue)
 Bound an int32_t value to min and max limits. More...
 
void SynthLab::boundValueUnipolar (double &value)
 Bound a value to [0, +1]. More...
 
void SynthLab::boundValueBipolar (double &value)
 Bound a value to [-1, +1]. More...
 
void SynthLab::boundMIDIValueByte (uint32_t &value)
 Bound a value to 0 and 127 limits. More...
 
void SynthLab::boundMIDIValueDoubleByte (uint32_t &value)
 Bound a value to min and max limits. More...
 
void SynthLab::mapDoubleValue (double &value, double min, double max, double minMap, double maxMap)
 map double on a range of (min, max) to the same double on the range of (minMap, maxMap) More...
 
void SynthLab::mapDoubleValue (double &value, double min, double minMap, double slope)
 map double on a range of (min, max) to the same double on the range of (minMap, maxMap) using a pre-calculated slope variable where: More...
 
void SynthLab::mapIntValue (int &value, int min, int max, int minMap, int maxMap, bool roundValue=true)
 map int on a range of (min, max) to the same int on the range of (minMap, maxMap) More...
 
void SynthLab::mapUintValue (uint32_t &value, uint32_t min, uint32_t max, uint32_t minMap, uint32_t maxMap, bool roundValue=true)
 map unsigned int on a range of (min, max) to the same unsigned int on the range of (minMap, maxMap) More...
 
uint32_t SynthLab::mapDoubleToUINT (double value, double min, double max, uint32_t minMap, uint32_t maxMap, bool roundValue=false)
 map double on a range of (min, max) to a uint32_t on the range of (minMap, maxMap) More...
 
double SynthLab::mapUINTToDouble (uint32_t value, uint32_t min, uint32_t max, double minMap, double maxMap)
 map uint32_t on a range of (min, max) to a double on the range of (minMap, maxMap) More...
 
double SynthLab::raw2dB (double raw)
 calculates dB for given input More...
 
double SynthLab::dB2Raw (double dB)
 converts dB to raw value More...
 
double SynthLab::peakGainFor_Q (double Q)
 calculates the peak magnitude for a given Q More...
 
double SynthLab::dBPeakGainFor_Q (double Q)
 calculates the peak magnitude in dB for a given Q More...
 
double SynthLab::sgn (double xn)
 calculates sgn( ) of input More...
 
double SynthLab::calcWSGain (double xn, double saturation, double asymmetry)
 calculates gain of a waveshaper More...
 
double SynthLab::atanWaveShaper (double xn, double saturation)
 calculates arctangent waveshaper More...
 
double SynthLab::tanhWaveShaper (double xn, double saturation)
 calculates hyptan waveshaper More...
 
double SynthLab::softClipWaveShaper (double xn, double saturation)
 calculates hyptan waveshaper More...
 
double SynthLab::fuzzExp1WaveShaper (double xn, double saturation, double asymmetry)
 calculates fuzz exp1 waveshaper More...
 
void SynthLab::copyStingList (std::vector< std::string > &source, std::vector< std::string > &destination)
 Copies one vector of strings to another. More...
 
std::string SynthLab::concatStrings (std::string s1, std::string s2)
 Concatenate two strings. More...
 
void SynthLab::ReplaceSubStrWithStr (std::string &str, const std::string &from, const std::string &to)
 Helper to relace strings within a std::string object. More...
 
void SynthLab::stripLastFolderFromPath (std::string &str)
 Helper to strip the last folder path from a given path. More...
 
void SynthLab::getPluginContainerFolder (std::string &str)
 Helper to get the outer plugin folder with the inner folder path. More...
 
double SynthLab::doLinearInterpolation (double x1, double x2, double y1, double y2, double x)
 performs linear interpolation of x distance between two (x,y) points; returns interpolated value More...
 
double SynthLab::doLinearInterpolation (double y1, double y2, double fractional_X)
 performs linear interpolation of fractional x distance between two adjacent (x,y) points; returns interpolated value More...
 
double SynthLab::doLagrangeInterpolation (double *x, double *y, int n, double xbar)
 implements n-order Lagrange Interpolation More...
 
double SynthLab::calculateWaveTablePhaseInc (double oscFrequency, double sampleRate, uint32_t wavetableLength)
 calculates the phase-increment for a wavetable for a target oscillator frequency More...
 
bool SynthLab::checkAndWrapWaveTableIndex (double &index, uint32_t tableLength)
 check and do modulo (fmod) wrap of a wavetable index value More...
 
int SynthLab::countTrailingZero (int x)
 count trailing zeros in a binary number More...
 
uint64_t SynthLab::countTrailingZeros_x64 (uint64_t x)
 count trailing zeros in a binary number, return in unsigned int More...
 
void SynthLab::calculatePanValues (double bipolarModulator, double &leftPanValue, double &rightPanValue)
 calculates the left and right pan values from a bipolar (-1 -> 1) value More...
 
void SynthLab::calculateConstPwrMixValues (double bipolarModulator, double &mixValueA, double &mixValueB)
 converts bipolar (-1 -> 1) value into a pair of constant power mixing coefficients More...
 
double SynthLab::crossfade (XFadeType xfadeType, double inputA, double inputB, double xFrac)
 crossfade two values And B together by some fractional amount More...
 
double SynthLab::semitonesBetweenFrequencies (double startFrequency, double endFrequency)
 calculates the number of semitones between a start and end frequency More...
 
double SynthLab::getTimeFromTempo (double BPM, NoteDuration duration, bool returnMilliseconds=false)
 converts a BPM value and a NoteDuration into a time More...
 
double SynthLab::getTimeFromTempo (double BPM, double normalizedNoteMult)
 converts a BPM value and a normalized note multiplier on the range [0, 1] to a note duration multiplier More...
 
double SynthLab::quantizeBipolarValue (double d, uint32_t qLevels)
 Quantizes a double value into some number of quantization levels. More...
 
uint64_t SynthLab::doubleToUint64 (double d)
 maps a double value into a uint64 value without casting or mangling bits More...
 
double SynthLab::uint64ToDouble (uint64_t u)
 maps a uint64 value to a double value without casting or mangling bits More...
 
uint32_t SynthLab::floatToUint32 (float f)
 maps a float value to a uint32_t value without casting or mangling bits More...
 
float SynthLab::uint32ToFloat (uint32_t u)
 maps a uint32_t value to a float value without casting or mangling bits More...
 
bool SynthLab::inRange (double low, double high, double x)
 tests a number to see if it is withing a certain range More...
 
double SynthLab::wrapMax (double x, double max)
 wraps a value around a maximum value enough times that it falls within the maximum boundary More...
 
double SynthLab::wrapMinMax (double x, double min, double max)
 wraps a value around a maximum value enough times that it falls within the maximum boundary More...
 
std::vector< std::string > SynthLab::charArrayToStringVector (const char **charArray, uint32_t size, std::string ignoreString="")
 Converts an old fasioned array of char* strings to a vector of std::strings. More...
 
bool SynthLab::appendCharArrayToStringVector (const char **charArray, uint32_t size, std::vector< std::string > &outputVector, std::string ignoreString)
 Appends an old fasioned array of char* strings to a vector of std::strings. More...
 
VectorXFadeData SynthLab::calculateVectorMix (double joystick_X, double joystick_Y, double origin_X=0.0, double origin_Y=0.0)
 converts a joystick (x,y) position into the four mixing coefficients plus the X/Y axis shaodows More...
 
double SynthLab::quadraticSine (double angle)
 produces the quadratic sine approximation More...
 
double SynthLab::BhaskaraISine (double angle)
 produces the Bhaskara's sine approximation More...
 
double SynthLab::parabolicSine (double angle)
 highest accurace sinudoid approximation function More...
 
double SynthLab::calculatePitchBend (std::shared_ptr< MidiInputData > midiInputData)
 Calculate a pitch bend multiplier value based on the global MIDI input values: More...
 
uint32_t SynthLab::calculateNumTables (uint32_t seedMIDINote, uint32_t tableIntervalSemitones)
 Calculates the number of wavetables needed to cover the MIDI keyboard starting from a seed note, and them progressing up the keyboard by some number of semitones between each table. More...
 
double SynthLab::readHexLUT (uint64_t *table, double xn)
 Read a table that has been encoded as uint64_t HEX values. More...
 
double SynthLab::concaveXForm (double xn, bool useLUT=false)
 Perform the MMA concave tranform on a unipolar value. More...
 
double SynthLab::bipolarConcaveXForm (double xn, bool useLUT=false)
 Perform the MMA concave tranform on a bipolar value. More...
 
double SynthLab::reverseConcaveXForm (double xn, bool useLUT=false)
 Perform the MMA reverse concave tranform on a unipolar value. More...
 
double SynthLab::bipolarReverseConcaveXForm (double xn, bool useLUT=false)
 Perform the MMA reverse concave tranform on a bipolar value. More...
 
double SynthLab::convexXForm (double xn, bool useLUT=false)
 Perform the MMA convex tranform on a unipolar value. More...
 
double SynthLab::bipolarConvexXForm (double xn, bool useLUT=false)
 Perform the MMA convex tranform on a bipolar value. More...
 
double SynthLab::reverseConvexXForm (double xn, bool useLUT=false)
 Perform the MMA reverse convex tranform on a unipolar value. More...
 
double SynthLab::bipolarReverseConvexXForm (double xn, bool useLUT=false)
 Perform the MMA reverse convex tranform on a bipolar value. More...
 
double SynthLab::doPolyBLEP_2 (double mcounter, double phaseInc, double height, bool risingEdge)
 Calculates the 2nd order polynomial BLEP correction factor. More...
 
double SynthLab::doBLEP_N (uint32_t tableLength, double modCounter, double phaseInc, double height, bool risingEdge, uint32_t pointsPerSide, bool interpolate=false)
 Calculates the BLEP correction factor for 1, 2, 3 or 4 points of correction on each side of the waveform discontinuity. More...
 

Detailed Description

Function Documentation

◆ antiLogNormToNorm()

double SynthLab::antiLogNormToNorm ( double  aLogNormalizedValue)
inline

anti-log normalized to normalized version

Parameters
aLogNormalizedValuelog-normalized value
Returns
anti-log verion, normalized

◆ appendCharArrayToStringVector()

bool SynthLab::appendCharArrayToStringVector ( const char **  charArray,
uint32_t  size,
std::vector< std::string > &  outputVector,
std::string  ignoreString 
)
inline

Appends an old fasioned array of char* strings to a vector of std::strings.

Parameters
charArraythe array to append
sizelength of array
outputVectorthe vector to append, pass by reference
ignoreStringstring to ignore and NOT append to the vector
Returns
true if successful

◆ atanWaveShaper()

double SynthLab::atanWaveShaper ( double  xn,
double  saturation 
)
inline

calculates arctangent waveshaper

Parameters
xnthe input value
saturationthe saturation control
Returns
the waveshaped output value

◆ BhaskaraISine()

double SynthLab::BhaskaraISine ( double  angle)
inline

produces the Bhaskara's sine approximation

  • more accurate than quadratic sine
Parameters
anglesine angle
Returns
Bhaskara I approximation

◆ bipolarConcaveXForm()

double SynthLab::bipolarConcaveXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA concave tranform on a bipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe normalized bipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the convex transformed value

◆ bipolarConvexXForm()

double SynthLab::bipolarConvexXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA convex tranform on a bipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe bipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the convex transformed value

◆ bipolarReverseConcaveXForm()

double SynthLab::bipolarReverseConcaveXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA reverse concave tranform on a bipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe bipolar bipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the reverse convex transformed value

◆ bipolarReverseConvexXForm()

double SynthLab::bipolarReverseConvexXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA reverse convex tranform on a bipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe unipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the bipolar convex transformed value

◆ boundIntValue()

void SynthLab::boundIntValue ( int32_t &  value,
int32_t  minValue,
int32_t  maxValue 
)
inline

Bound an int32_t value to min and max limits.

Parameters
valueto be bound, pass by reference
minValueminimum value of bound
maxValuemaximum value of bound

◆ boundMIDIValueByte()

void SynthLab::boundMIDIValueByte ( uint32_t &  value)
inline

Bound a value to 0 and 127 limits.

Parameters
valueto be bound, pass by reference

◆ boundMIDIValueDoubleByte()

void SynthLab::boundMIDIValueDoubleByte ( uint32_t &  value)
inline

Bound a value to min and max limits.

Parameters
valueto be bound, pass by reference

◆ boundUIntValue()

void SynthLab::boundUIntValue ( uint32_t &  value,
uint32_t  minValue,
uint32_t  maxValue 
)
inline

Bound a uint32_t value to min and max limits.

Parameters
value- value to bound
minValue- lower bound limit
maxValue- upper bound limit

◆ boundValue()

void SynthLab::boundValue ( double &  value,
double  minValue,
double  maxValue 
)
inline

Bound a value to min and max limits.

Parameters
value- value to bound
minValue- lower bound limit
maxValue- upper bound limit

◆ boundValueBipolar()

void SynthLab::boundValueBipolar ( double &  value)
inline

Bound a value to [-1, +1].

Parameters
value- value to bound

◆ boundValueUnipolar()

void SynthLab::boundValueUnipolar ( double &  value)
inline

Bound a value to [0, +1].

Parameters
value- value to bound

◆ calculateConstPwrMixValues()

void SynthLab::calculateConstPwrMixValues ( double  bipolarModulator,
double &  mixValueA,
double &  mixValueB 
)
inline

converts bipolar (-1 -> 1) value into a pair of constant power mixing coefficients

  • returns are via pass-by-reference mechanism
  • identical to constant power pan function
Parameters
bipolarModulatorbipolar input value
mixValueAreturned channel A coefficient
mixValueBreturned channel B coefficient

◆ calculateNumTables()

uint32_t SynthLab::calculateNumTables ( uint32_t  seedMIDINote,
uint32_t  tableIntervalSemitones 
)
inline

Calculates the number of wavetables needed to cover the MIDI keyboard starting from a seed note, and them progressing up the keyboard by some number of semitones between each table.

Parameters
seedMIDINoteMIDI the lowest MIDI note with a wavetable
tableIntervalSemitonesthe interval to skip when counting tables; if this value is 1 then there will be a table on each MIDI note chromatically (semitone); if this value is 3 then there will be a table on each minor third boundary
Returns
the number of tables needed

◆ calculatePanValues()

void SynthLab::calculatePanValues ( double  bipolarModulator,
double &  leftPanValue,
double &  rightPanValue 
)
inline

calculates the left and right pan values from a bipolar (-1 -> 1) value

  • returns are via pass-by-reference mechanism
  • uses sin/cos quadrants for constant-power curve
Parameters
bipolarModulatorbipolar input value
leftPanValuereturned left pan multiplier
rightPanValuereturned right pan multiplier

◆ calculatePitchBend()

double SynthLab::calculatePitchBend ( std::shared_ptr< MidiInputData midiInputData)
inline

Calculate a pitch bend multiplier value based on the global MIDI input values:

  • kMIDIMasterPBSensCoarse (from master controls)
  • kMIDIMasterPBSensFine (from master controls)
  • kMIDIPitchBendDataLSB (from pitch bend wheel)
  • kMIDIPitchBendDataMSB (from pitch bend wheel)
  • NOTE: the term "Master" is verbatim from the MIDI specifiction as of this writing
Parameters
midiInputDataMIDI input data array as a shared pointer
Returns
pitch bend multiplier value as a double

◆ calculateVectorMix()

VectorXFadeData SynthLab::calculateVectorMix ( double  joystick_X,
double  joystick_Y,
double  origin_X = 0.0,
double  origin_Y = 0.0 
)
inline

converts a joystick (x,y) position into the four mixing coefficients plus the X/Y axis shaodows

Parameters
joystick_Xjoytick X coordinate
joystick_Yjoytick X coordinate
origin_Xorigin of X axis
origin_Yorigin of Y axis
Returns
VectorXFadeData structure of various vector mixing coeffients

◆ calculateWaveTablePhaseInc()

double SynthLab::calculateWaveTablePhaseInc ( double  oscFrequency,
double  sampleRate,
uint32_t  wavetableLength 
)
inline

calculates the phase-increment for a wavetable for a target oscillator frequency

Parameters
oscFrequencytarget oscillator frequency
sampleRatefs
wavetableLengthtable length
Returns
the phase-increment for a wavetable lookup

◆ calcWSGain()

double SynthLab::calcWSGain ( double  xn,
double  saturation,
double  asymmetry 
)
inline

calculates gain of a waveshaper

Parameters
xnthe input value
saturationthe saturation control
asymmetrythe degree of asymmetry
Returns
gain value

◆ charArrayToStringVector()

std::vector<std::string> SynthLab::charArrayToStringVector ( const char **  charArray,
uint32_t  size,
std::string  ignoreString = "" 
)
inline

Converts an old fasioned array of char* strings to a vector of std::strings.

Parameters
charArraythe array to convert
sizelength of array
ignoreStringstring to ignore and NOT add to the vector
Returns
the std::vector<std::string> version

◆ checkAndWrapWaveTableIndex()

bool SynthLab::checkAndWrapWaveTableIndex ( double &  index,
uint32_t  tableLength 
)
inline

check and do modulo (fmod) wrap of a wavetable index value

Parameters
indexmodulo counter value, retured with pass-by-reference
tableLengthwavetable length in samples
Returns
the phase-increment for a wavetable lookup

◆ clampMaxValue()

void SynthLab::clampMaxValue ( double &  value,
double  maxValue 
)
inline

Bound a value to max limits.

Parameters
value- value to bound
maxValue- upper bound limit

◆ clampMinValue()

void SynthLab::clampMinValue ( double &  value,
double  minValue 
)
inline

Bound a value to min limits.

Parameters
value- value to bound
minValue- lower bound limit

◆ concatStrings()

std::string SynthLab::concatStrings ( std::string  s1,
std::string  s2 
)
inline

Concatenate two strings.

Parameters
s1the first string
s2the second string
Returns
the concatenation of the two as s1s2

◆ concaveXForm()

double SynthLab::concaveXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA concave tranform on a unipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe normalized value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the convex transformed value

◆ convexXForm()

double SynthLab::convexXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA convex tranform on a unipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe unipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the convex transformed value

◆ copyAudioBufferOutputToSynthOutput()

void SynthLab::copyAudioBufferOutputToSynthOutput ( std::shared_ptr< AudioBuffer source,
SynthProcessInfo destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

copies an output audio buffer to the SynthProcessInfo audio output buffer

  • functionally equivalent to copyOutputToOutput( ); renamed for easier programming
  • used for moving the final rendered audio data fom the engine's output mix buffers to the plugin framework-supplied buffers
  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose output will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ copyBufferToInput()

void SynthLab::copyBufferToInput ( std::shared_ptr< AudioBuffer source,
std::shared_ptr< AudioBuffer destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

copies an output audio buffer to an input audio buffer

  • functionally equivalent to copyOutputToInput( ); renamed for easier programming
  • used for voice object to move data from its mix buffers into the rest of the audio chain
  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose input will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ copyOutputToInput()

void SynthLab::copyOutputToInput ( std::shared_ptr< AudioBuffer source,
std::shared_ptr< AudioBuffer destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

copies an output audio buffer to an input audio buffer

  • used for moving audio data through the audio engine
  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose input will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ copyOutputToOutput() [1/2]

void SynthLab::copyOutputToOutput ( std::shared_ptr< AudioBuffer source,
std::shared_ptr< AudioBuffer destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

copies an output audio buffer to another output audio buffer

  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose output will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ copyOutputToOutput() [2/2]

void SynthLab::copyOutputToOutput ( std::shared_ptr< AudioBuffer source,
SynthProcessInfo destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

copies an output audio buffer to the SynthProcessInfo audio output buffer

  • used for moving the final rendered audio data fom the engine's output mix buffers to the plugin framework-supplied buffers
  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose output will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ copyStingList()

void SynthLab::copyStingList ( std::vector< std::string > &  source,
std::vector< std::string > &  destination 
)
inline

Copies one vector of strings to another.

Parameters
sourcethe source vector to copy
destinationthe vector that receives the copy

◆ copySynthOutputToAudioBufferInput()

void SynthLab::copySynthOutputToAudioBufferInput ( SynthProcessInfo source,
std::shared_ptr< AudioBuffer destination,
uint32_t  channel,
uint32_t  samplesToCopy 
)
inline

Complementary function that moves audio from the SynthProcessInfo output into an audio buffer.

  • used in the plugin framework integration code
  • copies mono->mono. mono->stereo and stereo->stereo
Parameters
sourceAudioBuffer whose output is being copied
destinationAudioBuffer whose output will receive the copied audio data the channels to copy MONO_TO_MONO, MONO_TO_STEREO, STEREO_TO_STEREO
samplesToCopysize of block to copy

◆ countTrailingZero()

int SynthLab::countTrailingZero ( int  x)
inline

count trailing zeros in a binary number

Parameters
xbinary numnber to count trailing zeros
Returns
the number of trailing zeros as int

◆ countTrailingZeros_x64()

uint64_t SynthLab::countTrailingZeros_x64 ( uint64_t  x)
inline

count trailing zeros in a binary number, return in unsigned int

Parameters
xbinary numnber to count trailing zeros
Returns
the number of trailing zeros as uint64_t

◆ crossfade()

double SynthLab::crossfade ( XFadeType  xfadeType,
double  inputA,
double  inputB,
double  xFrac 
)
inline

crossfade two values And B together by some fractional amount

  • frac = 0.0 is 100A
  • frac = 1.0 is 100A
  • frac = 0.5 is a 50A + 50B mixture
Parameters
xfadeTypetype of crossfade: linear, square law, cosntant power
inputAvalue A
inputBvalue B
xFracfractional distance between them to mix
Returns
the mixture of A and B

◆ dB2Raw()

double SynthLab::dB2Raw ( double  dB)
inline

converts dB to raw value

Parameters
dBvalue to convert to raw
Returns
the raw value

◆ dBPeakGainFor_Q()

double SynthLab::dBPeakGainFor_Q ( double  Q)
inline

calculates the peak magnitude in dB for a given Q

Parameters
Qthe Q value
Returns
the peak gain in dB

◆ doBLEP_N()

double SynthLab::doBLEP_N ( uint32_t  tableLength,
double  modCounter,
double  phaseInc,
double  height,
bool  risingEdge,
uint32_t  pointsPerSide,
bool  interpolate = false 
)
inline

Calculates the BLEP correction factor for 1, 2, 3 or 4 points of correction on each side of the waveform discontinuity.

  • uses residual tables found in bleptables.h that have the BLEP residual encoded with a variety of windows
Parameters
tableLengthlenght of the BLEP residual table
modCounterthe modulo counter value that is clocking the oscillator
phaseInccounter's phase increment value
heightnormalized height of the discontinuity to correction
risingEdgetrue if discontinuity is a rising edge, false if falling edge
pointsPerSidenumber of points per side to correct
interpolateset true to interpolate BLEP tables
Returns
the BLEP correction factor

◆ doLagrangeInterpolation()

double SynthLab::doLagrangeInterpolation ( double *  x,
double *  y,
int  n,
double  xbar 
)
inline

implements n-order Lagrange Interpolation

Parameters
xPointer to an array containing the x-coordinates of the input values
yPointer to an array containing the y-coordinates of the input values
nthe order of the interpolator, this is also the length of the x,y input arrays
xbarThe x-coorinates whose y-value we want to interpolate
Returns
the interpolated value

◆ doLinearInterp()

double SynthLab::doLinearInterp ( double  y1,
double  y2,
double  fractional_X 
)
inline

performs linear interpolation of fractional x distance between two adjacent (x,y) points; returns interpolated value

Parameters
y1- the y coordinate of the first point
y2- the 2 coordinate of the second point
fractional_X- the interpolation location as a fractional distance between x1 and x2 (which are not needed)
Returns
the interpolated value or y2 if the interpolation is outside the x interval

◆ doLinearInterpolation() [1/2]

double SynthLab::doLinearInterpolation ( double  x1,
double  x2,
double  y1,
double  y2,
double  x 
)
inline

performs linear interpolation of x distance between two (x,y) points; returns interpolated value

NOTE** you must ensure that the x coordinates are not identical, x1 != x2 to avoid divide by zero; this code needs to be as efficient as possible So, either make sure programatically or check x1,x2 prior to calling!

Parameters
x1the x coordinate of the first point
x2the x coordinate of the second point
y1the y coordinate of the first point
y2the 2 coordinate of the second point
xthe interpolation location
Returns
the interpolated value or y1 if the x coordinates are unusable

◆ doLinearInterpolation() [2/2]

double SynthLab::doLinearInterpolation ( double  y1,
double  y2,
double  fractional_X 
)
inline

performs linear interpolation of fractional x distance between two adjacent (x,y) points; returns interpolated value

Parameters
y1the y coordinate of the first point
y2the 2 coordinate of the second point
fractional_Xthe interpolation location as a fractional distance between x1 and x2 (which are not needed)
Returns
the interpolated value or y2 if the interpolation is outside the x interval

◆ doPolyBLEP_2()

double SynthLab::doPolyBLEP_2 ( double  mcounter,
double  phaseInc,
double  height,
bool  risingEdge 
)
inline

Calculates the 2nd order polynomial BLEP correction factor.

Parameters
mcounterthe modulo counter value that is clocking the oscillator
phaseInccounter's phase increment value
heightnormalized height of the discontinuity to correction
risingEdgetrue if discontinuity is a rising edge, false if falling edge
Returns
the polyBLEP correction factor

◆ doubleToUint64()

uint64_t SynthLab::doubleToUint64 ( double  d)
inline

maps a double value into a uint64 value without casting or mangling bits

  • union for dataype conversion without bit mangling */
  • used to store double values as 64-bit HEX strings for making tables
Parameters
dthe double value to convert
Returns
the input value, bit for bit, encoded as a uint64_t

◆ floatToUint32()

uint32_t SynthLab::floatToUint32 ( float  f)
inline

maps a float value to a uint32_t value without casting or mangling bits

  • used to store double values as 32-bit HEX strings for making tables
Parameters
fthe float value to convert
Returns
the input value, bit for bit, encoded as a uint32_t

◆ fuzzExp1WaveShaper()

double SynthLab::fuzzExp1WaveShaper ( double  xn,
double  saturation,
double  asymmetry 
)
inline

calculates fuzz exp1 waveshaper

Parameters
xnthe input value
saturationthe saturation control
Returns
the waveshaped output value

◆ getModKnobValueAntiLog()

double SynthLab::getModKnobValueAntiLog ( double  normalizedValue,
double  min,
double  max 
)
inline

maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max] anti-logarithmically

Parameters
normalizedValuenormalized value
minthe minimum mapped value
maxthe maximum mapped value
Returns
the new value, mapped on the new range anti-logarithmically

◆ getModKnobValueLinear()

double SynthLab::getModKnobValueLinear ( double  normalizedValue,
double  min,
double  max 
)
inline

maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max]

Parameters
normalizedValuenormalized value
minthe minimum mapped value
maxthe maximum mapped value
Returns
the new value, mapped on the new range

◆ getModKnobValueLog()

double SynthLab::getModKnobValueLog ( double  normalizedValue,
double  min,
double  max 
)
inline

maps a mod-knob value on the range of [0.0, 1.0] to a number on the range [min, max] logarithmically

Parameters
normalizedValuenormalized value
minthe minimum mapped value
maxthe maximum mapped value
Returns
the new value, mapped on the new range logarithmically

◆ getPluginContainerFolder()

void SynthLab::getPluginContainerFolder ( std::string &  str)
inline

Helper to get the outer plugin folder with the inner folder path.

  • this assumes bundle packaging which is the same for AU, AAX, VST3, and RAFX
Parameters
strthe string to manipulate, pass-by-reference

◆ getTimeFromTempo() [1/2]

double SynthLab::getTimeFromTempo ( double  BPM,
NoteDuration  duration,
bool  returnMilliseconds = false 
)
inline

converts a BPM value and a NoteDuration into a time

Parameters
BPMtiming BPM value
durationNoteDuration constant
returnMillisecondsset true if you want milliseconds
Returns
the time in seconds or milliseconds

◆ getTimeFromTempo() [2/2]

double SynthLab::getTimeFromTempo ( double  BPM,
double  normalizedNoteMult 
)
inline

converts a BPM value and a normalized note multiplier on the range [0, 1] to a note duration multiplier

  • there are fewer choices with this function ranging from a whole note to a sixteenth note
  • used specifically for the mod-knobs, which transmit normalized values
  • used for the LFO's sync-to-BPM feature
Parameters
BPMtiming BPM value
normalizedNoteMultnormalized value
Returns
the time in seconds or milliseconds

◆ inRange()

bool SynthLab::inRange ( double  low,
double  high,
double  x 
)
inline

tests a number to see if it is withing a certain range

Parameters
lowthe minimum value of the range
highthe maximum value of the range
xthe value to test
Returns
true if the value is within the range, including endpoints

◆ logNormToNorm()

double SynthLab::logNormToNorm ( double  logNormalizedValue)
inline

log-normalized to normalized version

Parameters
logNormalizedValuelog-normalized value
Returns
normalvalue, normalized

◆ mapDoubleToUINT()

uint32_t SynthLab::mapDoubleToUINT ( double  value,
double  min,
double  max,
uint32_t  minMap,
uint32_t  maxMap,
bool  roundValue = false 
)
inline

map double on a range of (min, max) to a uint32_t on the range of (minMap, maxMap)

Parameters
valueto be mapped
minminimum value of source range
maxmaximum value of source range
minMapminimum value of destination (mapped) range
maxMapmaximum value of destination (mapped) range
roundValueset true to round the final value
Returns
the mapped value as uint32_t

◆ mapDoubleValue() [1/2]

void SynthLab::mapDoubleValue ( double &  value,
double  min,
double  max,
double  minMap,
double  maxMap 
)
inline

map double on a range of (min, max) to the same double on the range of (minMap, maxMap)

Parameters
valueto be mapped, pass-by-reference, returns in this variable
minminimum value of source range
maxmaximum value of source range
minMapminimum value of destination (mapped) range
maxMapmaximum value of destination (mapped) range

◆ mapDoubleValue() [2/2]

void SynthLab::mapDoubleValue ( double &  value,
double  min,
double  minMap,
double  slope 
)
inline

map double on a range of (min, max) to the same double on the range of (minMap, maxMap) using a pre-calculated slope variable where:

  • slope = (maxMap - minMap) / (max - min)
  • used when the input/output mapping ranges are known apriori which is most of the time
Parameters
valueto be mapped, pass-by-reference, returns in this variable
minminimum value of source range
minMapminimum value of destination (mapped) range

◆ mapIntValue()

void SynthLab::mapIntValue ( int &  value,
int  min,
int  max,
int  minMap,
int  maxMap,
bool  roundValue = true 
)
inline

map int on a range of (min, max) to the same int on the range of (minMap, maxMap)

Parameters
valueto be mapped, pass-by-reference, returns in this variable
minminimum value of source range
maxmaximum value of source range
minMapminimum value of destination (mapped) range
maxMapmaximum value of destination (mapped) range
roundValueset true to round the final value (crucial that you get this right for MIDI)

◆ mapUINTToDouble()

double SynthLab::mapUINTToDouble ( uint32_t  value,
uint32_t  min,
uint32_t  max,
double  minMap,
double  maxMap 
)
inline

map uint32_t on a range of (min, max) to a double on the range of (minMap, maxMap)

Parameters
valueto be mapped
minminimum value of source range
maxmaximum value of source range
minMapminimum value of destination (mapped) range
maxMapmaximum value of destination (mapped) range
Returns
the mapped value as double

◆ mapUintValue()

void SynthLab::mapUintValue ( uint32_t &  value,
uint32_t  min,
uint32_t  max,
uint32_t  minMap,
uint32_t  maxMap,
bool  roundValue = true 
)
inline

map unsigned int on a range of (min, max) to the same unsigned int on the range of (minMap, maxMap)

Parameters
valueto be mapped, pass-by-reference, returns in this variable
minminimum value of source range
maxmaximum value of source range
minMapminimum value of destination (mapped) range
maxMapmaximum value of destination (mapped) range
roundValueset true to round the final value (crucial that you get this right for MIDI)

◆ msecToSamples()

double SynthLab::msecToSamples ( double  sampleRate,
double  timeMSec 
)
inline

convert a time in milliseconds to a floating point sample count

Parameters
sampleRatefs
timeMSectime in milliseconds to convert
Returns
the number of samples (fractional)

◆ normToAntiLogNorm()

double SynthLab::normToAntiLogNorm ( double  normalizedValue)
inline

normalized to anti-log normalized version

Parameters
normalizedValuelog-normalized value
Returns
anti-log verion, normalized

◆ normToLogNorm()

double SynthLab::normToLogNorm ( double  normalizedValue)
inline

normalized to Log-normalized version

Parameters
normalizedValuenormalized value
Returns
log10 version, normalized

◆ parabolicSine()

double SynthLab::parabolicSine ( double  angle)
inline

highest accurace sinudoid approximation function

◆ peakGainFor_Q()

double SynthLab::peakGainFor_Q ( double  Q)
inline

calculates the peak magnitude for a given Q

Parameters
Qthe Q value
Returns
the peak gain (not in dB)

◆ quadraticSine()

double SynthLab::quadraticSine ( double  angle)
inline

produces the quadratic sine approximation

Parameters
anglesine angle
Returns
quadratic sine approximation at the given angle

◆ quantizeBipolarValue()

double SynthLab::quantizeBipolarValue ( double  d,
uint32_t  qLevels 
)
inline

Quantizes a double value into some number of quantization levels.

  • used for the step-LFO feature
Parameters
dthe double value to quntize
qLevelsnumber of quantization levels
Returns
the quantized value

◆ raw2dB()

double SynthLab::raw2dB ( double  raw)
inline

calculates dB for given input

Parameters
rawvalue to convert to dB
Returns
the dB value

◆ readHexLUT()

double SynthLab::readHexLUT ( uint64_t *  table,
double  xn 
)
inline

Read a table that has been encoded as uint64_t HEX values.

Parameters
tablethe table to read
xnthe fractional location within the table to read
Returns
the interpolated value as a double

◆ ReplaceSubStrWithStr()

void SynthLab::ReplaceSubStrWithStr ( std::string &  str,
const std::string &  from,
const std::string &  to 
)
inline

Helper to relace strings within a std::string object.

Parameters
strthe string to manipulate, pass-by-reference
fromthe string to find
tothe string to replace with

◆ reverseConcaveXForm()

double SynthLab::reverseConcaveXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA reverse concave tranform on a unipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe unipolar bipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the reverse convex transformed value

◆ reverseConvexXForm()

double SynthLab::reverseConvexXForm ( double  xn,
bool  useLUT = false 
)
inline

Perform the MMA reverse convex tranform on a unipolar value.

  • option to use the calculation or the lookup table (LUT)
Parameters
xnthe unipolar value to transform
useLUTset to true to use lookup table instead of direct calculation
Returns
the reverse convex transformed value

◆ semitonesBetweenFrequencies()

double SynthLab::semitonesBetweenFrequencies ( double  startFrequency,
double  endFrequency 
)
inline

calculates the number of semitones between a start and end frequency

Parameters
startFrequencystart frequency in Hz
endFrequencyend frequency in Hz
Returns
the number of semitones between

◆ sgn()

double SynthLab::sgn ( double  xn)
inline

calculates sgn( ) of input

Parameters
xnthe input value
Returns
-1 if xn is negative or +1 if xn is 0 or greater

◆ softClipWaveShaper()

double SynthLab::softClipWaveShaper ( double  xn,
double  saturation 
)
inline

calculates hyptan waveshaper

Parameters
xnthe input value
saturationthe saturation control
Returns
the waveshaped output value

◆ stripLastFolderFromPath()

void SynthLab::stripLastFolderFromPath ( std::string &  str)
inline

Helper to strip the last folder path from a given path.

Parameters
strthe string to manipulate, pass-by-reference

◆ tanhWaveShaper()

double SynthLab::tanhWaveShaper ( double  xn,
double  saturation 
)
inline

calculates hyptan waveshaper

Parameters
xnthe input value
saturationthe saturation control
Returns
the waveshaped output value

◆ uint32ToFloat()

float SynthLab::uint32ToFloat ( uint32_t  u)
inline

maps a uint32_t value to a float value without casting or mangling bits

  • used to decode double values that were stored as 32-bit HEX strings
Parameters
uthe uint32_t value to convert
Returns
the input value, bit for bit, encoded as a float

◆ uint64ToDouble()

double SynthLab::uint64ToDouble ( uint64_t  u)
inline

maps a uint64 value to a double value without casting or mangling bits

  • used to decode double values that were stored as 64-bit HEX strings
Parameters
uthe uint64_t value to convert
Returns
the input value, bit for bit, encoded as a double

◆ wrapMax()

double SynthLab::wrapMax ( double  x,
double  max 
)
inline

wraps a value around a maximum value enough times that it falls within the maximum boundary

Parameters
xthe value to wrap
maxthe maximum value to wrap over
Returns
the wrapped value

◆ wrapMinMax()

double SynthLab::wrapMinMax ( double  x,
double  min,
double  max 
)
inline

wraps a value around a maximum value enough times that it falls within the maximum boundary

Parameters
xthe value to wrap
minthe minimum value to wrap from
maxthe maximum value to wrap over
Returns
the wrapped value