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

◆ beatsin88()

LIB8STATIC u16 fl::beatsin88 ( accum88 beats_per_minute_88,
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_minute_88the frequency of the wave, in Q8.8 format
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
Warning
The BPM parameter MUST be provided in Q8.8 format!

Definition at line 63 of file beat.h.

65 {
66 u16 beat = beat88(beats_per_minute_88, timebase);
67 u16 beatsin = (sin16(beat + phase_offset) + 32768);
68 u16 rangewidth = highest - lowest;
69 u16 scaledbeat = scale16(beatsin, rangewidth);
70 u16 result = lowest + scaledbeat;
71 if (result > highest) {
72 result = highest;
73 }
74 return result;
75}
LIB8STATIC u16 beat88(accum88 beats_per_minute_88, u32 timebase=0) FL_NOEXCEPT
Generates a 16-bit "sawtooth" wave at a given BPM, with BPM specified in Q8.8 fixed-point format.
Definition beat.h:26
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References beat88(), FL_NOEXCEPT, and LIB8STATIC.

Referenced by fl::Pacifica::draw(), and fl::Pride2015::draw().

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