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

◆ beatsin8()

LIB8STATIC u8 fl::beatsin8 ( accum88 beats_per_minute,
u8 lowest = 0,
u8 highest = 255,
u32 timebase = 0,
u8 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

Definition at line 105 of file beat.h.

107 {
108 u8 beat = beat8(beats_per_minute, timebase);
109 u8 beatsin = sin8(beat + phase_offset);
110 u8 rangewidth = highest - lowest;
111 u8 scaledbeat = scale8(beatsin, rangewidth);
112 u8 result = lowest + scaledbeat;
113 if (result > highest) {
114 result = highest;
115 }
116 return result;
117}
LIB8STATIC u8 beat8(accum88 beats_per_minute, u32 timebase=0) FL_NOEXCEPT
Generates an 8-bit "sawtooth" wave at a given BPM.
Definition beat.h:51
unsigned char u8
Definition stdint.h:131
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References beat8(), FL_NOEXCEPT, and LIB8STATIC.

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

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