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

Function generateSine

tests/profile/fft_cq_compare.cpp:79–87  ·  view source on GitHub ↗

Generate a pure sine wave at a specific frequency

Source from the content-addressed store, hash-verified

77
78// Generate a pure sine wave at a specific frequency
79static void generateSine(fl::vector<fl::i16> &buf, int samples,
80 int sampleRate, float freq) {
81 buf.resize(samples);
82 for (int i = 0; i < samples; i++) {
83 float t = static_cast<float>(i) / static_cast<float>(sampleRate);
84 float s = fl::sinf(2.0f * static_cast<float>(FL_M_PI) * freq * t);
85 buf[i] = static_cast<fl::i16>(s * 30000.0f);
86 }
87}
88
89struct BenchResult {
90 const char *name;

Callers 1

runAccuracyTestFunction · 0.70

Calls 2

sinfFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected