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

◆ beat88()

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.

Parameters
beats_per_minute_88the frequency of the wave, in Q8.8 format
timebasethe time offset of the wave from the millis() timer
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 beat16() or beat8().

Definition at line 897 of file lib8tion.h.

898{
899 // BPM is 'beats per minute', or 'beats per 60000ms'.
900 // To avoid using the (slower) division operator, we
901 // want to convert 'beats per 60000ms' to 'beats per 65536ms',
902 // and then use a simple, fast bit-shift to divide by 65536.
903 //
904 // The ratio 65536:60000 is 279.620266667:256; we'll call it 280:256.
905 // The conversion is accurate to about 0.05%, more or less,
906 // e.g. if you ask for "120 BPM", you'll get about "119.93".
907 return (((GET_MILLIS()) - timebase) * beats_per_minute_88 * 280) >> 16;
908}
#define GET_MILLIS
The a number of functions need access to a millisecond counter in order to keep time.
Definition lib8tion.h:837

References GET_MILLIS, and LIB8STATIC.

Referenced by beat16(), and beatsin88().

+ Here is the caller graph for this function: