ASPiK SDK
Loading...
Searching...
No Matches
FX-Functions

The FX-Functions module contains specialized audio DSP C++ functions that are inlcuded with and documented in Will Pirkle's new plugin programming book. These objects are described with even more documentation in this book and are free to use in your projects, commercial or personal. More...

Functions

bool checkFloatUnderflow (double &value)
 Perform underflow check; returns true if we did underflow (user may not care)
 
double 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
 
double doLinearInterpolation (double y1, double y2, double fractional_X)
 performs linear interpolation of fractional x distance between two adjacent (x,y) points; returns interpolated value
 
double doLagrangeInterpolation (double *x, double *y, int n, double xbar)
 implements n-order Lagrange Interpolation
 
void boundValue (double &value, double minValue, double maxValue)
 Bound a value to min and max limits.
 
double doUnipolarModulationFromMin (double unipolarModulatorValue, double minValue, double maxValue)
 Perform unipolar modulation from a min value up to a max value using a unipolar modulator value.
 
double doUnipolarModulationFromMax (double unipolarModulatorValue, double minValue, double maxValue)
 Perform unipolar modulation from a max value down to a min value using a unipolar modulator value.
 
double doBipolarModulation (double bipolarModulatorValue, double minValue, double maxValue)
 Perform bipolar modulation about a center that his halfway between the min and max values.
 
double unipolarToBipolar (double value)
 calculates the bipolar [-1.0, +1.0] value FROM a unipolar [0.0, +1.0] value
 
double bipolarToUnipolar (double value)
 calculates the unipolar [0.0, +1.0] value FROM a bipolar [-1.0, +1.0] value
 
double raw2dB (double raw)
 calculates dB for given input
 
double dB2Raw (double dB)
 converts dB to raw value
 
double peakGainFor_Q (double Q)
 calculates the peak magnitude for a given Q
 
double dBPeakGainFor_Q (double Q)
 calculates the peak magnitude in dB for a given Q
 
double doWhiteNoise ()
 calculates a random value between -1.0 and +1.0
 
double sgn (double xn)
 calculates sgn( ) of input
 
double calcWSGain (double xn, double saturation, double asymmetry)
 calculates gain of a waveshaper
 
double atanWaveShaper (double xn, double saturation)
 calculates arctangent waveshaper
 
double tanhWaveShaper (double xn, double saturation)
 calculates hyptan waveshaper
 
double softClipWaveShaper (double xn, double saturation)
 calculates hyptan waveshaper
 
double fuzzExp1WaveShaper (double xn, double saturation, double asymmetry)
 calculates fuzz exp1 waveshaper
 
double getMagResponse (double theta, double a0, double a1, double a2, double b1, double b2)
 returns the magnitude resonse of a 2nd order H(z) transfer function
 
ComplexNumber complexMultiply (ComplexNumber c1, ComplexNumber c2)
 returns the complex product of two complex numbers
 
void calcEdgeFrequencies (double fc, double Q, double &f_Low, double &f_High)
 calculagte low and high edge frequencies of BPF or BSF
 
int findEdgeTargetBin (double testFreq, double bin1Freq)
 find bin for target frequency
 
bool getTransitionBandData (double testFreq, double bin1Freq, unsigned int relax_Bins, TransitionBandData &transitionData)
 get bin data for a filter's transitino band (see FX book for details)
 
bool calculateBrickwallMagArray (BrickwallMagData &magData)
 calculate an arra of magnitude points from brickwall specifications
 
bool calculateAnalogMagArray (AnalogMagData &magData)
 calculate an arra of magnitude points from analog filter specifications
 
void freqSample (int N, double A[], double h[], int symm)
 calcuate the IR for an array of magnitude points using the frequency sampling method. NOTE: very old function that is all over the internet.
 
double getMagnitude (double re, double im)
 calculates magnitude of a complex numb er
 
double getPhase (double re, double im)
 calculates phase of a complex numb er
 
double principalArg (double phaseIn)
 calculates proncipal argument of a phase value; this is the wrapped value on the range of [-pi, +pi]
 
bool resample (double *input, double *output, uint32_t inLength, uint32_t outLength, interpolation interpType=interpolation::kLinear, double scalar=1.0, double *outWindow=nullptr)
 function that resamples an input array of length N into an output array of length M. You can set the interpolation type (linear or lagrange) and you can supply an optional window array that the resampled array will be processed through.
 
std::unique_ptr< double[]> makeWindow (unsigned int windowLength, unsigned int hopSize, windowType window, double &gainCorrectionValue)
 creates a new std::unique_ptr<double[]> array for a given window lenght and type.
 
