dplug.core.math

DSP utility functions.

Members

Aliases

fast_ceil
alias fast_ceil = llvm_ceil
Undocumented in source.
fast_ceil
alias fast_ceil = ceil
Undocumented in source.
fast_cos
alias fast_cos = llvm_cos
Undocumented in source.
fast_cos
alias fast_cos = cos
Undocumented in source.
fast_exp
alias fast_exp = llvm_exp
Undocumented in source.
fast_exp
alias fast_exp = exp
Undocumented in source.
fast_exp2
alias fast_exp2 = llvm_exp2
Undocumented in source.
fast_exp2
alias fast_exp2 = exp2
Undocumented in source.
fast_fabs
alias fast_fabs = llvm_fabs
Undocumented in source.
fast_fabs
alias fast_fabs = fabs
Undocumented in source.
fast_floor
alias fast_floor = llvm_floor
Undocumented in source.
fast_floor
alias fast_floor = floor
Undocumented in source.
fast_log
alias fast_log = llvm_log
Undocumented in source.
fast_log
alias fast_log = log
Undocumented in source.
fast_log10
alias fast_log10 = llvm_log10
Undocumented in source.
fast_log10
alias fast_log10 = log10
Undocumented in source.
fast_log2
alias fast_log2 = llvm_log2
Undocumented in source.
fast_log2
alias fast_log2 = log2
Undocumented in source.
fast_pow
alias fast_pow = llvm_pow
Undocumented in source.
fast_pow
alias fast_pow = pow
Undocumented in source.
fast_round
alias fast_round = llvm_round
Undocumented in source.
fast_round
alias fast_round = round
Undocumented in source.
fast_sin
alias fast_sin = llvm_sin
Undocumented in source.
fast_sin
alias fast_sin = sin
Undocumented in source.
fast_sqrt
alias fast_sqrt = llvm_sqrt
Undocumented in source.
fast_sqrt
alias fast_sqrt = sqrt
Undocumented in source.
fast_trunc
alias fast_trunc = llvm_trunc
Undocumented in source.
fast_trunc
alias fast_trunc = trunc
Undocumented in source.

Functions

computeRMS
T computeRMS(T[] samples)
Undocumented in source. Be warned that the author may not have intended to support it.
convertDecibelToLinearGain
float convertDecibelToLinearGain(float dB)
double convertDecibelToLinearGain(double dB)

Converts from dB to linear gain. Precision: This uses fast_exp which under normal conditions has a peak error under -135dB over the useful range.

convertFrequencyToMIDINote
float convertFrequencyToMIDINote(float frequency)

Mapping from frequency to MIDI notes.

convertFrequencyToNormalizedFrequency
float convertFrequencyToNormalizedFrequency(float frequencyHz, float samplingRate)

Computes a normalized frequency form a frequency.

convertLinearGainToDecibel
float convertLinearGainToDecibel(float x)
double convertLinearGainToDecibel(double x)

Converts from linear gain to dB. Precision: This uses fast_exp which under normal conditions has a peak error under -135dB over the useful range.

convertMIDINoteToFrequency
float convertMIDINoteToFrequency(float note)

Mapping from MIDI notes to frequency.

convertNormalizedFrequencyToFrequency
float convertNormalizedFrequencyToFrequency(float frequencyCyclesPerSample, float samplingRate)

Computes a frequency.

convertPowerToDecibel
float convertPowerToDecibel(float x)
double convertPowerToDecibel(double x)

Converts from power to dB. Instantaneous power is the squared amplitude of a signal, and can be a nice domain to work in at times. Precision: This uses fast_exp which under normal conditions has a peak error under -135dB over the useful range.

equalLoudnessCurve
T equalLoudnessCurve(T frequency)

Fletcher and Munson equal-loudness curve Reference: Xavier Serra thesis (1989).

expDecayFactor
double expDecayFactor(double timeConstantInSeconds, double samplerate)

Gets a factor for making exponential decay curves, which are the same thing as a 6dB/oct lowpass filter.

hermite
T hermite(T frac_pos, T xm1, T x0, T x1, T x2)

Hermite interpolation.

iFloorLog2
int iFloorLog2(int i)
inverseSqrt
T inverseSqrt(T x)

SSE approximation of reciprocal square root.

isEven
bool isEven(T i)

Is this integer even?

isOdd
bool isOdd(T i)

Is this integer odd?

isPowerOfTwo
bool isPowerOfTwo(int i)
lerp
S lerp(S a, S b, T t)

Linear interpolation, akin to GLSL's mix.

linmap
T linmap(T value, T a, T b, T c, T d)

Map linearly x from the range [a, b] to the range [c, d]

logmap
T logmap(T t, T min, T max)

map [0..1] to min..max logarithmically min and max must be all > 0, t in [0..1] Note: you can totally have a max that is smaller than min. In this cases, the range mapped with more accuracy are still small values.

nextMultipleOf
size_t nextMultipleOf(size_t n, size_t powerOfTwo)
nextPow2HigherOrEqual
int nextPow2HigherOrEqual(int i)
long nextPow2HigherOrEqual(long i)

Computes next power of 2.

normalizePhase
T normalizePhase(T phase)

Give back a phase between -PI and PI

rawSawtooth
T rawSawtooth(T x)

Quick and dirty sawtooth for testing purposes.

rawSquare
T rawSquare(T x)

Quick and dirty square for testing purposes.

rawTriangle
T rawTriangle(T x)

Quick and dirty triangle for testing purposes.

sinc
T sinc(T x)

Cardinal sine

smoothStep
T smoothStep(T a, T b, T t)

Same as GLSL smoothstep function. See: http://en.wikipedia.org/wiki/Smoothstep

Variables

TAU
real TAU;
Undocumented in source.

Meta