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

Function makeSample

tests/fl/audio/test_helpers.h:31–40  ·  view source on GitHub ↗

Generate a sine wave audio sample with specified frequency, timestamp, and amplitude @param freq Frequency in Hz (e.g., 440.0f for A4) @param timestamp Sample timestamp in milliseconds @param amplitude Peak amplitude (default: 16000 for typical test signal) @param count Number of samples (default: 512) @param sampleRate Sample rate in Hz (default: 44100) @return Sample containing the generated sin

Source from the content-addressed store, hash-verified

29/// @param sampleRate Sample rate in Hz (default: 44100)
30/// @return Sample containing the generated sine wave
31inline Sample makeSample(float freq, fl::u32 timestamp, float amplitude = 16000.0f,
32 int count = 512, float sampleRate = 44100.0f) {
33 fl::vector<fl::i16> data;
34 data.reserve(count);
35 for (int i = 0; i < count; ++i) {
36 float phase = 2.0f * FL_M_PI * freq * i / sampleRate;
37 data.push_back(static_cast<fl::i16>(amplitude * fl::sinf(phase)));
38 }
39 return Sample(data, timestamp);
40}
41
42/// Generate a silence audio sample (all zeros)
43/// @param timestamp Sample timestamp in milliseconds

Callers 15

makeSample_AdversarialFunction · 0.70
FL_TEST_FILEFunction · 0.70
FL_TEST_FILEFunction · 0.70
FL_TEST_FILEFunction · 0.70
makeSample_VocalDetectorFunction · 0.50
vocal.hppFile · 0.50
makeSample_BeatDetectorFunction · 0.50
makeBassSyncFunction · 0.50
beat.hppFile · 0.50
equalizer.hppFile · 0.50
percussion.hppFile · 0.50

Calls 4

sinfFunction · 0.85
SampleClass · 0.50
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected