ASPiK SDK
Loading...
Searching...
No Matches
fxobjects.h File Reference

a collection of 54 objects and support structures, functions and enuemrations for all projects documented in: More...

#include <memory>
#include <algorithm>
#include <math.h>
#include "guiconstants.h"
#include "filters.h"
#include <time.h>
#include "fftw3.h"

Go to the source code of this file.

Classes

struct  ComplexNumber
 Structure to hold a complex value. More...
 
struct  BrickwallMagData
 Custom structure that holds magnitude information about a brickwall filter. More...
 
struct  TransitionBandData
 Custom structure that holds transition band information for FIR filter calculations. More...
 
struct  AnalogMagData
 Custom parameter structure calculating analog magnitude response arrays with calculateAnalogMagArray( ). More...
 
class  IAudioSignalProcessor
 Use this interface for objects that process audio input samples to produce audio output samples. A derived class must implement the three abstract methods. The others are optional. More...
 
struct  SignalGenData
 This is the output structure for audio generator objects that can render up to four outputs. More...
 
class  IAudioSignalGenerator
 Use this interface for objects that render an output without an input, such as oscillators. May also be used for envelope generators whose input is a note-on or other switchable event. More...
 
struct  BiquadParameters
 Custom parameter structure for the Biquad object. Default version defines the biquad structure used in the calculation. More...
 
class  Biquad
 The Biquad object implements a first or second order H(z) transfer function using one of four standard structures: Direct, Canonical, Transpose Direct, Transpose Canonical. More...
 
struct  AudioFilterParameters
 Custom parameter structure for the AudioFilter object. More...
 
class  AudioFilter
 The AudioFilter object implements all filters in Designing Audio Effects Plugins in C++ 2nd Ed. by Will Pirkle. More...
 
struct  FilterBankOutput
 Custom output structure for filter bank objects that split the inptu into multiple frequency channels (bands) More...
 
struct  LRFilterBankParameters
 Custom parameter structure for the LRFilterBank object which splits the input signal into multiple bands. The stock obejct splits into low and high frequency bands so this structure only requires one split point - add more split frequencies to support more bands. More...
 
class  LRFilterBank
 The LRFilterBank object implements 2 Linkwitz-Riley Filters in a parallel filter bank to split the signal into two frequency bands. Note that one channel is inverted (see the FX book below for explanation). You can add more bands here as well. More...
 
struct  AudioDetectorParameters
 Custom parameter structure for the AudioDetector object. NOTE: this object uses constant defintions: More...
 
class  AudioDetector
 The AudioDetector object implements the audio detector defined in the book source below. NOTE: this detector can receive signals and transmit detection values that are both > 0dBFS. More...
 
struct  DynamicsProcessorParameters
 Custom parameter structure for the DynamicsProcessor object. Ths struct includes all information needed from GUI controls. More...
 
class  DynamicsProcessor
 The DynamicsProcessor object implements a dynamics processor suite: compressor, limiter, downward expander, gate. More...
 
class  LinearBuffer< T >
 The LinearBuffer object implements a linear buffer of type T. It allows easy wrapping of a smart pointer object. More...
 
class  CircularBuffer< T >
 The CircularBuffer object implements a simple circular buffer. It uses a wrap mask to wrap the read or write index quickly. More...
 
class  ImpulseConvolver
 The ImpulseConvolver object implements a linear conovlver. NOTE: compile in Release mode or you may experice stuttering, glitching or other sample-drop activity. More...
 
struct  AnalogFIRFilterParameters
 Custom parameter structure for the AnalogFIRFilter object. This is a somewhat silly object that implaments an analog magnitude response as a FIR filter. NOT DESIGNED to replace virtual analog; rather it is intended to show the frequency sampling method in an easy (and fun) way. More...
 
class  AnalogFIRFilter
 The AnalogFIRFilter object implements a somewhat silly algorithm that implaments an analog magnitude response as a FIR filter. NOT DESIGNED to replace virtual analog; rather it is intended to show the frequency sampling method in an easy (and fun) way. More...
 