unsigned int countForRatio (rateConversionRatio ratio)
 returns the up or downsample ratio as a numeric value
 
double * getFilterIRTable (unsigned int FIRLength, rateConversionRatio ratio, unsigned int sampleRate)
 returns the up or downsample ratio as a numeric value
 
double ** decomposeFilter (double *filterIR, unsigned int FIRLength, unsigned int ratio)
 performs a polyphase decomposition on a big FIR into a set of sub-band FIRs
 
SpeakerArrangement Steinberg::Vst::ASPiK::getSupportedSpeakerArrangement (uint32_t index)
 implements n-order Lagrange Interpolation
 
uint32_t Steinberg::Vst::ASPiK::getChannelFormatForSpkrArrangement (SpeakerArrangement arr)
 implements n-order Lagrange Interpolation
 

Detailed Description

The FX-Functions module contains specialized audio DSP C++ functions that are inlcuded with and documented in Will Pirkle's new plugin programming book. These objects are described with even more documentation in this book and are free to use in your projects, commercial or personal.

Download them from https://www.willpirkle.com/Downloads/fxobjects.zip and then you may drop them into your ASPiK's PluginObject folder and import them into your Visual Studio or XCode projects (you need to do this manually for several reasons, one involving FFTW and that is why it is not a direct part of the SDK). These objects are 100% free for you to use in your commercial or non-commercial plugins. See the ASPiK licensing agreement for details.

Function Documentation

◆ atanWaveShaper()

double atanWaveShaper ( double  xn,
double  saturation 
)
inline

calculates arctangent waveshaper

@atanWaveShaper

Parameters
xn- the input value
saturation- the saturation control
Returns
the waveshaped output value

◆ bipolarToUnipolar()

double bipolarToUnipolar ( double  value)
inline

calculates the unipolar [0.0, +1.0] value FROM a bipolar [-1.0, +1.0] value

@bipolarToUnipolar

Parameters
value- value to convert
Returns
the unipolar value

◆ boundValue()

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

Bound a value to min and max limits.

@boundValue

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

◆ calcEdgeFrequencies()

void calcEdgeFrequencies ( double  fc,
double  Q,
double &  f_Low,
double &  f_High 
)
inline

calculagte low and high edge frequencies of BPF or BSF

@calcEdgeFrequencies

Parameters
fc- the center frequency of the BPF or BSF
Q- the Q (fc/BW) of the filter
f_Low- the returned low edge frequency
f_High- the returned high edge frequency

◆ calculateAnalogMagArray()

bool calculateAnalogMagArray ( AnalogMagData magData)
inline

calculate an arra of magnitude points from analog filter specifications

@calculateAnalogMagArray

Parameters
magData- the the target magnitude data
Returns
true if data was filled, false otherwise

◆ calculateBrickwallMagArray()

bool calculateBrickwallMagArray ( BrickwallMagData magData)
inline

calculate an arra of magnitude points from brickwall specifications

@calculateBrickwallMagArray

Parameters
magData- the the target magnitude data
Returns
true if data was filled, false otherwise

◆ calcWSGain()

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

calculates gain of a waveshaper

@calcWSGain

Parameters
xn- the input value
saturation- the saturation control
asymmetry- the degree of asymmetry
Returns
gain value

◆ checkFloatUnderflow()

bool checkFloatUnderflow ( double &  value)
inline

Perform underflow check; returns true if we did underflow (user may not care)

@checkFloatUnderflow

Parameters
value- the value to check for underflow
Returns
true if overflowed, false otherwise

◆ complexMultiply()

ComplexNumber complexMultiply ( ComplexNumber  c1,
ComplexNumber  c2 
)
inline

returns the complex product of two complex numbers

@complexMultiply

Parameters
c1,c2- complex numbers to multiply
Returns
the complex product of c1 and c2

◆ countForRatio()

unsigned int countForRatio ( rateConversionRatio  ratio)
inline

returns the up or downsample ratio as a numeric value

@countForRatio

Parameters
ratio- enum class ratio value
Returns
the up or downsample ratio as a numeric value

◆ dB2Raw()

double dB2Raw ( double  dB)
inline

converts dB to raw value

@dBTo_Raw

Parameters
dB- value to convert to raw
Returns
the raw value

◆ dBPeakGainFor_Q()

double dBPeakGainFor_Q ( double  Q)
inline

calculates the peak magnitude in dB for a given Q

@dBPeakGainFor_Q

