Main namespace. More...
Namespaces | |
| namespace | arr |
| Array rank functions for numerical types. | |
| namespace | gen |
| Generator function objects. | |
| namespace | ipl |
| Interpolation functions. | |
| namespace | iplSeq |
| Sequence (stream-based) interpolation strategies. | |
| namespace | mem |
| Memory functions. | |
| namespace | rnd |
| Random number functions. | |
| namespace | scl |
| Scalar rank functions for numerical types. | |
| namespace | tap |
| Read tap strategies. | |
| namespace | tbl |
| Table functions. | |
Classes | |
| class | IndexMap |
| Maps a real number in [0, pmax) to an integer in [0, imax). More... | |
| class | Slice |
| Uniformly strided section of an array. More... | |
| class | AudioDevice |
| Audio device abstraction. More... | |
| class | AudioIOData |
| Audio data to be sent to callback. More... | |
| class | AudioIO |
| Audio input/output streaming. More... | |
| struct | SizeArrayPow2 |
| Size type for ArrayPow2. More... | |
| struct | SizeArray |
| Size type for Array. More... | |
| class | ArrayBase |
| Abstract base class for array types. More... | |
| class | Array |
| Resizable array. More... | |
| class | ArrayPow2 |
| Resizable array with a power-of-2 number of elements. More... | |
| class | Ring |
| Ring buffer. More... | |
| class | RingFill |
| Ring buffer that keeps track of its fill amount. More... | |
| class | DoubleRing |
| Double buffered ring-buffer. More... | |
| struct | DelayN |
| N-sample delay. More... | |
| class | Delay |
| Variable length delay-line. More... | |
| class | Delays |
| Variable delay-line with multiple read taps. More... | |
| class | DelayShift |
| Fixed-size shift delay. More... | |
| class | Delay1 |
| One element delay. More... | |
| class | Delay2 |
| Two element delay. More... | |
| class | Comb |
| Variable length delay-line with feedback and/or feedforward. More... | |
| class | SlidingWindow |
| Sliding window for analysis. More... | |
| class | DFTBase |
| Base class for DFTs. More... | |
| class | DFT |
| Discrete Fourier transform. More... | |
| class | STFT |
| Short-time Fourier transform. More... | |
| class | SDFT |
| Sliding discrete Fourier transform (SDFT) More... | |
| struct | AmpEnv |
| Amplitude envelope extractor. More... | |
| struct | Biquad3 |
| 3 biquad filters in parallel More... | |
| struct | Chirp |
| Sine wave with frequency and amplitude driven by an exponentially decaying envelope. More... | |
| struct | ChebyN |
| Nth order Chebyshev transfer function. More... | |
| struct | Chorus |
| Dual delay-line chorus driven by quadrature sinusoid. More... | |
| struct | FreqShift |
| Frequency shifter. More... | |
| class | Pan |
| Equal-power 2-channel panner. More... | |
| struct | Pluck |
| Plucked string source/filter. More... | |
| class | Quantizer |
| Quantizes sequence sampling and element magnitudes. More... | |
| struct | Threshold |
| Compares signal magnitude to a threshold. More... | |
| class | Curve |
| Exponential curve with variable curvature. More... | |
| class | Env |
| Envelope with a fixed number of exponential segments and a sustain point. More... | |
| class | AD |
| AD (Attack, Decay) envelope. More... | |
| class | ADSR |
| ADSR (Attack, Decay, Sustain, Release) envelope. More... | |
| class | Decay |
| Exponentially decaying curve. More... | |
| class | Gate |
| Binary gate controlled by threshold comparison. More... | |
| class | Seg |
| Interpolation envelope segment. More... | |
| class | SegExp |
| Exponential envelope segment for smoothing out value changes. More... | |
| class | CFFT |
| One-dimensional complex fast Fourier transform. More... | |
| class | RFFT |
| One-dimensional real-to-complex fast Fourier transform. More... | |
| class | AllPass1 |
| First-order all-pass filter. More... | |
| class | Biquad |
| 2-pole/2-zero IIR filter More... | |
| class | BlockDC |
| DC frequency blocker. More... | |
| class | BlockNyq |
| Nyquist frequency blocker. More... | |
| class | Filter2 |
| Abstract base class for 2-pole or 2-zero filter. More... | |
| class | AllPass2 |
| Second-order all-pass filter. More... | |
| class | Notch |
| Two-zero notch. More... | |
| class | Reson |
| Two-pole resonator. More... | |
| class | Hilbert |
| Hilbert transformer, converts real signal into complex. More... | |
| class | Integrator |
| Leaky integrator. More... | |
| class | MovingAvg |
| Moving average filter. More... | |
| class | OnePole |
| One-pole smoothing filter. More... | |
| class | Vowel |
| Formant data of vowel sounds. More... | |
| class | Node2 |
| Doubly-linked node. More... | |
| class | Node3 |
| Triply-linked node. More... | |
| class | Node4 |
| Quadruply-linked node. More... | |
| class | NoiseBrown |
| Brownian noise. More... | |
| class | NoisePink |
| Pink Noise. More... | |
| class | NoiseWhite |
| White noise. More... | |
| class | Accum |
| Fixed-point phase accumulator. More... | |
| class | Sweep |
| Linear sweep in interval [0,1) More... | |
| class | AccumPhase |
| Floating-point phase accumulator with output in [-pi, pi). More... | |
| class | Osc |
| Tabulated function oscillator. More... | |
| class | CSine |
| Complex sinusoid oscillator. More... | |
| class | Sine |
| Computed sine wave oscillator. More... | |
| class | SineR |
| Sine oscillator based on an efficient recursion equation. More... | |
| class | SineRs |
| Multiple SineRs. More... | |
| class | SineD |
| Damped sine oscillator based on an efficient recursion equation. More... | |
| class | SineDs |
| Multiple SineDs. More... | |
| class | TableSine |
| Lookup table sine oscillator. More... | |
| class | LFO |
| Low-frequency oscillator (non band-limited). More... | |
| class | Buzz |
| Base class for producing band-limited waveforms. More... | |
| struct | Impulse |
| Band-limited impulse train. More... | |
| struct | Saw |
| Band-limited saw wave. More... | |
| struct | Square |
| Band-limited square wave. More... | |
| class | DSF |
| Discrete summation formula (DSF) oscillator. More... | |
| class | Player |
| Sample buffer player. More... | |
| class | Recorder |
| Sound recorder. More... | |
| struct | RNGLinCon |
| Linear congruential uniform pseudo-random number generator. More... | |
| struct | RNGMulLinCon |
| Multiplicative linear congruential uniform pseudo-random number generator. More... | |
| class | RNGTaus |
| Combined Tausworthe uniform pseudo-random number generator. More... | |
| class | Func |
| Deferrable function. More... | |
| class | SoundFile |
| Class for reading and writing sound file data. More... | |
| class | Synced1 |
| Normalized unit synchronization observer. More... | |
| class | Synced |
| Unit synchronization observer. More... | |
| class | Sync |
| Unit synchronization subject. More... | |
| class | Timer |
| Timer. More... | |
| class | TransferFunc |
| Transfer function of an arbitrary difference equation. More... | |
| struct | Polar |
| Polar number with argument in radians. More... | |
| struct | Complex |
| Complex number. More... | |
| struct | Multi |
| Multi-element container. More... | |
| struct | ValPower |
| A value in the form: base^expo. More... | |
| class | Interval |
| A closed interval [min, max]. More... | |
| class | ValWrap |
| A value wrapped to an interval [min, max) More... | |
| struct | Vec |
| Fixed-size vector. More... | |
| class | FunctionTable |
| Maps value in unit interval to a tabulated function. More... | |
| class | UnitMapper |
| Maps a unit value through an invertible function. More... | |
Typedefs | |
| typedef void(* | audioCallback )(AudioIOData &io) |
| Audio callback type. | |
| typedef long long | nsec_t |
| nanoseconds type | |
Enumerations | |
| enum | SpectralType { COMPLEX, MAG_PHASE, MAG_FREQ } |
| Spectral data types. More... | |
| enum | FilterType { LOW_PASS, HIGH_PASS, BAND_PASS, BAND_PASS_UNIT, BAND_REJECT, ALL_PASS } |
| Filter types. More... | |
| enum | WindowType { BARTLETT, BLACKMAN, BLACKMAN_HARRIS, HAMMING, HANN, WELCH, NYQUIST, RECTANGLE } |
| Window types. More... | |
| enum | WaveformType { SINE, COSINE, TRIANGLE, PARABOLIC, SQUARE, SAW, IMPULSE } |
| Waveform types. More... | |
Functions | |
| uint32_t | bits (const char *string) |
| Convert a string of 1s and 0s to an integer. | |
| uint32_t | bitsToUInt (const char *bits) |
| Converts bit string to unsigned integer. | |
| uint32_t | floatToUInt (float v) |
| Cast float to unsigned int. | |
| int32_t | floatToInt (float v) |
| Cast float to int. | |
| float | split (float value, int32_t &intPart) |
| Get fractional and integer parts from a float. | |
| void | printHexArray (const float *table, uint32_t len, uint32_t valuesPerLine) |
| Prints array as hexidecimal values. | |
| void | printPlot (float value, uint32_t width=50, bool spaces=true, bool sign=true, const char *point="o") |
| Print signed unit value on a horizontal plot. | |
| void | err (const char *msg, const char *src="", bool exits=true) |
| Prints error messge to stderr and optionally calls exit() | |
| uint32_t | indexLast (uint32_t len, uint32_t str) |
| Returns last index of an arithmetic iteration starting from 0. | |
| index_t | posToInd (float v, index_t n) |
| Maps a position in [-1, 1] to an index in [0, n). No boundary operations are performed. | |
| template<class T > | |
| Slice< T > | slice (T *src, int32_t cnt, int32_t str=1, int32_t off=0) |
| Slice object function. | |
| void | blockSubnormal (float &v) |
| Sets argument to zero if subnormal. | |
| void | blockSubnormal (double &v) |
| Sets argument to zero if subnormal. | |
| int32_t | castIntRound (double v) |
| Cast value to signed integer using rounding. | |
| uint32_t | floatExponent (float v) |
| Returns biased decimal value of 32-bit float exponent field. | |
| float | floatMantissa (float v) |
| Returns mantissa field as float between [0, 1). | |
| float | fraction (uint32_t bits, uint32_t phase) |
| Converts linear integer phase to fraction. | |
| float | intToUnit (int16_t v) |
| Convert 16-bit signed integer to floating point in [-1, 1) | |
| float | punUF (uint32_t v) |
| Type-pun 32-bit unsigned int to 32-bit float. | |
| uint32_t | punFU (float v) |
| Type-pun 32-bit float to 32-bit unsigned int. | |
| uint32_t | unitToUInt (float u) |
| Convert floating point in [0, 1) to unsigned long in [0, 2^32) | |
| uint32_t | unitToUInt2 (float u) |
| Convert floating point in [0, 1) to unsigned long in [0, 2^32) | |
| uint8_t | unitToUInt8 (float u) |
| Convert unit float in [0,1) to 8-bit unsigned int in [0, 256). | |
| template<class T > | |
| T | poleRadius (T bw, double ups) |
| Returns pole radius given a bandwidth and sampling interval. | |
| template<class T > | |
| T | freqToRad (T freq, double ups) |
| Convert domain frequency to radians clipped to interval [0, pi). | |
| char | intensityToASCII (float v) |
| Returns an ASCII character most closely matching an intensity value in [0,1]. | |
| template<class T > | |
| void | print2D (T *pix, int nx, int ny, FILE *fp=stdout) |
| Prints 2D pixel array. | |
| template<class T > | |
| double | norm (const T &v) |
| Returns a positive length associated with argument. | |
| template<class T > | |
| double | normCompare (const T &v) |
| Returns a positive number valid for comparing norms. | |
| template<class T > | |
| void | addSine (T *dst, uint32_t len, double cycles=1, double amp=1, double phs=0) |
| Add sine wave to array. | |
| template<class T , class A > | |
| void | addSines (T *dst, uint32_t len, const A *amps, int numh, double hmul=1, double hshf=1, double hphs=0) |
| Add harmonic series to array with specified amplitudes. | |
| template<class T , class A , class C > | |
| void | addSines (T *dst, uint32_t len, const A *amps, const C *cycs, int numh, double hphs=0) |
| Add harmonics to array with specified amplitudes and harmonic numbers. | |
| template<int InvPower, class T > | |
| void | addSinesPow (T *dst, uint32_t len, int numh, double hmul=1, double hshf=1, double amp=1, double hphs=0, double wphs=0) |
| Add multiple sine waves to array. | |
| template<class T > | |
| void | addWave (T *dst, uint32_t len, gam::WaveformType type, int numh=32, double amp=1, double phs=0, double hshf=1) |
| Add predefined waveform to array. | |
| template<gam::WaveformType W> | |
| double | normConstant () |
| Get Fourier series normalization constant for a waveform. | |
| template<class T > | |
| Vec< 3, T > | cross (const Vec< 3, T > &a, const Vec< 3, T > &b) |
| Returns cross product, a x b. | |
| template<class T > | |
| Vec< 3, T > | productZXZ (const Complex< T > &a, const Complex< T > &b, const Complex< T > &c) |
| Returns spherical Euler product (ZXZ convention) | |
| template<int N, class T > | |
| Vec< N, T > | rotate (const Vec< N, T > &v, const Vec< N, T > &p, const Complex< T > &a) |
| Rotate vector towards perpendicular vector by angle using right-hand rule. | |
| template<class VecN , class T > | |
| void | rotatePlane (VecN &v1, VecN &v2, const Complex< T > &a) |
| Rotates two vectors by angle in plane formed from bivector v1 ^ v2. | |
Variables | |
| const int | endian = 0 |
| 0 if little-endian, 1 if big-endian. | |
Main namespace.
| enum FilterType |
| enum SpectralType |
Spectral data types.
| COMPLEX |
Complex number |
| MAG_PHASE |
Magnitude and phase |
| MAG_FREQ |
Magnitude and frequency |
| enum WaveformType |
| enum WindowType |
| void addSine | ( | T * | dst, |
| uint32_t | len, | ||
| double | cycles = 1, |
||
| double | amp = 1, |
||
| double | phs = 0 |
||
| ) |
Add sine wave to array.
| [out] | dst | destination array |
| [in] | len | length of array |
| [in] | cycles | number of cycles of sine wave, must be integer for periodic waves |
| [in] | amp | amplitude of sine wave |
| [in] | phs | phase of sine wave, in [0,1] |
| void gam::addSines | ( | T * | dst, |
| uint32_t | len, | ||
| const A * | amps, | ||
| int | numh, | ||
| double | hmul = 1, |
||
| double | hshf = 1, |
||
| double | hphs = 0 |
||
| ) |
Add harmonic series to array with specified amplitudes.
| [out] | dst | destination array |
| [in] | len | length of destination array |
| [in] | amps | amplitudes of harmonic series, size must be numh |
| [in] | numh | total number of harmonics |
| [in] | hmul | harmonic number multiplication factor |
| [in] | hshf | harmonic number shift amount |
| [in] | hphs | phase of sine wave, in [0,1] |
| void gam::addSines | ( | T * | dst, |
| uint32_t | len, | ||
| const A * | amps, | ||
| const C * | cycs, | ||
| int | numh, | ||
| double | hphs = 0 |
||
| ) |
Add harmonics to array with specified amplitudes and harmonic numbers.
| [out] | dst | destination array |
| [in] | len | length of destination array |
| [in] | amps | harmonic amplitudes of series, size must be numh |
| [in] | cycs | harmonic numbers of series, size must be numh |
| [in] | numh | total number of harmonics |
| [in] | hphs | phase of sine wave, in [0,1] |
| void addSinesPow | ( | T * | dst, |
| uint32_t | len, | ||
| int | numh, | ||
| double | hmul = 1, |
||
| double | hshf = 1, |
||
| double | amp = 1, |
||
| double | hphs = 0, |
||
| double | wphs = 0 |
||
| ) |
Add multiple sine waves to array.
| InvPower | amplitudes will be set to 1 / h^InvPower |
| [out] | dst | destination array |
| [in] | len | length of destination array |
| [in] | numh | total number of harmonics |
| [in] | hmul | harmonic number multiplication factor |
| [in] | hshf | harmonic number shift amount |
| [in] | amp | overall amplitude scaling factor |
| [in] | hphs | phase of (sine) harmonics, in [0,1] |
| [in] | wphs | phase of composite waveform, in [0,1] |
| void addWave | ( | T * | dst, |
| uint32_t | len, | ||
| gam::WaveformType | type, | ||
| int | numh = 32, |
||
| double | amp = 1, |
||
| double | phs = 0, |
||
| double | hshf = 1 |
||
| ) |
Add predefined waveform to array.
The produced waveforms are not normalized; the fundamental always has a unit amplitude.
| [out] | dst | destination array |
| [in] | len | length of destination array |
| [in] | type | waveform type |
| [in] | numh | total number of harmonics |
| [in] | amp | amplitude of waveform |
| [in] | phs | phase of waveform, in [0,1] |
| [in] | hshf | harmonic number shift amount |
| int32_t castIntRound | ( | double | v | ) |
Cast value to signed integer using rounding.
This is much faster than using a standard C style cast. Floor or ceiling casts can be accomplished by subtracting or adding 0.5 from the input, respectively.
| uint32_t floatExponent | ( | float | v | ) |
Returns biased decimal value of 32-bit float exponent field.
The true exponent is the return value minus 127. For example, values in [0.5, 1) return 126 (01111110), so the true exponent is 126 - 127 = -1.
| int32_t floatToInt | ( | float | v | ) |
Cast float to int.
Reliable up to 2^24 (16777216)
| uint32_t floatToUInt | ( | float | v | ) |
Cast float to unsigned int.
Reliable up to 2^24 (16777216)
| float fraction | ( | uint32_t | bits, |
| uint32_t | phase | ||
| ) |
Converts linear integer phase to fraction.
2^bits is the effective size of the lookup table.
Note: the fraction only has 24-bits of precision.
| void printPlot | ( | float | value, |
| uint32_t | width = 50, |
||
| bool | spaces = true, |
||
| bool | sign = true, |
||
| const char * | point = "o" |
||
| ) |
Print signed unit value on a horizontal plot.
| [in] | value | Normalized value to plot |
| [in] | width | Character width of plot excluding center point |
| [in] | spaces | Print extra filling spaces to the right |
| [in] | sign | Whether plot is signed |
| [in] | point | The print character for points |
| uint32_t gam::punFU | ( | float | v | ) |
Type-pun 32-bit float to 32-bit unsigned int.
This function uses a union to avoid problems with direct pointer casting when the fstrict-aliasing compiler flag is on.
| float gam::punUF | ( | uint32_t | v | ) |
Type-pun 32-bit unsigned int to 32-bit float.
This function uses a union to avoid problems with direct pointer casting when the fstrict-aliasing compiler flag is on.
| float split | ( | float | value, |
| int32_t & | intPart | ||
| ) |
Get fractional and integer parts from a float.
Works reliably up to 2^24 == 16777216 Useful for linearly interpolated table lookups
| uint32_t unitToUInt | ( | float | u | ) |
Convert floating point in [0, 1) to unsigned long in [0, 2^32)
This conversion is most accurate on an exponential scale. Input values outside [-1, 1) return 0. Values in [-1, 0] behave as positive values in [0, 1).
| uint32_t unitToUInt2 | ( | float | u | ) |
Convert floating point in [0, 1) to unsigned long in [0, 2^32)
This conversion is most accurate on a linear scale. Input values outside [0, 1) result in undefined behavior.