struct  AudioDelayParameters
 Custom parameter structure for the AudioDelay object. More...
 
class  AudioDelay
 The AudioDelay object implements a stereo audio delay with multiple delay algorithms. More...
 
struct  OscillatorParameters
 Custom parameter structure for the LFO and DFOscillator objects. More...
 
class  LFO
 The LFO object implements a mathematically perfect LFO generator for modulation uses only. It should not be used for audio frequencies except for the sinusoidal output which, though an approximation, has very low TDH. More...
 
class  DFOscillator
 The DFOscillator object implements generates a very pure sinusoidal oscillator by placing poles direclty on the unit circle. Accuracy is excellent even at low frequencies. More...
 
struct  ModulatedDelayParameters
 Custom parameter structure for the ModulatedDelay object. More...
 
class  ModulatedDelay
 The ModulatedDelay object implements the three basic algorithms: flanger, chorus, vibrato. More...
 
struct  PhaseShifterParameters
 Custom parameter structure for the PhaseShifter object. More...
 
class  PhaseShifter
 The PhaseShifter object implements a six-stage phaser. More...
 
struct  SimpleLPFParameters
 Custom parameter structure for the SimpleLPFP object. Used for reverb algorithms in book. More...
 
class  SimpleLPF
 The SimpleLPF object implements a first order one-pole LPF using one coefficient "g" value. More...
 
struct  SimpleDelayParameters
 Custom parameter structure for the SimpleDelay object. Used for reverb algorithms in book. More...
 
class  SimpleDelay
 The SimpleDelay object implements a basic delay line without feedback. More...
 
struct  CombFilterParameters
 Custom parameter structure for the CombFilter object. Used for reverb algorithms in book. More...
 
class  CombFilter
 The CombFilter object implements a comb filter with optional LPF in feedback loop. Used for reverb algorithms in book. More...
 
struct  DelayAPFParameters
 Custom parameter structure for the DelayAPF object. Used for reverb algorithms in book. More...
 
class  DelayAPF
 The DelayAPF object implements a delaying APF with optional LPF and optional modulated delay time with LFO. More...
 
struct  NestedDelayAPFParameters
 Custom parameter structure for the NestedDelayAPF object. Used for reverb algorithms in book. More...
 
class  NestedDelayAPF
 The NestedDelayAPF object implements a pair of nested Delaying APF structures. These are labled the outer and inner APFs. The outer APF's LPF and LFO may be optionally enabled. You might want to extend this object to enable and use the inner LPF and LFO as well. More...
 
struct  TwoBandShelvingFilterParameters
 Custom parameter structure for the TwoBandShelvingFilter object. Used for reverb algorithms in book. More...
 
class  TwoBandShelvingFilter
 The TwoBandShelvingFilter object implements two shelving filters in series in the standard "Bass and Treble" configuration. More...
 
struct  ReverbTankParameters
 Custom parameter structure for the ReverbTank object. More...
 
class  ReverbTank
 The ReverbTank object implements the cyclic reverb tank in the FX book listed below. More...
 
class  PeakLimiter
 The PeakLimiter object implements a simple peak limiter; it is really a simplified and hard-wired versio of the DynamicsProcessor. More...
 
struct  ZVAFilterParameters
 Custom parameter structure for the ZVAFilter object. More...
 
class  ZVAFilter
 The ZVAFilter object implements multpile Zavalishin VA Filters. Audio I/O: More...
 
struct  EnvelopeFollowerParameters
 Custom parameter structure for the EnvelopeFollower object. More...
 
class  EnvelopeFollower
 The EnvelopeFollower object implements a traditional envelope follower effect modulating a LPR fc value using the strength of the detected input. More...
 
struct  TriodeClassAParameters
 Custom parameter structure for the TriodeClassA object. More...
 
class  TriodeClassA
 The TriodeClassA object simulates a triode in class A configuration. This is a very simple and basic simulation and a starting point for other designs; it is not intended to be a full-fledged triode simulator. More...
 
