12#define INT16_POS (32767)
13#define INT16_NEG (-32768)
51 const float decay = 1.0f - 1.0f /
static_cast<float>(1 << damp);
120 FL_WARN(
"warning X value too high");
135 i32 mCourantSq32 =
static_cast<i32
>(
mCourantSq);
143 for (fl::size i = 1; i <
length + 1; i++) {
147 (i32)curr[i + 1] - ((i32)curr[i] << 1) + curr[i - 1];
156 i32 term =
static_cast<i32
>(
157 (
static_cast<i64>(mCourantSq32) * lap) >> 15);
161 i32 f = -(i32)next[i] + ((i32)curr[i] << 1) + term;
169 f =
static_cast<i32
>(
175 next[i] =
static_cast<i16
>(
fl::clamp(f, q15_min,
static_cast<i32
>(32767)));
214 FL_WARN(
"Out of range: " <<
x <<
", " <<
y);
223 FL_WARN(
"Out of range: " <<
x <<
", " <<
y);
227 return curr[(
y + 1) *
stride + (
x + 1)];
232 FL_WARN(
"Out of range: " <<
x <<
", " <<
y);
236 return prev[(
y + 1) *
stride + (
x + 1)];
250 FL_WARN(
"Out of range: " <<
x <<
", " <<
y);
262 for (fl::size j = 0; j <
height + 2; ++j) {
273 for (fl::size i = 0; i <
width + 2; ++i) {
278 i32 mCourantSq32 =
static_cast<i32
>(
mCourantSq);
298 for (fl::size j = 1; j <=
height; ++j) {
299 const fl::size row = j *
stride;
304 for (fl::size i = 1; i <=
width; ++i) {
305 const i32 c = row_curr[i];
313 const i32 diag = (i32)row_above[i - 1] + row_above[i + 1] +
314 row_below[i - 1] + row_below[i + 1];
315 const i32 nbr = (i32)row_above[i] + row_below[i] +
316 row_curr[i - 1] + row_curr[i + 1];
317 laplacian = diag + (nbr << 2) - 20 * c;
320 laplacian = (i32)row_curr[i + 1] + row_curr[i - 1] +
321 row_above[i] + row_below[i] - (c << 2);
328 i64 product =
static_cast<i64>(mCourantSq32) * laplacian;
336 term =
static_cast<i32
>((product >> 15) / 6);
338 term =
static_cast<i32
>(product >> 15);
341 i32 f = -(i32)row_next[i] + (c << 1) + term;
345 f =
static_cast<i32
>(
350 row_next[i] =
static_cast<i16
>(
fl::clamp(f, q15_min,
static_cast<i32
>(32767)));
i16 geti16(fl::size x) const
WaveSimulation1D_Real(u32 length, float speed=0.16f, int dampening=6) FL_NOEXCEPT
i16 geti16Previous(fl::size x) const
void set(fl::size x, float value)
void setDampening(int damp) FL_NOEXCEPT
bool has(fl::size x) const
int getDampenening() const
void setSpeed(float something)
float getf(fl::size x) const
void setf(fl::size x, fl::size y, float value)
i16 geti16Previous(fl::size x, fl::size y) const
i16 geti16(fl::size x, fl::size y) const
fl::vector_psram< i16 > grid1
int getDampenening() const
WaveSimulation2D_Real(u32 W, u32 H, float speed=0.16f, float dampening=6.0f) FL_NOEXCEPT
void setSpeed(float something)
LaplacianStencil mStencil
float getf(fl::size x, fl::size y) const
void seti16(fl::size x, fl::size y, i16 value)
bool has(fl::size x, fl::size y) const
fl::vector_psram< i16 > grid2
void setDampening(int damp) FL_NOEXCEPT
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
fl::UISlider dampening("Dampening", 6.0f, 0.0f, 10.0f, 0.1f)
i16 float_to_fixed(float f)
i16 compute_damp_decay_q15(int damp) FL_NOEXCEPT
float fixed_to_float(i16 f)
constexpr int type_rank< T >::value
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
Base definition for an LED controller.
#define FL_RESTRICT_PARAM