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

◆ beatsin16()

LIB8STATIC u16 fl::beatsin16 ( accum88 beats_per_minute,
u16 lowest = 0,
u16 highest = 65535,
u32 timebase = 0,
u16 phase_offset = 0 )

Generates a 16-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 84 of file beat.h.

86 {
87 u16 beat = beat16(beats_per_minute, timebase);
88 u16 beatsin = (sin16(beat + phase_offset) + 32768);
89 u16 rangewidth = highest - lowest;
90 u16 scaledbeat = scale16(beatsin, rangewidth);
91 u16 result = lowest + scaledbeat;
92 if (result > highest) {
93 result = highest;
94 }
95 return result;
96}
LIB8STATIC u16 beat16(accum88 beats_per_minute, u32 timebase=0) FL_NOEXCEPT
Generates a 16-bit "sawtooth" wave at a given BPM.
Definition beat.h:41
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References beat16(), FL_NOEXCEPT, and LIB8STATIC.

Referenced by fl::Pacifica::draw(), fl::DemoReel100::juggle(), and fl::DemoReel100::sinelon().

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