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

Function generateTestSignal

tests/profile/fft_cq_compare.cpp:28–42  ·  view source on GitHub ↗

Generate a synthetic audio buffer: mix of sine waves spanning the frequency range to exercise all CQ bins.

Source from the content-addressed store, hash-verified

26// Generate a synthetic audio buffer: mix of sine waves spanning the
27// frequency range to exercise all CQ bins.
28static void generateTestSignal(fl::vector<fl::i16> &buf, int samples,
29 int sampleRate) {
30 buf.resize(samples);
31 const float freqs[] = {200.0f, 500.0f, 1200.0f, 3000.0f};
32 const float amps[] = {0.4f, 0.3f, 0.2f, 0.1f};
33 for (int i = 0; i < samples; i++) {
34 float t = static_cast<float>(i) / static_cast<float>(sampleRate);
35 float signal = 0.0f;
36 for (int f = 0; f < 4; f++) {
37 signal +=
38 amps[f] * fl::sinf(2.0f * static_cast<float>(FL_M_PI) * freqs[f] * t);
39 }
40 buf[i] = static_cast<fl::i16>(signal * 25000.0f);
41 }
42}
43
44// Generate white noise (flat spectrum, equal energy per Hz)
45static void generateWhiteNoise(fl::vector<fl::i16> &buf, int samples) {

Callers 1

runBenchmarkFunction · 0.85

Calls 2

sinfFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected