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

Function makeTwoTone

tests/fl/audio/fft/fft.cpp:686–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686fl::vector<fl::i16> makeTwoTone(float freq1, float freq2, int count = 512,
687 float sampleRate = 44100.0f,
688 float amplitude = 8000.0f) {
689 fl::vector<fl::i16> samples;
690 samples.reserve(count);
691 for (int i = 0; i < count; ++i) {
692 float t = static_cast<float>(i) / sampleRate;
693 float s = amplitude * fl::sinf(2.0f * FL_M_PI * freq1 * t) +
694 amplitude * fl::sinf(2.0f * FL_M_PI * freq2 * t);
695 if (s > 32767.0f) s = 32767.0f;
696 if (s < -32768.0f) s = -32768.0f;
697 samples.push_back(static_cast<fl::i16>(s));
698 }
699 return samples;
700}
701
702int findPeakBin(fl::span<const float> bins) {
703 int peak = 0;

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 3

sinfFunction · 0.85
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected