dplug.core.math

DSP utility functions.

Members

Functions

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.

convertMIDINoteToFrequency
float convertMIDINoteToFrequency(float note)

Mapping from MIDI notes to frequency.

convertNormalizedFreqyencyToFrequency
float convertNormalizedFreqyencyToFrequency(float frequencyCyclesPerSample, float samplingRate)

Computes a frequency.

deciBelToFloat
T deciBelToFloat(T dB)

Convert from dB to float.

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.

floatToDeciBel
T floatToDeciBel(T x)

Convert from float to dB

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]

nextPowerOf2
int nextPowerOf2(int i)

Computes next power of 2.

nextPowerOf2
long nextPowerOf2(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

Meta

Authors

Guillaume Piolat