struct  ClassATubePreParameters
 Custom parameter structure for the ClassATubePre object. More...
 
class  ClassATubePre
 The ClassATubePre object implements a simple cascade of four (4) triode tube models. More...
 
struct  BitCrusherParameters
 Custom parameter structure for the BitCrusher object. More...
 
class  BitCrusher
 The BitCrusher object implements a quantizing bitcrusher algorithm. More...
 
class  IComponentAdaptor
 Use this interface for objects in the WDF Ladder Filter library; see book for more information. More...
 
class  WdfResistor
 The WdfResistor object implements the reflection coefficient and signal flow through a WDF simulated resistor. More...
 
class  WdfCapacitor
 The WdfCapacitor object implements the reflection coefficient and signal flow through a WDF simulated capacitor. More...
 
class  WdfInductor
 The WdfInductor object implements the reflection coefficient and signal flow through a WDF simulated inductor. More...
 
class  WdfSeriesLC
 The WdfSeriesLC object implements the reflection coefficient and signal flow through a WDF simulated series LC pair. More...
 
class  WdfParallelLC
 The WdfParallelLC object implements the reflection coefficient and signal flow through a WDF simulated parallel LC pair. More...
 
class  WdfSeriesRL
 The WdfSeriesRL object implements the reflection coefficient and signal flow through a WDF simulated series RL pair. More...
 
class  WdfParallelRL
 The WdfParallelRL object implements the reflection coefficient and signal flow through a WDF simulated parallel RL pair. More...
 
class  WdfSeriesRC
 The WdfSeriesRC object implements the reflection coefficient and signal flow through a WDF simulated series RC pair. More...
 
class  WdfParallelRC
 The WdfParallelRC object implements the reflection coefficient and signal flow through a WDF simulated parallal RC pair. More...
 
struct  WdfComponentInfo
 Custom structure to hold component information. More...
 
class  WdfAdaptorBase
 The WdfAdaptorBase object acts as the base class for all WDF Adaptors; the static members allow for simplified connection of components. See the FX book for more details. More...
 
class  WdfSeriesAdaptor
 The WdfSeriesAdaptor object implements the series reflection-free (non-terminated) adaptor. More...
 
class  WdfSeriesTerminatedAdaptor
 The WdfSeriesTerminatedAdaptor object implements the series terminated (non-reflection-free) adaptor. More...
 
class  WdfParallelAdaptor
 The WdfParallelAdaptor object implements the parallel reflection-free (non-terminated) adaptor. More...
 
class  WdfParallelTerminatedAdaptor
 The WdfParallelTerminatedAdaptor object implements the parallel terminated (non-reflection-free) adaptor. More...
 
class  WDFButterLPF3
 The WDFButterLPF3 object implements a 3rd order Butterworth ladder filter. NOTE: designed with Elsie www.TonneSoftware.comm. More...
 
class  WDFTunableButterLPF3
 The WDFTunableButterLPF3 object implements a tunable 3rd order Butterworth ladder filter. NOTE: designed with Elsie www.TonneSoftware.comm. More...
 
class  WDFBesselBSF3
 The WDFBesselBSF3 object implements a 3rd order Bessel BSF NOTE: designed with Elsie www.TonneSoftware.comm. More...
 
class  WDFConstKBPF6
 The WDFConstKBPF6 object implements a 6th order constant K BPF NOTE: designed with Elsie www.TonneSoftware.comm. More...
 
struct  WDFParameters
 Custom parameter structure for the WDF filter examples. More...
 
class  WDFIdealRLCLPF
 The WDFIdealRLCLPF object implements an ideal RLC LPF using the WDF library. More...
 
class  WDFIdealRLCHPF
 The WDFIdealRLCHPF object implements an ideal RLC HPF using the WDF library. More...
 
class  WDFIdealRLCBPF
 The WDFIdealRLCBPF object implements an ideal RLC BPF using the WDF library. More...
 