Parameters
Q- the Q value
Returns
the peak gain in dB

◆ decomposeFilter()

double ** decomposeFilter ( double *  filterIR,
unsigned int  FIRLength,
unsigned int  ratio 
)
inline

performs a polyphase decomposition on a big FIR into a set of sub-band FIRs

@decomposeFilter

Parameters
filterIR- pointer to filter IR array
FIRLength- lenght of IR array
ratio- up or down sampling ratio
Returns
a pointer an arry of buffer pointers to the decomposed mini-filters

◆ doBipolarModulation()

double doBipolarModulation ( double  bipolarModulatorValue,
double  minValue,
double  maxValue 
)
inline

Perform bipolar modulation about a center that his halfway between the min and max values.

@doBipolarModulation

Parameters
bipolarModulatorValue- modulation value on range [-1.0, +1.0]
minValue- lower modulation limit
maxValue- upper modulation limit
Returns
the modulated value

◆ doLagrangeInterpolation()

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

implements n-order Lagrange Interpolation

@doLagrangeInterpolation

Parameters
x- Pointer to an array containing the x-coordinates of the input values
y- Pointer to an array containing the y-coordinates of the input values
n- the order of the interpolator, this is also the length of the x,y input arrays
xbar- The x-coorinates whose y-value we want to interpolate
Returns
the interpolated value

◆ doLinearInterpolation() [1/2]

double 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

@doLinearInterpolation

Parameters
x1- the x coordinate of the first point
x2- the x coordinate of the second point
y1- the y coordinate of the first point
y2- the 2 coordinate of the second point
x- the interpolation location
Returns
the interpolated value or y1 if the x coordinates are unusable

◆ doLinearInterpolation() [2/2]

double 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

@doLinearInterpolation

Parameters
y1- the y coordinate of the first point
y2- the 2 coordinate of the second point
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

◆ doUnipolarModulationFromMax()

double doUnipolarModulationFromMax ( double  unipolarModulatorValue,
double  minValue,
double  maxValue 
)
inline

Perform unipolar modulation from a max value down to a min value using a unipolar modulator value.

@doUnipolarModulationFromMax

Parameters
unipolarModulatorValue- modulation value on range [0.0, +1.0]
minValue- lower modulation limit
maxValue- upper modulation limit
Returns
the modulated value

◆ doUnipolarModulationFromMin()

double doUnipolarModulationFromMin ( double  unipolarModulatorValue,
double  minValue,
double  maxValue 
)
inline

Perform unipolar modulation from a min value up to a max value using a unipolar modulator value.

@doUnipolarModulationFromMin

Parameters
unipolarModulatorValue- modulation value on range [0.0, +1.0]
minValue- lower modulation limit
maxValue- upper modulation limit
Returns
the modulated value

◆ doWhiteNoise()

double doWhiteNoise ( )
inline

calculates a random value between -1.0 and +1.0

@doWhiteNoise

Returns
the random value on the range [-1.0, +1.0]

◆ findEdgeTargetBin()

int findEdgeTargetBin ( double  testFreq,
double  bin1Freq 
)
inline

find bin for target frequency

@findEdgeTargetBin

Parameters
testFreq- the target frequency
bin1Freq- the frequency of bin 1
Returns
the index of the target bin

◆ freqSample()

void freqSample ( int  N,
double  A[],
double  h[],
int  symm 
)
inline

calcuate the IR for an array of magnitude points using the frequency sampling method. NOTE: very old function that is all over the internet.

@freqSample

Parameters
N- Number of filter coefficients
A[]- Sample points of desired response [N/2]
symmetry- Symmetry of desired filter
h[]- the output array of impulse response

◆ fuzzExp1WaveShaper()

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

calculates fuzz exp1 waveshaper

@fuzzExp1WaveShaper

Parameters
xn- the input value
saturation- the saturation control
Returns
the waveshaped output value

◆ getChannelFormatForSpkrArrangement()

uint32_t Steinberg::Vst::ASPiK::getChannelFormatForSpkrArrangement ( SpeakerArrangement  arr)

implements n-order Lagrange Interpolation

@getChannelFormatForSpkrArrangement

Parameters
SpeakerArrangementthe VST speaker arrangement
Returns
the ASPiK channel I/O combination enum

◆ getFilterIRTable()

double * getFilterIRTable ( unsigned int  FIRLength,
rateConversionRatio  ratio,
unsigned int  sampleRate 
)
inline

returns the up or downsample ratio as a numeric value

@getFilterIRTable

