FastLED 3.9.15
Loading...
Searching...
No Matches

◆ beatsin8()

LIB8STATIC uint8_t beatsin8 ( accum88 beats_per_minute,
uint8_t lowest = 0,
uint8_t highest = 255,
uint32_t timebase = 0,
uint8_t phase_offset = 0 )

Generates an 8-bit sine wave at a given BPM that oscillates within a given range.

Parameters
beats_per_minutethe frequency of the wave, in decimal
lowestthe lowest output value of the sine wave
highestthe highest output value of the sine wave
timebasethe time offset of the wave from the millis() timer
phase_offsetphase offset of the wave from the current position
Examples
DemoReel100.ino, and Pacifica.ino.

Definition at line 975 of file lib8tion.h.

977{
978 uint8_t beat = beat8( beats_per_minute, timebase);
979 uint8_t beatsin = sin8( beat + phase_offset);
980 uint8_t rangewidth = highest - lowest;
981 uint8_t scaledbeat = scale8( beatsin, rangewidth);
982 uint8_t result = lowest + scaledbeat;
983 return result;
984}
LIB8STATIC uint8_t beat8(accum88 beats_per_minute, uint32_t timebase=0)
Generates an 8-bit "sawtooth" wave at a given BPM.
Definition lib8tion.h:923
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Definition scale8.h:34
#define sin8
Platform-independent alias of the fast sin implementation.
Definition trig8.h:216

References beat8(), LIB8STATIC, scale8(), and sin8.

Referenced by bpm(), fl::DemoReel100::bpm(), fl::Pacifica::draw(), loop(), fl::Pacifica::pacifica_add_whitecaps(), pacifica_add_whitecaps(), and pacifica_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: