dplug.core.math

DSP utility functions.

Members

Functions

convertDecibelToLinearGain
T convertDecibelToLinearGain(T dB)

Convert from dB to float. 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
T convertLinearGainToDecibel(T x)

Convert from float 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.

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]

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

Structs

Real80
struct Real80

Real80 is a scalar numerical type similar to real when using x86 DMD using FPU. This ensures 80-bit computation, when double isn't enough and real is a 64-bit floating-point number. This can happen in pole/zero computations for some IIR filters.

Meta