12#ifndef SBL_MATH_INTERPOLATE_HPP_
13#define SBL_MATH_INTERPOLATE_HPP_
28inline constexpr float crossfade(
float a,
float b,
float t) {
return a + (b - a) * t; }
38inline constexpr float smooth_step(
float t) {
return t * t * (3.0f - 2.0f * t); }
48inline constexpr int32_t
crossfade_i16(int16_t a, int16_t b, uint16_t t) {
49 return a + ((
static_cast<int32_t
>(b) - a) * t) /
U16_MAX;
The numbers every layer reaches for.
Domain-neutral math: constants, clamp, interpolation.
constexpr float crossfade(float a, float b, float t)
Linear crossfade between two values.
constexpr float smooth_step(float t)
Hermite smooth step (3rd-order S-curve)
constexpr int32_t crossfade_i16(int16_t a, int16_t b, uint16_t t)
Integer crossfade for 16-bit values.
constexpr uint16_t U16_MAX
The full scale of a 16-bit unsigned blend factor.