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

◆ beatsin88()

LIB8STATIC uint16_t beatsin88 ( accum88 beats_per_minute_88,
uint16_t lowest = 0,
uint16_t highest = 65535,
uint32_t timebase = 0,
uint16_t 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! E.g. for 120 BPM it would be 120*256 = 30720. If you just want to specify "120", use beatsin16() or beatsin8().
Examples
Pacifica.ino, and Pride2015.ino.

Definition at line 801 of file lib8tion.h.

803{
804 uint16_t beat = beat88( beats_per_minute_88, timebase);
805 uint16_t beatsin = (sin16( beat + phase_offset) + 32768);
806 uint16_t rangewidth = highest - lowest;
807 uint16_t scaledbeat = scale16( beatsin, rangewidth);
808 uint16_t result = lowest + scaledbeat;
809 return result;
810}
LIB8STATIC uint16_t beat88(accum88 beats_per_minute_88, uint32_t timebase=0)
Generates a 16-bit "sawtooth" wave at a given BPM, with BPM specified in Q8.8 fixed-point format.
Definition lib8tion.h:759
LIB8STATIC uint16_t scale16(uint16_t i, fract16 scale)
Scale a 16-bit unsigned value by an 16-bit value, which is treated as the numerator of a fraction who...
Definition scale8.h:551
#define sin16
Platform-independent alias of the fast sin implementation.
Definition trig8.h:112

References beat88(), LIB8STATIC, scale16(), and sin16.

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

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