MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Transform.hpp File Reference

Discrete sequence transformation primitives for MayaFlux::Kinesis. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  MayaFlux
 Main namespace for the Maya Flux audio engine.
 
namespace  MayaFlux::Kinesis
 
namespace  MayaFlux::Kinesis::Discrete
 

Functions

void MayaFlux::Kinesis::Discrete::linear (std::span< double > data, double a, double b) noexcept
 Linear map y = a*x + b applied in-place.
 
void MayaFlux::Kinesis::Discrete::power (std::span< double > data, double exponent) noexcept
 Power map y = x^exponent applied in-place Scalar transcendental — not SIMD hot-path.
 
void MayaFlux::Kinesis::Discrete::exponential (std::span< double > data, double a, double b, double base=std::numbers::e) noexcept
 Exponential map y = a * base^(b*x) applied in-place Scalar transcendental — not SIMD hot-path.
 
void MayaFlux::Kinesis::Discrete::logarithmic (std::span< double > data, double a, double b, double c, double base=std::numbers::e) noexcept
 Logarithmic map y = a * log_base(b*x + c) applied in-place Values where (b*x + c) <= 0 are mapped to 0.
 
template<typename TrigFunc >
requires std::invocable<TrigFunc, double> && std::same_as<std::invoke_result_t<TrigFunc, double>, double>
void MayaFlux::Kinesis::Discrete::apply_trig (std::span< double > data, TrigFunc func, double frequency, double amplitude, double phase) noexcept
 Trigonometric map y = amplitude * f(frequency*x + phase) applied in-place.
 
void MayaFlux::Kinesis::Discrete::clamp (std::span< double > data, double lo, double hi) noexcept
 Clamp values to [lo, hi] in-place.
 
void MayaFlux::Kinesis::Discrete::quantize (std::span< double > data, uint8_t bits) noexcept
 Quantize to n-bit resolution in-place Input is assumed to be in [-1, 1]; values outside are clamped first.
 
void MayaFlux::Kinesis::Discrete::normalize (std::span< double > data, double target_min=-1.0, double target_max=1.0) noexcept
 Normalize to [target_min, target_max] in-place Single-pass min/max reduction followed by a single transform pass.
 
void MayaFlux::Kinesis::Discrete::reverse (std::span< double > data) noexcept
 Reverse temporal order in-place.
 
void MayaFlux::Kinesis::Discrete::fade (std::span< double > data, double fade_in_ratio, double fade_out_ratio) noexcept
 Apply equal-power (cosine) fade-in then fade-out envelope in-place The cosine taper maintains constant perceived loudness at the crossover point (0 dB centre gain vs −6 dB for a linear taper).
 
std::vector< double > MayaFlux::Kinesis::Discrete::slice (std::span< const double > data, double start_ratio, double end_ratio)
 Extract a contiguous slice by ratio, returning a new vector.
 
std::vector< double > MayaFlux::Kinesis::Discrete::delay (std::span< const double > data, uint32_t delay_samples, double fill_value=0.0)
 Prepend delay_samples zero-valued (or fill_value) samples, returning a new vector.
 
void MayaFlux::Kinesis::Discrete::interpolate_linear (std::span< const double > src, std::span< double > dst) noexcept
 Linear interpolation from src into dst (caller sizes dst) Branchless inner loop with precomputed step; dst may be larger or smaller than src.
 
void MayaFlux::Kinesis::Discrete::interpolate_cubic (std::span< const double > src, std::span< double > dst) noexcept
 Catmull-Rom cubic interpolation from src into dst (caller sizes dst) Branchless boundary clamping; Horner evaluation form.
 
std::vector< double > MayaFlux::Kinesis::Discrete::time_stretch (std::span< const double > data, double stretch_factor)
 Time-stretch via linear interpolation resampling Fast but alias-naive: no anti-aliasing pre-filter is applied when stretch_factor < 1.
 

Detailed Description

Discrete sequence transformation primitives for MayaFlux::Kinesis.

Pure numerical functions operating on contiguous double-precision spans. No MayaFlux type dependencies. Domain-agnostic — the same primitives serve audio, visual, control, and any other sampled sequence.

All mutating functions operate in-place on the supplied span. Functions that change the output size return a new vector. Callers loop over channels; no multichannel wrappers are provided.

SIMD notes: linear, clamp, reverse, fade, normalize, quantize, interpolate_linear, and interpolate_cubic are written to be auto-vectorisable under -O2 -march=native (GCC/Clang). Transcendental functions (power, exponential, logarithmic) remain scalar; they are not hot-path and require SVML or a polynomial approximation for SIMD throughput.

Definition in file Transform.hpp.