Utilities#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.Functions
-
template<typename T0, typename T1, typename T2>
inline void Clamp(T0 &x, T1 min, T2 max)# Clamp
xto the inclusive range [min,max].Templated so it works on any types that compare with
<. The result is written back intox.
-
inline void Randomize()#
Seed the random generator from the current time.
Call once at startup.
-
inline Int Random(Int max)#
Random integer in [0,
max).
-
inline Int Random(Int min, Int max)#
Random integer in [
min,max).
-
inline Int BigRandom(Int max)#
Heavy-tailed random integer biased toward 0; produces fewer high values than
Random.
-
inline Flt RandomF()#
Random float in [0, 1].
-
inline Flt RandomF(Flt max)#
Random float in [0,
max].
-
inline Flt RandomF(Flt min, Flt max)#
Random float in [
min,max].
-
inline Flt *Random(Flt *min, Flt *max)#
Random pointer in [
min,max), stride oneFlt.
Variables
-
const Flt Pi_6 = 0.52359878f#
PI/6 (30°).
-
const Flt Pi_4 = 0.78539816f#
PI/4 (45°).
-
const Flt Pi_3 = 1.04719755f#
PI/3 (60°).
-
const Flt Pi_2 = 1.57079633f#
PI/2 (90°).
-
const Flt Pi = 3.14159265f#
PI (180°).
-
const Flt Pi2 = 6.28318531f#
PI × 2 (360°).
-
const Flt ToDegrees = 57.29577951f#
Multiply radians by this to get degrees.
-
const Flt ToRadians = 0.017453293f#
Multiply degrees by this to get radians.
-
const Flt Sqrt2 = 1.4142135623730950f#
√2.
-
const Flt Sqrt3 = 1.7320508075688773f#
√3.
-
const Flt Sqrt2_2 = 0.7071067811865475f#
√2 / 2.
-
const Flt Sqrt3_3 = 0.5773502691896257f#
√3 / 3.
-
template<typename T0, typename T1, typename T2>
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.Functions
-
inline Int Min(Int x, Int y)#
Minimum of two integers.
-
inline Int Min(UInt x, Int y)#
-
inline Int Min(Int x, UInt y)#
-
inline UInt Min(UInt x, UInt y)#
-
inline I64 Min(Int x, I64 y)#
-
inline Flt Min(Flt x, Flt y)#
-
inline Flt Min(Int x, Flt y)#
-
inline Flt Min(Flt x, Int y)#
-
inline Dbl Min(Dbl x, Dbl y)#
-
inline Int Max(Int x, Int y)#
-
inline UInt Max(UInt x, Int y)#
-
inline UInt Max(Int x, UInt y)#
-
inline UInt Max(UInt x, UInt y)#
-
inline I64 Max(Int x, I64 y)#
-
inline Flt Max(Flt x, Flt y)#
-
inline Flt Max(Int x, Flt y)#
-
inline Flt Max(Flt x, Int y)#
-
inline Dbl Max(Dbl x, Dbl y)#
-
class Pos#
3D position vector — the spatial coordinate used throughout libYSE.
Used for
soundpositions, theListenerposition, andreverbzone centres. Components are plain floats — read or writex,y,zdirectly. Arithmetic and comparison operators behave component-wise.Public Functions
-
inline float length()#
Euclidean length of the vector.
-
inline std::string asText()#
Human-readable
"X: x Y: y Z: z"representation.
-
inline Pos()#
Construct at the origin (0, 0, 0).
-
inline Pos(float r)#
Construct with every component set to
r.
-
inline Pos(float x, float y, float z)#
Construct with explicit components.
-
Pos(const aPos &v)#
Construct from an atomic position object.
Friends
-
inline float length()#
-
inline Int Min(Int x, Int y)#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.-
class linearInterpolator#
Block-rate linear interpolator driven by an external time delta.
Call
setto start interpolating toward a target overtimeseconds, then callupdate(timeDelta)once per frame andoperator()to read the current value.Public Functions
-
linearInterpolator()#
-
linearInterpolator &set(Flt target, Flt time = 0)#
Start a new ramp toward
targetovertimeseconds.
-
linearInterpolator &update(Flt timeDelta)#
Advance the interpolator by
timeDeltaseconds.
-
Flt target()#
Current target value.
-
Flt operator()()#
Current interpolated value.
-
linearInterpolator()#
-
template<class TYPE>
class objectInterpolator# Probabilistic cross-fade between two objects.
Unlike
linearInterpolator, this template does NOT blend the objects themselves — it returns either the current or the target object on each call. AstimeLeftdecreases, the probability of returning the target rises until it reaches 1.0 attimeLeft == 0. Useful for non-blendable state (pointers, discrete enums, etc.).Public Functions
-
inline objectInterpolator()#
-
inline objectInterpolator<TYPE> &set(TYPE obj, Flt time = 0)#
Set a new target object.
TYPEmust be copy-constructible unless it is itself a pointer. Setting a target for the first time replaces the current value immediately; subsequent calls start a cross-fade.
-
inline objectInterpolator<TYPE> &update(Flt timeDelta)#
Advance by
timeDeltaseconds.
-
inline TYPE &operator()()#
Return either the current or target object, weighted by how far the cross-fade has progressed.
-
inline Bool isSet()#
Whether any object has been set.
-
inline objectInterpolator()#
-
class linearInterpolator#
-
namespace YSE
Public API of libYSE — sound playback, mixing, and 3D positional audio.
Entry points:
YSE::System(lifecycle and audio device),YSE::Listener(3D origin),YSE::sound(a playable source),YSE::channel(mixing tree),YSE::reverb(positioned reverb zone),YSE::patcher(modular DSP graph),YSE::player(note sequencer). Sub-namespaces group domain-specific types:YSE::DSPfor signal processing,YSE::MIDIfor MIDI I/O,YSE::MUSICfor note / chord / motif primitives.Note
Apart from their constructors, the oscillator and
vcfclasses must only be invoked from inside a DSP callback /processbody.