LMMS
Loading...
Searching...
No Matches
primitives.h File Reference
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <map>
#include <algorithm>

Go to the source code of this file.

Classes

struct  dsp::stereo_sample< T >
class  dsp::decay
class  dsp::sine_table< T, N, Multiplier >
struct  dsp::note_desc

Namespaces

namespace  dsp

Macros

#define M_PI   3.14159265358979323846264338327

Enumerations

enum  dsp::periodic_unit { dsp::UNIT_BPM , dsp::UNIT_MS , dsp::UNIT_HZ , dsp::UNIT_SYNC }

Functions

void dsp::zero (float &v)
 Set a float to zero.
void dsp::zero (double &v)
 Set a double to zero.
void dsp::zero (uint64_t &v)
 Set 64-bit unsigned integer value to zero.
void dsp::zero (uint32_t &v)
 Set 32-bit unsigned integer value to zero.
void dsp::zero (uint16_t &v)
 Set 16-bit unsigned integer value to zero.
void dsp::zero (uint8_t &v)
 Set 8-bit unsigned integer value to zero.
void dsp::zero (int64_t &v)
 Set 64-bit signed integer value to zero.
void dsp::zero (int32_t &v)
 Set 32-bit signed integer value to zero.
void dsp::zero (int16_t &v)
 Set 16-bit signed integer value to zero.
void dsp::zero (int8_t &v)
 Set 8-bit signed integer value to zero.
template<class T>
void dsp::zero (T *data, unsigned int size)
 Set array (buffer or anything similar) to vector of zeroes.
template<class T>
void dsp::fill (T *data, T value, unsigned int size)
 Set array (buffer or anything similar) to vector of values.
template<class T>
stereo_sample< T > dsp::operator* (const T &value, const stereo_sample< T > &value2)
 Multiply constant by stereo_value.
template<class T>
stereo_sample< T > dsp::operator+ (const T &value, const stereo_sample< T > &value2)
 Add constant to stereo_value.
template<class T>
stereo_sample< T > dsp::operator- (const T &value, const stereo_sample< T > &value2)
 Subtract stereo_value from constant (yields stereo_value of course).
template<typename T>
stereo_sample< T > dsp::shr (stereo_sample< T > v, int bits=1)
 Shift value right by 'bits' bits (multiply by 2^-bits).
template<typename T>
void dsp::zero (stereo_sample< T > &v)
 Set a stereo_sample<T> value to zero.
template<typename T>
dsp::small_value ()
 'Small value' for integer and other types
template<>
float dsp::small_value< float > ()
 'Small value' for floats (2^-24) - used for primitive underrun prevention. The value is pretty much arbitrary (allowing for 24-bit signals normalized to 1.0).
template<>
double dsp::small_value< double > ()
 'Small value' for doubles (2^-24) - used for primitive underrun prevention. The value is pretty much arbitrary.
template<typename T>
float dsp::mono (T v)
 Convert a single value to single value = do nothing :) (but it's a generic with specialisation for stereo_sample).
template<typename T>
dsp::mono (stereo_sample< T > v)
 Convert a stereo_sample to single value by averaging two channels.
template<typename T>
dsp::clip (T value, T min, T max)
 Clip a value to [min, max].
double dsp::clip11 (double value)
 Clip a double to [-1.0, +1.0].
float dsp::clip11 (float value)
 Clip a float to [-1.0f, +1.0f].
double dsp::clip01 (double value)
 Clip a double to [0.0, +1.0].
float dsp::clip01 (float value)
 Clip a float to [0.0f, +1.0f].
template<typename T, typename U>
dsp::lerp (T v1, T v2, U mix)
template<typename T>
stereo_sample< T > dsp::lerp (stereo_sample< T > &v1, stereo_sample< T > &v2, float mix)
void dsp::sanitize (float &value)
float dsp::_sanitize (float value)
void dsp::sanitize_denormal (float &value)
void dsp::sanitize_denormal (double &value)
void dsp::sanitize (double &value)
double dsp::_sanitize (double value)
template<class T>
void dsp::sanitize (stereo_sample< T > &value)
float dsp::fract16 (unsigned int value)
int dsp::fastf2i_drm (float f)
 fast float to int conversion using default rounding mode
float dsp::note_to_hz (double note, double detune_cents=0.0)
 Convert MIDI note to frequency in Hz.
float dsp::normalized_hermite (float t, float p0, float p1, float m0, float m1)
float dsp::hermite_interpolation (float x, float x0, float x1, float p0, float p1, float m0, float m1)
float dsp::amp2dB (float amp)
 convert amplitude value to dB
float dsp::dB2amp (float db)
 convert dB to amplitude value
void dsp::print_bits (size_t const size, void const *const ptr)
note_desc dsp::hz_to_note (double hz, double tune)
double dsp::convert_periodic (double val, periodic_unit unit_in, periodic_unit unit_out)

Variables

template<class T, int N, int Multiplier>
bool dsp::sine_table< T, N, Multiplier >::initialized = false
template<class T, int N, int Multiplier>
dsp::sine_table< T, N, Multiplier >::data [N+1]

Macro Definition Documentation

◆ M_PI

#define M_PI   3.14159265358979323846264338327