class  WDFIdealRLCBSF
 The WDFIdealRLCBSF object implements an ideal RLC BSF using the WDF library. More...
 
class  FastFFT
 The FastFFT provides a simple wrapper for the FFTW FFT operation - it is ultra-thin and simple to use. More...
 
class  PhaseVocoder
 The PhaseVocoder provides a basic phase vocoder that is initialized to N = 4096 and 75% overlap; the de-facto standard for PSM algorithms. The analysis and sythesis hop sizes are identical. More...
 
class  FastConvolver
 The FastConvolver provides a fast convolver - the user supplies the filter IR and the object snapshots the FFT of that filter IR. Input audio is fast-convovled with the filter FFT using complex multiplication and zero-padding. More...
 
struct  BinData
 Custom structure that holds information about each FFT bin. This includes all information needed to perform pitch shifting and time stretching with phase locking (optional) and peak tracking (optional). More...
 
struct  PSMVocoderParameters
 Custom parameter structure for the Biquad object. Default version defines the biquad structure used in the calculation. More...
 
class  PSMVocoder
 The PSMVocoder object implements a phase vocoder pitch shifter. Phase locking and peak tracking are optional. More...
 
struct  InterpolatorOutput
 Custom output structure for interpolator; it holds an arry of interpolated output samples. More...
 
class  Interpolator
 The Interpolator object implements a sample rate interpolator. One input sample yields N output samples. More...
 
struct  DecimatorInput
 Custom input structure for DecimatorInput; it holds an arry of input samples that will be decimated down to just one sample. More...
 
class  Decimator
 The Decimator object implements a sample rate decimator. Ana array of M input samples is decimated to one output sample. More...
 

Macros

#define HAVE_FFTW   1
 
#define NEGATIVE   0
 
#define POSITIVE   1
 

Enumerations

enum class  brickwallFilter { kBrickLPF , kBrickHPF , kBrickBPF , kBrickBSF }
 Use this strongly typed enum to easily set brickwall filter type for functions that need it. More...
 
enum class  edgeTransition { kFallingEdge , kRisingEdge }
 Use this strongly typed enum to easily set the edge direction (rising or falling) of a transition band. More...
 
enum class  analogFilter {
  kLPF1 , kHPF1 , kLPF2 , kHPF2 ,
  kBPF2 , kBSF2
}
 Use this strongy typed enum to set the analog filter type for the AnalogMagData structure. More...
 
enum class  interpolation { kLinear , kLagrange4 }
 
enum  filterCoeff {
  a0 , a1 , a2 , b1 ,
  b2 , c0 , d0 , numCoeffs
}
 Use this enum to easily access coefficents inside of arrays. More...
 
enum  stateReg {
  x_z1 , x_z2 , y_z1 , y_z2 ,
  numStates
}
 Use this enum to easily access z^-1 state values inside of arrays. For some structures, fewer storage units are needed. They are divided as follows: More...
 
enum class  biquadAlgorithm { kDirect , kCanonical , kTransposeDirect , kTransposeCanonical }
 Use this strongly typed enum to easily set the biquad calculation type. More...
 
enum class  filterAlgorithm {
  kLPF1P , kLPF1 , kHPF1 , kLPF2 ,
  kHPF2 , kBPF2 , kBSF2 , kButterLPF2 ,
  kButterHPF2 , kButterBPF2 , kButterBSF2 , kMMALPF2 ,
  kMMALPF2B , kLowShelf , kHiShelf , kNCQParaEQ ,
  kCQParaEQ , kLWRLPF2 , kLWRHPF2 , kAPF1 ,
  kAPF2 , kResonA , kResonB , kMatchLP2A ,
  kMatchLP2B , kMatchBP2A , kMatchBP2B , kImpInvLP1 ,
  kImpInvLP2
}
 Use this strongly typed enum to easily set the filter algorithm for the AudioFilter object or any other object that requires filter definitions. More...
 
enum class  dynamicsProcessorType { kCompressor , kDownwardExpander }
 Use this strongly typed enum to set the dynamics processor type. More...
 
