MCPcopy Create free account
hub / github.com/FastLED/FastLED / generateSine

Function generateSine

tests/profile/audio/pitch_sweep_test.cpp:41–50  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Sine-wave generator ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

39// Sine-wave generator
40// ---------------------------------------------------------------------------
41static void generateSine(fl::vector<fl::i16> &buf, int samples,
42 int sampleRate, float freq,
43 float amplitude = 30000.0f) {
44 buf.resize(samples);
45 for (int i = 0; i < samples; i++) {
46 float t = static_cast<float>(i) / static_cast<float>(sampleRate);
47 float s = fl::sinf(2.0f * static_cast<float>(FL_M_PI) * freq * t);
48 buf[i] = static_cast<fl::i16>(s * amplitude);
49 }
50}
51
52// ---------------------------------------------------------------------------
53// Helper: find peak bin

Callers 1

runSweepFunction · 0.70

Calls 2

sinfFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected