38static constexpr uint16_t
Log = 0;
53template<u
int16_t Size>
54inline uint16_t
lut_curve_warp(
const uint16_t* table, uint16_t phase, uint16_t curve) {
55 if (curve ==
U16_MID)
return phase;
57 uint32_t phase32 =
static_cast<uint32_t
>(phase) << 16;
69 uint32_t inv_phase32 =
static_cast<uint32_t
>(
U16_MAX - phase) << 16;
77 return static_cast<uint16_t
>(
78 phase + ((
static_cast<int32_t
>(shaped) - phase) * amount >> 16));
90 static uint16_t
warp(uint16_t phase, uint16_t curve) {
114 static uint16_t
warp(uint16_t phase, uint16_t curve) {
115 if (curve ==
U16_MID)
return phase;
119 uint32_t t = flip ? (
U16_MAX - phase) : phase;
124 uint32_t a_q16 =
static_cast<uint32_t
>((
static_cast<uint64_t
>(
STAGES_K) * dc * dc) >> 16);
129 uint64_t num =
static_cast<uint64_t
>(
Q16_ONE + a_q16) * t;
130 uint32_t den =
Q16_ONE +
static_cast<uint32_t
>(
131 static_cast<uint64_t
>(a_q16) * t >> 16);
133 uint32_t result =
static_cast<uint32_t
>(num / den);
136 return static_cast<uint16_t
>(flip ? (
U16_MAX - result) : result);
162 static constexpr float K = 128.0f;
165 static float warp(
float phase,
float curve) {
166 if (curve > -0.001f && curve < 0.001f)
return phase;
168 bool flip = curve > 0.0f;
169 float t = flip ? (1.0f - phase) : phase;
170 float dc = flip ? curve : -curve;
172 float a =
K * dc * dc;
173 float num = (1.0f + a) * t;
174 float den = 1.0f + a * t;
175 float result = num / den;
177 if (result > 1.0f) result = 1.0f;
178 return flip ? (1.0f - result) : result;
static constexpr uint16_t Exp
static constexpr uint16_t Log
static constexpr uint16_t Linear
uint16_t lookup_linear(const uint16_t *table, uint32_t phase)
constexpr uint16_t exp_curve_256[257]
DSP atoms for audio signal processing.
constexpr uint16_t U16_MID
uint16_t lut_curve_warp(const uint16_t *table, uint16_t phase, uint16_t curve)
constexpr uint16_t U16_MAX
constexpr uint32_t Q16_ONE
static uint16_t warp(uint16_t phase, uint16_t curve)
static float warp(float phase, float curve)
static constexpr uint32_t STAGES_K
static uint16_t warp(uint16_t phase, uint16_t curve)