enum class  delayAlgorithm { kNormal , kPingPong }
 Use this strongly typed enum to easily set the delay algorithm. More...
 
enum class  delayUpdateType { kLeftAndRight , kLeftPlusRatio }
 Use this strongly typed enum to easily set the delay update type; this varies depending on the designer's choice of GUI controls. See the book reference for more details. More...
 
enum class  generatorWaveform { kTriangle , kSin , kSaw }
 Use this strongly typed enum to easily set the oscillator waveform. More...
 
enum  DFOscillatorCoeffs { df_b1 , df_b2 , numDFOCoeffs }
 Use this non-typed enum to easily access the direct form oscillator coefficients. More...
 
enum  DFOscillatorStates { df_yz1 , df_yz2 , numDFOStates }
 Use this non-typed enum to easily access the direct form oscillator state registers. More...
 
enum class  modDelaylgorithm { kFlanger , kChorus , kVibrato }
 Use this strongly typed enum to easily set modulated delay algorithm. More...
 
enum class  reverbDensity { kThick , kSparse }
 Use this strongly typed enum to easily set the density in the reverb object. More...
 
enum class  vaFilterAlgorithm {
  kLPF1 , kHPF1 , kAPF1 , kSVF_LP ,
  kSVF_HP , kSVF_BP , kSVF_BS
}
 Use this strongly typed enum to easily set the virtual analog filter algorithm. More...
 
enum class  distortionModel { kSoftClip , kArcTan , kFuzzAsym }
 Use this strongly typed enum to easily set the waveshaper model for the Triode objects. More...
 
enum class  wdfComponent {
  R , L , C , seriesLC ,
  parallelLC , seriesRL , parallelRL , seriesRC ,
  parallelRC
}
 Use this strongly typed enum to easily set the wdfComponent type. More...
 
enum class  windowType {
  kNoWindow , kRectWindow , kHannWindow , kBlackmanHarrisWindow ,
  kHammingWindow
}
 Use this strongly typed enum to easily set the windowing type for FFT algorithms that use it. More...
 
enum class  rateConversionRatio { k2x , k4x }
 Use this strongly typed enum to easily set up or down sampling ratios. 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
 

Variables

const double kSmallestPositiveFloatValue = 1.175494351e-38
 
const double kSmallestNegativeFloatValue = -1.175494351e-38
 
const double kSqrtTwo = pow(2.0, 0.5)
 
const double kMinFilterFrequency = 20.0
 
const double kMaxFilterFrequency = 20480.0
 
const double ARC4RANDOMMAX = 4294967295.0
 
const unsigned int TLD_AUDIO_DETECT_MODE_PEAK = 0
 
const unsigned int TLD_AUDIO_DETECT_MODE_MS = 1
 
const unsigned int TLD_AUDIO_DETECT_MODE_RMS = 2
 
const double TLD_AUDIO_ENVELOPE_ANALOG_TC = -0.99967234081320612357829304641019
 
const unsigned int IR_LEN = 512
 
const unsigned int PHASER_STAGES = 6
 
const double apf0_minF = 32.0
 
const double apf0_maxF = 1500.0
 
const double apf1_minF = 68.0
 
const double apf1_maxF = 3400.0
 
const double apf2_minF = 96.0
 
const double apf2_maxF = 4800.0
 
const double apf3_minF = 212.0
 
const double apf3_maxF = 10000.0
 
const double apf4_minF = 320.0
 
const double apf4_maxF = 16000.0
 
const double apf5_minF = 636.0
 
const double apf5_maxF = 20480.0
 
const unsigned int NUM_BRANCHES = 4
 
const unsigned int NUM_CHANNELS = 2
 
const unsigned int NUM_TUBES = 4
 
const unsigned int PSM_FFT_LEN = 4096
 
const unsigned int maxSamplingRatio = 4
 

Detailed Description

a collection of 54 objects and support structures, functions and enuemrations for all projects documented in:

FX Objects File.

Author
Will Pirkle
Date
20-May-2020