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

◆ beatsin16()

LIB8STATIC uint16_t beatsin16 ( accum88 beats_per_minute,
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_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
Examples
DemoReel100.ino, and Pacifica.ino.

Definition at line 939 of file lib8tion.h.

941{
942 uint16_t beat = beat16( beats_per_minute, timebase);
943 uint16_t beatsin = (sin16( beat + phase_offset) + 32768);
944 uint16_t rangewidth = highest - lowest;
945 uint16_t scaledbeat = scale16( beatsin, rangewidth);
946 uint16_t result = lowest + scaledbeat;
947 return result;
948}
LIB8STATIC uint16_t beat16(accum88 beats_per_minute, uint32_t timebase=0)
Generates a 16-bit "sawtooth" wave at a given BPM.
Definition lib8tion.h:895
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:546
#define sin16
Platform-independent alias of the fast sin implementation.
Definition trig8.h:103

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

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

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