Vital
|
A collection of inline helper functions and constants used for SIMD computations, interpolation, and other audio-related utilities. More...
Classes | |
union | int_float |
A small union to reinterpret an int as a float or vice versa. More... | |
class | RandomGenerator |
A basic random number generator for producing uniform distributions of floats. More... | |
Functions | |
force_inline poly_float | mulAdd (poly_float a, poly_float b, poly_float c) |
Performs a fused multiply-add on SIMD data: (a * b) + c. | |
force_inline poly_float | mulSub (poly_float a, poly_float b, poly_float c) |
Performs a fused multiply-sub on SIMD data: (a * b) - c. | |
template<mono_float(*)(mono_float) func> | |
force_inline poly_float | map (poly_float value) |
Applies a scalar function to each element in a poly_float . | |
force_inline poly_float | centsToRatio (poly_float value) |
Converts semitone cents to a linear frequency ratio (vectorized). | |
force_inline poly_float | noteOffsetToRatio (poly_float value) |
Converts note offsets to frequency ratios. Similar to centsToRatio , but may differ in how offset is defined. | |
force_inline poly_float | ratioToMidiTranspose (poly_float value) |
Converts a ratio to MIDI transpose (vectorized). | |
force_inline poly_float | midiCentsToFrequency (poly_float value) |
Converts MIDI cents to frequency (vectorized). | |
force_inline poly_float | midiNoteToFrequency (poly_float value) |
Converts a MIDI note to a frequency (vectorized). | |
force_inline poly_float | frequencyToMidiNote (poly_float value) |
Converts a frequency to a MIDI note (vectorized). | |
force_inline poly_float | frequencyToMidiCents (poly_float value) |
Converts a frequency to MIDI cents (vectorized). | |
force_inline poly_float | magnitudeToDb (poly_float value) |
Converts a magnitude value to decibels (vectorized). | |
force_inline poly_float | dbToMagnitude (poly_float value) |
Converts a dB value to linear magnitude (vectorized). | |
force_inline poly_float | tan (poly_float value) |
Computes the tangent of each element (in radians) in a poly_float . | |
force_inline poly_float | sin (poly_float value) |
Computes the sine of each element (in radians). | |
force_inline poly_float | cos (poly_float value) |
Computes the cosine of each element (in radians). | |
force_inline poly_float | sqrt (poly_float value) |
Computes the square root of each element in a poly_float . | |
force_inline poly_float | interpolate (poly_float from, poly_float to, mono_float t) |
Performs a linear interpolation between two poly_float s using a scalar t in [0..1]. | |
force_inline poly_float | getCubicInterpolationValues (mono_float mono_t) |
Returns the cubic Lagrange interpolation constants for a scalar mono_t . | |
force_inline poly_float | getOptimalInterpolationValues (mono_float mono_t) |
Returns an "optimal" polynomial interpolation for a scalar mono_t . | |
force_inline matrix | getPolynomialInterpolationMatrix (poly_float t_from) |
Creates a matrix for polynomial interpolation given a starting poly_float t_from. | |
force_inline matrix | getCatmullInterpolationMatrix (poly_float t) |
Creates a Catmull-Rom interpolation matrix from a poly_float t. | |
force_inline matrix | getLinearInterpolationMatrix (poly_float t) |
Creates a matrix for simple linear interpolation using scalar or vector t . | |
force_inline poly_float | toPolyFloatFromUnaligned (const mono_float *unaligned) |
Loads a poly_float from an unaligned float pointer. | |
force_inline matrix | getValueMatrix (const mono_float *buffer, poly_int indices) |
Creates a matrix of 4 poly_float lanes from a single buffer at varying indices. | |
force_inline matrix | getValueMatrix (const mono_float *const *buffers, poly_int indices) |
Creates a matrix of 4 poly_float lanes from 4 separate buffers at varying indices. | |
force_inline poly_float | interpolate (poly_float from, poly_float to, poly_float t) |
Interpolates between two SIMD values with a SIMD fraction t. | |
force_inline poly_float | interpolate (mono_float from, mono_float to, poly_float t) |
Interpolates between two scalars with a SIMD fraction t. | |
force_inline poly_float | perlinInterpolate (poly_float from, poly_float to, poly_float t) |
A specialized interpolation function used in perlin-like routines. | |
force_inline poly_float | clamp (poly_float value, mono_float min, mono_float max) |
Clamps each lane of a vector to [min, max]. | |
force_inline poly_float | clamp (poly_float value, poly_float min, poly_float max) |
Clamps each lane of a vector to [min, max], where min and max are themselves poly_float s. | |
force_inline poly_int | clamp (poly_int value, poly_int min, poly_int max) |
Clamps a poly_int to [min, max]. | |
force_inline poly_float | max (poly_float left, poly_float right) |
Returns the maximum of two poly_float s lane-by-lane. | |
force_inline poly_float | min (poly_float left, poly_float right) |
Returns the minimum of two poly_float s lane-by-lane. | |
force_inline bool | equal (poly_float left, poly_float right) |
Checks if two poly_float s are equal lane-by-lane. Returns true if all lanes match. | |
force_inline poly_float | maskLoad (poly_float zero_value, poly_float one_value, poly_mask reset_mask) |
Selects between two values (zero_value or one_value) based on a mask in each lane. | |
force_inline poly_int | maskLoad (poly_int zero_value, poly_int one_value, poly_mask reset_mask) |
Overload for poly_int . | |
force_inline poly_float | modOnce (poly_float value) |
A special mod operation that ensures the result stays below 1.0, subtracting 1.0 if needed. | |
force_inline poly_mask | closeToZeroMask (poly_float value) |
Returns a mask where lanes are true if value is close to 0. | |
force_inline poly_float | pow (poly_float base, poly_float exponent) |
Raises each lane in base to the power of the corresponding lane in exponent . | |
force_inline poly_mask | getSilentMask (const poly_float *buffer, int length) |
Creates a mask indicating whether all values in the given buffer are near zero. | |
force_inline poly_float | swapStereo (poly_float value) |
Swaps the left and right channels of a stereo poly_float . | |
force_inline poly_int | swapStereo (poly_int value) |
Same as swapStereo but for poly_int . | |
force_inline poly_float | swapVoices (poly_float value) |
Swaps the first half of the lanes with the second half. | |
force_inline poly_int | swapVoices (poly_int value) |
Overload for poly_int . | |
force_inline poly_float | swapInner (poly_float value) |
Reorders internal stereo lanes. | |
force_inline poly_float | reverse (poly_float value) |
Reverses the order of stereo lanes from (L, R, L, R) to (R, L, R, L). | |
force_inline poly_float | consolidateAudio (poly_float one, poly_float two) |
Interleaves two stereo poly_float s into a single vector with left channels first, then right channels. | |
force_inline poly_float | compactFirstVoices (poly_float one, poly_float two) |
Packs the first voice from two different poly_float s into a single vector. | |
force_inline poly_float | sumSplitAudio (poly_float sum) |
Adds two stereo lanes for each voice, returning a combined mono result in each lane. | |
force_inline mono_float | maxFloat (poly_float values) |
Returns the maximum lane value from a poly_float . | |
force_inline mono_float | minFloat (poly_float values) |
Returns the minimum lane value from a poly_float . | |
force_inline poly_float | encodeMidSide (poly_float value) |
Converts an L/R stereo representation into M/S (mid/side) encoding. | |
force_inline poly_float | decodeMidSide (poly_float value) |
Converts a mid/side encoded stereo value back to L/R (decodes). | |
force_inline poly_float | peak (const poly_float *buffer, int num, int skip=1) |
Returns the peak magnitude of a buffer (considering both positive and negative values). | |
force_inline void | zeroBuffer (mono_float *buffer, int size) |
Zeros a mono buffer (standard array). | |
force_inline void | zeroBuffer (poly_float *buffer, int size) |
Zeros a vector buffer (poly_float ). | |
force_inline void | copyBuffer (mono_float *dest, const mono_float *source, int size) |
Copies data from a source mono buffer to a destination mono buffer. | |
force_inline void | copyBuffer (poly_float *dest, const poly_float *source, int size) |
Copies data from a poly_float source buffer to another poly_float buffer. | |
force_inline void | addBuffers (poly_float *dest, const poly_float *b1, const poly_float *b2, int size) |
Adds two poly_float buffers element-by-element, storing in dest . | |
force_inline bool | isFinite (poly_float value) |
Checks if all lanes in a poly_float are finite. | |
force_inline bool | isInRange (poly_float value, mono_float min, mono_float max) |
Checks if each lane in a poly_float is within [min, max]. | |
force_inline bool | isContained (poly_float value) |
Checks if all lanes in a poly_float are within a broad range [-8000..8000]. | |
force_inline bool | isFinite (const poly_float *buffer, int size) |
Checks if all values in a buffer of poly_float s are finite. | |
force_inline bool | isInRange (const poly_float *buffer, int size, mono_float min, mono_float max) |
Checks if all values in a poly_float buffer are within [min, max]. | |
force_inline bool | isContained (const poly_float *buffer, int size) |
Checks if a buffer of poly_float is entirely within [-8000..8000]. | |
force_inline bool | isSilent (const poly_float *buffer, int size) |
Determines if the entire buffer is silent (very close to zero). | |
force_inline poly_float | gather (const mono_float *buffer, const poly_int &indices) |
Gathers values from a mono float buffer into a poly_float , using per-lane indices. | |
force_inline void | adjacentGather (const mono_float *buffer, const poly_int &indices, poly_float &value, poly_float &next) |
Gathers adjacent values for each lane, storing them in value and next . | |
force_inline poly_float | gatherSeparate (const mono_float *const *buffers, const poly_int &indices) |
Gathers values from different buffers, with each lane potentially reading from a different buffer index. | |
force_inline void | adjacentGatherSeparate (const mono_float *const *buffers, const poly_int &indices, poly_float &value, poly_float &next) |
Similar to adjacentGather but for separate buffers. | |
force_inline poly_float | fltScale (poly_float value, poly_float power) |
Performs a simple filter scaling operation (power * value) / ((power - 1)*value + 1) . | |
force_inline poly_float | toFloat (poly_int integers) |
Casts a poly_int to poly_float lane-by-lane. | |
force_inline poly_int | toInt (poly_float floats) |
Casts a poly_float to poly_int by truncation. | |
force_inline poly_int | truncToInt (poly_float value) |
Truncates a poly_float to an integer (effectively floor for positive values). | |
force_inline poly_float | trunc (poly_float value) |
Returns the truncated value of each lane in value . | |
force_inline poly_float | floor (poly_float value) |
Floors each lane in value . | |
force_inline poly_int | floorToInt (poly_float value) |
Floors each lane and returns the result as an integer. | |
force_inline poly_int | roundToInt (poly_float value) |
Rounds each lane to the nearest integer. | |
force_inline poly_float | ceil (poly_float value) |
Ceils each lane in value . | |
force_inline poly_float | round (poly_float value) |
Rounds each lane to the nearest integer as a poly_float . | |
force_inline poly_float | mod (poly_float value) |
Returns the fractional part of each lane by subtracting the floored value. | |
force_inline poly_float | reinterpretToFloat (poly_int value) |
Reinterprets a poly_int as a poly_float (bitcast). | |
force_inline poly_int | reinterpretToInt (poly_float value) |
Reinterprets a poly_float as a poly_int (bitcast). | |
template<size_t shift> | |
force_inline poly_int | shiftRight (poly_int integer) |
template<size_t shift> | |
force_inline poly_int | shiftLeft (poly_int integer) |
force_inline poly_float | pow2ToFloat (poly_int value) |
force_inline poly_float | triangleWave (poly_float t) |
Generates a simple triangle wave [0..1] from a fraction t in [0..1]. | |
force_inline poly_float | getCycleOffsetFromSeconds (double seconds, poly_float frequency) |
Computes a cycle offset given a time in seconds and a frequency. | |
force_inline poly_float | getCycleOffsetFromSamples (long long samples, poly_float frequency, int sample_rate, int oversample_amount) |
Computes a cycle offset given a sample count, frequency, sample rate, and oversampling factor. | |
force_inline poly_float | snapTranspose (poly_float transpose, int quantize) |
Snaps a MIDI transpose value to a quantization mask (e.g., scale degrees). | |
force_inline void | fillSnapBuffer (int transpose_quantize, float *snap_buffer) |
Fills a buffer with snap offsets for a given quantize mask. | |
force_inline bool | isTransposeQuantizeGlobal (int quantize) |
Checks if the transpose quantize mask applies globally (over multiple octaves). | |
force_inline bool | isTransposeSnapping (int quantize) |
Checks if any snapping bits are set in the transpose quantize mask. | |
force_inline poly_float | encodePhaseAndVoice (poly_float phase, poly_float voice) |
Encodes a phase [0..1) and a voice index into a single float, storing the voice in the integer portion. | |
force_inline std::pair< poly_float, poly_float > | decodePhaseAndVoice (poly_float encoded) |
Decodes a phase and voice from an encoded float, returning (phase, voice). | |
mono_float | encodeOrderToFloat (int *order, int size) |
Encodes a permutation (stored in order ) into a single float. | |
void | decodeFloatToOrder (int *order, mono_float float_code, int size) |
Decodes a float-encoded permutation back into order . | |
void | floatToPcmData (int16_t *pcm_data, const float *float_data, int size) |
Converts floating-point audio data to 16-bit PCM data. | |
void | complexToPcmData (int16_t *pcm_data, const std::complex< float > *complex_data, int size) |
Converts an array of complex floats (magnitude/phase) to PCM data. | |
void | pcmToFloatData (float *float_data, const int16_t *pcm_data, int size) |
Converts 16-bit PCM data to floating-point audio data. | |
void | pcmToComplexData (std::complex< float > *complex_data, const int16_t *pcm_data, int size) |
Converts 16-bit PCM data representing complex info (amp/phase) back to std::complex floats. | |
constexpr int | factorial (int value) |
Computes the factorial of a given integer at compile time. | |
force_inline mono_float | intToFloatBits (int i) |
Reinterprets an int as a float (bitwise). | |
force_inline int | floatToIntBits (mono_float f) |
Reinterprets a float as an int (bitwise). | |
force_inline mono_float | min (mono_float one, mono_float two) |
Returns the minimum of two floats. | |
force_inline mono_float | max (mono_float one, mono_float two) |
Returns the maximum of two floats. | |
force_inline mono_float | clamp (mono_float value, mono_float min_val, mono_float max_val) |
Clamps a value between [min_val, max_val]. | |
template<class T > | |
force_inline T | pass (T input) |
A pass-through function that simply returns the input. Often used in templated code. | |
force_inline int | imax (int one, int two) |
Returns the maximum of two integers. | |
force_inline int | imin (int one, int two) |
Returns the minimum of two integers. | |
force_inline double | interpolate (double from, double to, double t) |
Linearly interpolates between two double values. | |
force_inline mono_float | interpolate (mono_float from, mono_float to, mono_float t) |
Linearly interpolates between two floats. | |
force_inline mono_float | mod (double value, double *divisor) |
Returns the fractional part of value , storing the integer part in divisor (double). | |
force_inline mono_float | mod (float value, float *divisor) |
Returns the fractional part of value , storing the integer part in divisor (float). | |
force_inline int | iclamp (int value, int min_val, int max_val) |
Clamps an integer between [min_val, max_val]. | |
force_inline int | ilog2 (int value) |
Computes the floor of the base-2 logarithm of an integer (effectively the index of the highest set bit). | |
force_inline bool | closeToZero (mono_float value) |
Determines if a float is close to zero (within ±kEpsilon). | |
force_inline mono_float | magnitudeToDb (mono_float magnitude) |
Converts a magnitude to decibels using 20*log10(magnitude). | |
force_inline mono_float | dbToMagnitude (mono_float decibels) |
Converts decibels to linear magnitude using 10^(dB / 20). | |
force_inline mono_float | centsToRatio (mono_float cents) |
Converts cents to a ratio. A value of 1200 cents is 2.0. | |
force_inline mono_float | noteOffsetToRatio (mono_float cents) |
Converts a note offset in semitones (or partial) to a frequency ratio. | |
force_inline mono_float | ratioToMidiTranspose (mono_float ratio) |
Converts a frequency ratio to a MIDI transpose value (in semitones). | |
force_inline mono_float | midiCentsToFrequency (mono_float cents) |
Converts a MIDI-based cents value to an absolute frequency, relative to MIDI note 0. | |
force_inline mono_float | midiNoteToFrequency (mono_float note) |
Converts a MIDI note number to frequency in Hz. | |
force_inline mono_float | frequencyToMidiNote (mono_float frequency) |
Converts a frequency in Hz to a MIDI note number. | |
force_inline mono_float | frequencyToMidiCents (mono_float frequency) |
Converts a frequency in Hz to MIDI cents relative to MIDI note 0. | |
force_inline int | nextPowerOfTwo (mono_float value) |
Finds the next power of two greater than or equal to a float value. | |
force_inline bool | isSilent (const mono_float *buffer, int length) |
Checks if all samples in a buffer are close to zero. | |
force_inline mono_float | rms (const mono_float *buffer, int num) |
Computes the Root Mean Square (RMS) of a buffer of floats. | |
force_inline mono_float | inversePowerScale (mono_float t) |
A curve function used for specific shaping or scaling of a parameter. | |
force_inline mono_float | inverseFltScale (mono_float t) |
Another curve function, typically used for certain shape transformations. | |
Variables | |
constexpr mono_float | kPhaseEncodingMultiplier = 0.9f |
Used as a multiplier when encoding phase and voice data in a single float. | |
constexpr unsigned int | kNotePressedMask = 0xf |
A bitmask used in voice encoding for note-on states. | |
constexpr mono_float | kDbGainConversionMult = 20.0f |
Multiplicative factor for converting dB <-> magnitude using dB = 20*log10(magnitude). | |
constexpr int | kMaxOrderLength = 10 |
Maximum length for orders that can be encoded as a float via encodeOrderToFloat(). | |
constexpr mono_float | kLogOf2 = 0.69314718056f |
Natural log of 2. | |
constexpr mono_float | kInvLogOf2 = 1.44269504089f |
Reciprocal of the natural log of 2 (1 / ln(2)). | |
A collection of inline helper functions and constants used for SIMD computations, interpolation, and other audio-related utilities.
The functions within this namespace primarily operate on poly_float
and poly_int
(SIMD vector types) to efficiently handle multi-sample or multi-voice operations.
force_inline void vital::utils::addBuffers | ( | poly_float * | dest, |
const poly_float * | b1, | ||
const poly_float * | b2, | ||
int | size ) |
Adds two poly_float
buffers element-by-element, storing in dest
.
force_inline void vital::utils::adjacentGather | ( | const mono_float * | buffer, |
const poly_int & | indices, | ||
poly_float & | value, | ||
poly_float & | next ) |
Gathers adjacent values for each lane, storing them in value
and next
.
force_inline void vital::utils::adjacentGatherSeparate | ( | const mono_float *const * | buffers, |
const poly_int & | indices, | ||
poly_float & | value, | ||
poly_float & | next ) |
Similar to adjacentGather but for separate buffers.
force_inline poly_float vital::utils::ceil | ( | poly_float | value | ) |
Ceils each lane in value
.
force_inline mono_float vital::utils::centsToRatio | ( | mono_float | cents | ) |
Converts cents to a ratio. A value of 1200 cents is 2.0.
cents | The number of cents (1 semitone = 100 cents). |
force_inline poly_float vital::utils::centsToRatio | ( | poly_float | value | ) |
Converts semitone cents to a linear frequency ratio (vectorized).
value | The input in cents (e.g., 1200 = +1 octave). |
2^(value / 1200)
. force_inline mono_float vital::utils::clamp | ( | mono_float | value, |
mono_float | min_val, | ||
mono_float | max_val ) |
Clamps a value between [min_val, max_val].
value | The value to clamp. |
min_val | The minimum bound. |
max_val | The maximum bound. |
force_inline poly_float vital::utils::clamp | ( | poly_float | value, |
mono_float | min, | ||
mono_float | max ) |
Clamps each lane of a vector to [min, max].
force_inline poly_float vital::utils::clamp | ( | poly_float | value, |
poly_float | min, | ||
poly_float | max ) |
Clamps each lane of a vector to [min, max], where min and max are themselves poly_float
s.
force_inline poly_int vital::utils::clamp | ( | poly_int | value, |
poly_int | min, | ||
poly_int | max ) |
Clamps a poly_int
to [min, max].
force_inline bool vital::utils::closeToZero | ( | mono_float | value | ) |
Determines if a float is close to zero (within ±kEpsilon).
value | The float to test. |
force_inline poly_mask vital::utils::closeToZeroMask | ( | poly_float | value | ) |
Returns a mask where lanes are true if value
is close to 0.
force_inline poly_float vital::utils::compactFirstVoices | ( | poly_float | one, |
poly_float | two ) |
Packs the first voice from two different poly_float
s into a single vector.
void vital::utils::complexToPcmData | ( | int16_t * | pcm_data, |
const std::complex< float > * | complex_data, | ||
int | size ) |
Converts an array of complex floats (magnitude/phase) to PCM data.
pcm_data | Destination PCM array (size must be at least size ). |
complex_data | Source complex float array. |
size | Number of samples in the complex array (note that real PCM size is double). |
force_inline poly_float vital::utils::consolidateAudio | ( | poly_float | one, |
poly_float | two ) |
Interleaves two stereo poly_float
s into a single vector with left channels first, then right channels.
force_inline void vital::utils::copyBuffer | ( | mono_float * | dest, |
const mono_float * | source, | ||
int | size ) |
Copies data from a source mono buffer to a destination mono buffer.
force_inline void vital::utils::copyBuffer | ( | poly_float * | dest, |
const poly_float * | source, | ||
int | size ) |
Copies data from a poly_float
source buffer to another poly_float
buffer.
force_inline poly_float vital::utils::cos | ( | poly_float | value | ) |
Computes the cosine of each element (in radians).
force_inline mono_float vital::utils::dbToMagnitude | ( | mono_float | decibels | ) |
Converts decibels to linear magnitude using 10^(dB / 20).
decibels | The dB value. |
force_inline poly_float vital::utils::dbToMagnitude | ( | poly_float | value | ) |
Converts a dB value to linear magnitude (vectorized).
void vital::utils::decodeFloatToOrder | ( | int * | order, |
mono_float | float_code, | ||
int | size ) |
Decodes a float-encoded permutation back into order
.
Decodes a float-encoded permutation (from encodeOrderToFloat) back into an integer array.
order | The integer array to fill. |
float_code | The encoded float from encodeOrderToFloat. |
size | Number of elements in order . |
order | The integer array to fill with the permutation. |
float_code | The float code containing the encoded order. |
size | The length of the order array. |
force_inline poly_float vital::utils::decodeMidSide | ( | poly_float | value | ) |
Converts a mid/side encoded stereo value back to L/R (decodes).
force_inline std::pair< poly_float, poly_float > vital::utils::decodePhaseAndVoice | ( | poly_float | encoded | ) |
Decodes a phase and voice from an encoded float, returning (phase, voice).
force_inline poly_float vital::utils::encodeMidSide | ( | poly_float | value | ) |
Converts an L/R stereo representation into M/S (mid/side) encoding.
mono_float vital::utils::encodeOrderToFloat | ( | int * | order, |
int | size ) |
Encodes a permutation (stored in order
) into a single float.
Encodes a permutation order array into a single float (bit-packed).
order | Integer array representing the permutation. |
size | Length of the array (up to kMaxOrderLength). |
Each element in order
is used to compute a factorial-based integer code. It is then returned as a float.
order | An integer array representing the permutation order. |
size | The length of the array (up to kMaxOrderLength). |
force_inline poly_float vital::utils::encodePhaseAndVoice | ( | poly_float | phase, |
poly_float | voice ) |
Encodes a phase [0..1) and a voice index into a single float, storing the voice in the integer portion.
force_inline bool vital::utils::equal | ( | poly_float | left, |
poly_float | right ) |
Checks if two poly_float
s are equal lane-by-lane. Returns true if all lanes match.
|
constexpr |
Computes the factorial of a given integer at compile time.
value | The integer whose factorial is needed. |
value
. force_inline void vital::utils::fillSnapBuffer | ( | int | transpose_quantize, |
float * | snap_buffer ) |
Fills a buffer with snap offsets for a given quantize mask.
force_inline int vital::utils::floatToIntBits | ( | mono_float | f | ) |
Reinterprets a float as an int (bitwise).
f | The float to reinterpret. |
void vital::utils::floatToPcmData | ( | int16_t * | pcm_data, |
const float * | float_data, | ||
int | size ) |
Converts floating-point audio data to 16-bit PCM data.
pcm_data | Destination PCM array. |
float_data | Source float array. |
size | Number of samples to convert. |
force_inline poly_float vital::utils::floor | ( | poly_float | value | ) |
Floors each lane in value
.
force_inline poly_int vital::utils::floorToInt | ( | poly_float | value | ) |
Floors each lane and returns the result as an integer.
force_inline poly_float vital::utils::fltScale | ( | poly_float | value, |
poly_float | power ) |
Performs a simple filter scaling operation (power * value) / ((power - 1)*value + 1)
.
force_inline mono_float vital::utils::frequencyToMidiCents | ( | mono_float | frequency | ) |
Converts a frequency in Hz to MIDI cents relative to MIDI note 0.
frequency | The frequency in Hz. |
force_inline poly_float vital::utils::frequencyToMidiCents | ( | poly_float | value | ) |
Converts a frequency to MIDI cents (vectorized).
force_inline mono_float vital::utils::frequencyToMidiNote | ( | mono_float | frequency | ) |
Converts a frequency in Hz to a MIDI note number.
frequency | The frequency in Hz. |
force_inline poly_float vital::utils::frequencyToMidiNote | ( | poly_float | value | ) |
Converts a frequency to a MIDI note (vectorized).
force_inline poly_float vital::utils::gather | ( | const mono_float * | buffer, |
const poly_int & | indices ) |
Gathers values from a mono float buffer into a poly_float
, using per-lane indices.
force_inline poly_float vital::utils::gatherSeparate | ( | const mono_float *const * | buffers, |
const poly_int & | indices ) |
Gathers values from different buffers, with each lane potentially reading from a different buffer index.
force_inline matrix vital::utils::getCatmullInterpolationMatrix | ( | poly_float | t | ) |
Creates a Catmull-Rom interpolation matrix from a poly_float
t.
force_inline poly_float vital::utils::getCubicInterpolationValues | ( | mono_float | mono_t | ) |
Returns the cubic Lagrange interpolation constants for a scalar mono_t
.
force_inline poly_float vital::utils::getCycleOffsetFromSamples | ( | long long | samples, |
poly_float | frequency, | ||
int | sample_rate, | ||
int | oversample_amount ) |
Computes a cycle offset given a sample count, frequency, sample rate, and oversampling factor.
force_inline poly_float vital::utils::getCycleOffsetFromSeconds | ( | double | seconds, |
poly_float | frequency ) |
Computes a cycle offset given a time in seconds and a frequency.
seconds | The elapsed time in seconds. |
frequency | The per-lane frequency. |
force_inline matrix vital::utils::getLinearInterpolationMatrix | ( | poly_float | t | ) |
Creates a matrix for simple linear interpolation using scalar or vector t
.
force_inline poly_float vital::utils::getOptimalInterpolationValues | ( | mono_float | mono_t | ) |
Returns an "optimal" polynomial interpolation for a scalar mono_t
.
force_inline matrix vital::utils::getPolynomialInterpolationMatrix | ( | poly_float | t_from | ) |
Creates a matrix for polynomial interpolation given a starting poly_float
t_from.
force_inline poly_mask vital::utils::getSilentMask | ( | const poly_float * | buffer, |
int | length ) |
Creates a mask indicating whether all values in the given buffer are near zero.
force_inline matrix vital::utils::getValueMatrix | ( | const mono_float * | buffer, |
poly_int | indices ) |
Creates a matrix of 4 poly_float lanes from a single buffer at varying indices.
force_inline matrix vital::utils::getValueMatrix | ( | const mono_float *const * | buffers, |
poly_int | indices ) |
Creates a matrix of 4 poly_float lanes from 4 separate buffers at varying indices.
force_inline int vital::utils::iclamp | ( | int | value, |
int | min_val, | ||
int | max_val ) |
Clamps an integer between [min_val, max_val].
force_inline int vital::utils::ilog2 | ( | int | value | ) |
Computes the floor of the base-2 logarithm of an integer (effectively the index of the highest set bit).
value | The integer to compute log2 for (must be > 0). |
force_inline int vital::utils::imax | ( | int | one, |
int | two ) |
Returns the maximum of two integers.
force_inline int vital::utils::imin | ( | int | one, |
int | two ) |
Returns the minimum of two integers.
force_inline double vital::utils::interpolate | ( | double | from, |
double | to, | ||
double | t ) |
Linearly interpolates between two double values.
from | The starting value. |
to | The ending value. |
t | A fraction in [0, 1], where 0 returns from and 1 returns to . |
force_inline mono_float vital::utils::interpolate | ( | mono_float | from, |
mono_float | to, | ||
mono_float | t ) |
Linearly interpolates between two floats.
force_inline poly_float vital::utils::interpolate | ( | mono_float | from, |
mono_float | to, | ||
poly_float | t ) |
Interpolates between two scalars with a SIMD fraction t.
force_inline poly_float vital::utils::interpolate | ( | poly_float | from, |
poly_float | to, | ||
mono_float | t ) |
Performs a linear interpolation between two poly_float
s using a scalar t
in [0..1].
force_inline poly_float vital::utils::interpolate | ( | poly_float | from, |
poly_float | to, | ||
poly_float | t ) |
Interpolates between two SIMD values with a SIMD fraction t.
force_inline mono_float vital::utils::intToFloatBits | ( | int | i | ) |
Reinterprets an int as a float (bitwise).
i | The int to reinterpret. |
force_inline mono_float vital::utils::inverseFltScale | ( | mono_float | t | ) |
Another curve function, typically used for certain shape transformations.
t | Input value in [0, 1]. |
force_inline mono_float vital::utils::inversePowerScale | ( | mono_float | t | ) |
A curve function used for specific shaping or scaling of a parameter.
t | Input value in [0, 1]. |
force_inline bool vital::utils::isContained | ( | const poly_float * | buffer, |
int | size ) |
Checks if a buffer of poly_float
is entirely within [-8000..8000].
force_inline bool vital::utils::isContained | ( | poly_float | value | ) |
Checks if all lanes in a poly_float
are within a broad range [-8000..8000].
force_inline bool vital::utils::isFinite | ( | const poly_float * | buffer, |
int | size ) |
Checks if all values in a buffer of poly_float
s are finite.
force_inline bool vital::utils::isFinite | ( | poly_float | value | ) |
Checks if all lanes in a poly_float
are finite.
force_inline bool vital::utils::isInRange | ( | const poly_float * | buffer, |
int | size, | ||
mono_float | min, | ||
mono_float | max ) |
Checks if all values in a poly_float
buffer are within [min, max].
force_inline bool vital::utils::isInRange | ( | poly_float | value, |
mono_float | min, | ||
mono_float | max ) |
Checks if each lane in a poly_float
is within [min, max].
force_inline bool vital::utils::isSilent | ( | const mono_float * | buffer, |
int | length ) |
Checks if all samples in a buffer are close to zero.
buffer | A pointer to an array of mono_float samples. |
length | The number of samples in the buffer. |
force_inline bool vital::utils::isSilent | ( | const poly_float * | buffer, |
int | size ) |
Determines if the entire buffer is silent (very close to zero).
force_inline bool vital::utils::isTransposeQuantizeGlobal | ( | int | quantize | ) |
Checks if the transpose quantize mask applies globally (over multiple octaves).
force_inline bool vital::utils::isTransposeSnapping | ( | int | quantize | ) |
Checks if any snapping bits are set in the transpose quantize mask.
force_inline mono_float vital::utils::magnitudeToDb | ( | mono_float | magnitude | ) |
Converts a magnitude to decibels using 20*log10(magnitude).
magnitude | The non-negative amplitude or magnitude. |
force_inline poly_float vital::utils::magnitudeToDb | ( | poly_float | value | ) |
Converts a magnitude value to decibels (vectorized).
force_inline poly_float vital::utils::map | ( | poly_float | value | ) |
Applies a scalar function to each element in a poly_float
.
func | Pointer to a function (mono_float -> mono_float). |
value | The SIMD vector on which to apply the function element-by-element. |
func(value[i])
for each lane. force_inline poly_float vital::utils::maskLoad | ( | poly_float | zero_value, |
poly_float | one_value, | ||
poly_mask | reset_mask ) |
force_inline poly_int vital::utils::maskLoad | ( | poly_int | zero_value, |
poly_int | one_value, | ||
poly_mask | reset_mask ) |
Overload for poly_int
.
force_inline mono_float vital::utils::max | ( | mono_float | one, |
mono_float | two ) |
Returns the maximum of two floats.
force_inline poly_float vital::utils::max | ( | poly_float | left, |
poly_float | right ) |
Returns the maximum of two poly_float
s lane-by-lane.
force_inline mono_float vital::utils::maxFloat | ( | poly_float | values | ) |
Returns the maximum lane value from a poly_float
.
force_inline mono_float vital::utils::midiCentsToFrequency | ( | mono_float | cents | ) |
Converts a MIDI-based cents value to an absolute frequency, relative to MIDI note 0.
cents | The note offset in cents relative to MIDI note 0. |
force_inline poly_float vital::utils::midiCentsToFrequency | ( | poly_float | value | ) |
Converts MIDI cents to frequency (vectorized).
force_inline mono_float vital::utils::midiNoteToFrequency | ( | mono_float | note | ) |
Converts a MIDI note number to frequency in Hz.
note | MIDI note in semitones (C-1 is 0, A4 is 69, etc.). |
force_inline poly_float vital::utils::midiNoteToFrequency | ( | poly_float | value | ) |
Converts a MIDI note to a frequency (vectorized).
force_inline mono_float vital::utils::min | ( | mono_float | one, |
mono_float | two ) |
Returns the minimum of two floats.
force_inline poly_float vital::utils::min | ( | poly_float | left, |
poly_float | right ) |
Returns the minimum of two poly_float
s lane-by-lane.
force_inline mono_float vital::utils::minFloat | ( | poly_float | values | ) |
Returns the minimum lane value from a poly_float
.
force_inline mono_float vital::utils::mod | ( | double | value, |
double * | divisor ) |
Returns the fractional part of value
, storing the integer part in divisor
(double).
force_inline mono_float vital::utils::mod | ( | float | value, |
float * | divisor ) |
Returns the fractional part of value
, storing the integer part in divisor
(float).
force_inline poly_float vital::utils::mod | ( | poly_float | value | ) |
Returns the fractional part of each lane by subtracting the floored value.
force_inline poly_float vital::utils::modOnce | ( | poly_float | value | ) |
A special mod operation that ensures the result stays below 1.0, subtracting 1.0 if needed.
value | The input vector in [0..2). |
force_inline poly_float vital::utils::mulAdd | ( | poly_float | a, |
poly_float | b, | ||
poly_float | c ) |
Performs a fused multiply-add on SIMD data: (a * b) + c.
a | The first multiplicand. |
b | The second multiplicand. |
c | The addend. |
(a * b) + c
. force_inline poly_float vital::utils::mulSub | ( | poly_float | a, |
poly_float | b, | ||
poly_float | c ) |
Performs a fused multiply-sub on SIMD data: (a * b) - c.
a | The first multiplicand. |
b | The second multiplicand. |
c | The subtrahend. |
(a * b) - c
. force_inline int vital::utils::nextPowerOfTwo | ( | mono_float | value | ) |
Finds the next power of two greater than or equal to a float value.
value | A float specifying the lower bound. |
value
. force_inline mono_float vital::utils::noteOffsetToRatio | ( | mono_float | cents | ) |
Converts a note offset in semitones (or partial) to a frequency ratio.
cents | The number of semitones (100 cents each). |
force_inline poly_float vital::utils::noteOffsetToRatio | ( | poly_float | value | ) |
Converts note offsets to frequency ratios. Similar to centsToRatio
, but may differ in how offset is defined.
force_inline T vital::utils::pass | ( | T | input | ) |
A pass-through function that simply returns the input. Often used in templated code.
T | Generic type. |
input | The input value. |
void vital::utils::pcmToComplexData | ( | std::complex< float > * | complex_data, |
const int16_t * | pcm_data, | ||
int | size ) |
Converts 16-bit PCM data representing complex info (amp/phase) back to std::complex floats.
complex_data | Destination complex float array. |
pcm_data | Source PCM array. |
size | Number of samples in pcm_data (note that real complex size is half). |
void vital::utils::pcmToFloatData | ( | float * | float_data, |
const int16_t * | pcm_data, | ||
int | size ) |
Converts 16-bit PCM data to floating-point audio data.
float_data | Destination float array. |
pcm_data | Source PCM array. |
size | Number of samples to convert. |
force_inline poly_float vital::utils::peak | ( | const poly_float * | buffer, |
int | num, | ||
int | skip = 1 ) |
Returns the peak magnitude of a buffer (considering both positive and negative values).
force_inline poly_float vital::utils::perlinInterpolate | ( | poly_float | from, |
poly_float | to, | ||
poly_float | t ) |
A specialized interpolation function used in perlin-like routines.
force_inline poly_float vital::utils::pow | ( | poly_float | base, |
poly_float | exponent ) |
Raises each lane in base
to the power of the corresponding lane in exponent
.
force_inline poly_float vital::utils::pow2ToFloat | ( | poly_int | value | ) |
force_inline mono_float vital::utils::ratioToMidiTranspose | ( | mono_float | ratio | ) |
Converts a frequency ratio to a MIDI transpose value (in semitones).
ratio | The frequency ratio (e.g., 2.0 for one octave above). |
force_inline poly_float vital::utils::ratioToMidiTranspose | ( | poly_float | value | ) |
Converts a ratio to MIDI transpose (vectorized).
force_inline poly_float vital::utils::reinterpretToFloat | ( | poly_int | value | ) |
Reinterprets a poly_int
as a poly_float
(bitcast).
force_inline poly_int vital::utils::reinterpretToInt | ( | poly_float | value | ) |
Reinterprets a poly_float
as a poly_int
(bitcast).
force_inline poly_float vital::utils::reverse | ( | poly_float | value | ) |
Reverses the order of stereo lanes from (L, R, L, R) to (R, L, R, L).
force_inline mono_float vital::utils::rms | ( | const mono_float * | buffer, |
int | num ) |
Computes the Root Mean Square (RMS) of a buffer of floats.
buffer | The pointer to the samples. |
num | The number of samples. |
force_inline poly_float vital::utils::round | ( | poly_float | value | ) |
Rounds each lane to the nearest integer as a poly_float
.
force_inline poly_int vital::utils::roundToInt | ( | poly_float | value | ) |
Rounds each lane to the nearest integer.
force_inline poly_int vital::utils::shiftLeft | ( | poly_int | integer | ) |
force_inline poly_int vital::utils::shiftRight | ( | poly_int | integer | ) |
force_inline poly_float vital::utils::sin | ( | poly_float | value | ) |
Computes the sine of each element (in radians).
force_inline poly_float vital::utils::snapTranspose | ( | poly_float | transpose, |
int | quantize ) |
Snaps a MIDI transpose value to a quantization mask (e.g., scale degrees).
force_inline poly_float vital::utils::sqrt | ( | poly_float | value | ) |
Computes the square root of each element in a poly_float
.
force_inline poly_float vital::utils::sumSplitAudio | ( | poly_float | sum | ) |
Adds two stereo lanes for each voice, returning a combined mono result in each lane.
force_inline poly_float vital::utils::swapInner | ( | poly_float | value | ) |
Reorders internal stereo lanes.
force_inline poly_float vital::utils::swapStereo | ( | poly_float | value | ) |
Swaps the left and right channels of a stereo poly_float
.
force_inline poly_int vital::utils::swapStereo | ( | poly_int | value | ) |
Same as swapStereo but for poly_int
.
force_inline poly_float vital::utils::swapVoices | ( | poly_float | value | ) |
Swaps the first half of the lanes with the second half.
force_inline poly_int vital::utils::swapVoices | ( | poly_int | value | ) |
Overload for poly_int
.
force_inline poly_float vital::utils::tan | ( | poly_float | value | ) |
Computes the tangent of each element (in radians) in a poly_float
.
force_inline poly_float vital::utils::toFloat | ( | poly_int | integers | ) |
Casts a poly_int
to poly_float
lane-by-lane.
force_inline poly_int vital::utils::toInt | ( | poly_float | floats | ) |
Casts a poly_float
to poly_int
by truncation.
force_inline poly_float vital::utils::toPolyFloatFromUnaligned | ( | const mono_float * | unaligned | ) |
Loads a poly_float
from an unaligned float pointer.
force_inline poly_float vital::utils::triangleWave | ( | poly_float | t | ) |
Generates a simple triangle wave [0..1] from a fraction t
in [0..1].
force_inline poly_float vital::utils::trunc | ( | poly_float | value | ) |
Returns the truncated value of each lane in value
.
force_inline poly_int vital::utils::truncToInt | ( | poly_float | value | ) |
Truncates a poly_float
to an integer (effectively floor for positive values).
force_inline void vital::utils::zeroBuffer | ( | mono_float * | buffer, |
int | size ) |
Zeros a mono buffer (standard array).
force_inline void vital::utils::zeroBuffer | ( | poly_float * | buffer, |
int | size ) |
Zeros a vector buffer (poly_float
).
|
constexpr |
Multiplicative factor for converting dB <-> magnitude using dB = 20*log10(magnitude).
|
constexpr |
Reciprocal of the natural log of 2 (1 / ln(2)).
|
constexpr |
Natural log of 2.
|
constexpr |
Maximum length for orders that can be encoded as a float via encodeOrderToFloat().
|
constexpr |
A bitmask used in voice encoding for note-on states.
|
constexpr |
Used as a multiplier when encoding phase and voice data in a single float.