7#include "vendor/prelude/hint.h"
43[[nodiscard, gnu::const]]
44static inline float nec_trilerp(
53 float x,
float y,
float z
55 assume(0 <= x && x <= 1);
56 assume(0 <= y && y <= 1);
57 assume(0 <= z && z <= 1);
58 const auto z1 = 1.f - z;
59 const auto c00 = c000 * z1 + c001 * z;
60 const auto c01 = c010 * z1 + c011 * z;
61 const auto c10 = c100 * z1 + c101 * z;
62 const auto c11 = c110 * z1 + c111 * z;
63 const auto y1 = 1.f - y;
64 const auto c0 = c00 * y1 + c01 * y;
65 const auto c1 = c10 * y1 + c11 * y;
66 return c0 * (1.f - x) + c1 * x;
76 if (!mipmap_count) mipmap_count = 16;
77 if (!variant_count) variant_count = 1;
78 if (!sample_count) sample_count = 2048;
87struct nec_wt *nec_alloc_wt(
91) [[clang::allocating]] {
93 struct nec_wt *wt = malloc(size);
94 if (!wt)
return nullptr;
99[[nodiscard, gnu::const, gnu::nonnull]]
100static inline float nec_wt_get(
101 struct nec_wt wt[
const restrict
static 1],
102 float normalized_frequency,
106 assume(0 <= normalized_frequency && normalized_frequency <= 1);
107 assume(0 <= variant && variant <= 1);
108 assume(0 <= phase && phase < 1);
111 const auto m = normalized_frequency * (wt->
mipmap_count - 1);
112 const auto mi = floorf(m);
113 const auto mf = m - mi;
114 const auto m0 = (size_t)(mi);
115 const auto m1 = 1 + m0;
119 const auto vi = floorf(v);
120 const auto vf = v - vi;
121 const auto v0 = (size_t)(vi);
122 const auto v1 = 1 + v0;
126 const auto si = floorf(s);
127 const auto sf = s - si;
128 const auto s0 = (size_t)(si);
Definition wavetable.h:18
size_t variant_count
How many different wave shape variants exist in this wavetable that can be morphed between.
Definition wavetable.h:29
size_t sample_count
How many samples each wave shape variant is made of.
Definition wavetable.h:32
size_t mipmap_count
How many mip-map levels there are in this wavetable.
Definition wavetable.h:23
float data[]
The actual wavetable data.
Definition wavetable.h:39