FastLED 3.9.15
Loading...
Searching...
No Matches
noisegen.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "fl/stl/stdint.h"
7#include "noise.h"
8
9#include "fl/math/math.h"
10// Simple noise generator for 1-d waves. Default values will give good results
11// for most cases.
14 unsigned long time_multiplier;
15
17 NoiseGenerator(fl::i32 itScale, fl::i32 timeMul) : iteration_scale(itScale), time_multiplier(timeMul) {}
18
19 fl::u8 Value(fl::i32 i, unsigned long time_ms) const {
20 fl::u32 input = iteration_scale * i + time_ms * time_multiplier;
21 fl::u16 v1 = inoise16(input);
22 return fl::u8(v1 >> 8);
23 }
24
25 int LedValue(fl::i32 i, unsigned long time_ms) const {
26 int val = Value(i, time_ms);
27 return fl::max(0, val - 128) * 2;
28 }
29};
30
fl::u16 inoise16(fl::u32 x, fl::u32 y, fl::u32 z, fl::u32 t)
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
Functions to generate and fill arrays with noise.
NoiseGenerator(fl::i32 itScale, fl::i32 timeMul)
Definition noisegen.h:17
unsigned long time_multiplier
Definition noisegen.h:14
fl::i32 iteration_scale
Definition noisegen.h:13
fl::u8 Value(fl::i32 i, unsigned long time_ms) const
Definition noisegen.h:19
int LedValue(fl::i32 i, unsigned long time_ms) const
Definition noisegen.h:25