Parameters
FIRLength- lenght of FIR
ratio- the conversinon ratio
sampleRate- the sample rate
Returns
a pointer to the appropriate FIR coefficient table in filters.h or nullptr if not found

◆ getMagnitude()

double getMagnitude ( double  re,
double  im 
)
inline

calculates magnitude of a complex numb er

@getMagnitude

Parameters
re- complex number real part
im- complex number imaginary part
Returns
the magnitude value

◆ getMagResponse()

double getMagResponse ( double  theta,
double  a0,
double  a1,
double  a2,
double  b1,
double  b2 
)
inline

returns the magnitude resonse of a 2nd order H(z) transfer function

@getMagResponse

Parameters
theta- the angular frequency to apply
a0,a1,a2,b1,b2- the transfer function coefficients
Returns
the magnigtude response of the transfer function at w = theta

◆ getPhase()

double getPhase ( double  re,
double  im 
)
inline

calculates phase of a complex numb er

@getPhase

Parameters
re- complex number real part
im- complex number imaginary part
Returns
the phase value

◆ getSupportedSpeakerArrangement()

SpeakerArrangement Steinberg::Vst::ASPiK::getSupportedSpeakerArrangement ( uint32_t  index)

implements n-order Lagrange Interpolation

@getSupportedSpeakerArrangement

Parameters
indexindex of channel I/O struct
Returns
the VST SpeakerArrangement version of ASPiK channel I/O combi

◆ getTransitionBandData()

bool getTransitionBandData ( double  testFreq,
double  bin1Freq,
unsigned int  relax_Bins,
TransitionBandData transitionData 
)
inline

get bin data for a filter's transitino band (see FX book for details)

@getTransitionBandData

Parameters
testFreq- the target frequency
bin1Freq- the frequency of bin 1
relax_Bins- numebr of bins to relax the filter specification
transitionData- the output parameter containing the data
Returns
true if data was filled, false otherwise

◆ makeWindow()

std::unique_ptr< double[]> makeWindow ( unsigned int  windowLength,
unsigned int  hopSize,
windowType  window,
double &  gainCorrectionValue 
)
inline

creates a new std::unique_ptr<double[]> array for a given window lenght and type.

@makeWindow

Parameters
windowLength- length of window array (does NOT need to be power of 2)
hopSize- hopSize for vococerf applications, may set to 0 for non vocoder use
gainCorrectionValue- return variable that contains the window gain correction value

◆ peakGainFor_Q()

double peakGainFor_Q ( double  Q)
inline

calculates the peak magnitude for a given Q

@peakGainFor_Q

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

◆ principalArg()

double principalArg ( double  phaseIn)
inline

calculates proncipal argument of a phase value; this is the wrapped value on the range of [-pi, +pi]

@principalArg

Parameters
phaseIn- value to convert
Returns
the phase value on the range of [-pi, +pi]

◆ raw2dB()

double raw2dB ( double  raw)
inline

calculates dB for given input

@rawTo_dB

Parameters
raw- value to convert to dB
Returns
the dB value

◆ resample()

bool resample ( double *  input,
double *  output,
uint32_t  inLength,
uint32_t  outLength,
interpolation  interpType = interpolation::kLinear,
double  scalar = 1.0,
double *  outWindow = nullptr 
)
inline

function that resamples an input array of length N into an output array of length M. You can set the interpolation type (linear or lagrange) and you can supply an optional window array that the resampled array will be processed through.

@resample

Parameters
input- input array
output- output array
inLength- length N of input buffer
outLength- length M of output buffer
interpType- linear or lagrange interpolation
scalar- output scaling value (optional)
outWindow- output windowing buffer (optional)
Returns
true if resampling was sucessful

◆ sgn()

double sgn ( double  xn)
inline

calculates sgn( ) of input

@sgn

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

◆ softClipWaveShaper()

double softClipWaveShaper ( double  xn,
double  saturation 
)
inline

calculates hyptan waveshaper

@softClipWaveShaper

Parameters
xn- the input value
saturation- the saturation control
Returns
the waveshaped output value

◆ tanhWaveShaper()

double tanhWaveShaper ( double  xn,
double  saturation 
)
inline

calculates hyptan waveshaper

@tanhWaveShaper

Parameters
xn- the input value
saturation- the saturation control
Returns
the waveshaped output value

◆ unipolarToBipolar()

double unipolarToBipolar ( double  value)
inline

calculates the bipolar [-1.0, +1.0] value FROM a unipolar [0.0, +1.0] value

@unipolarToBipolar

Parameters
value- value to convert
Returns
the bipolar value