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

Function makeTremoloTone

tests/fl/audio/test_helpers.h:621–633  ·  view source on GitHub ↗

Generate an AM-modulated sine (tremolo tone): amp * (1 - depth + depth*sin(2*pi*modRate*t)) * sin(2*pi*freq*t) Creates envelope jitter without formant structure. Tests jitter boost false positives.

Source from the content-addressed store, hash-verified

619/// amp * (1 - depth + depth*sin(2*pi*modRate*t)) * sin(2*pi*freq*t)
620/// Creates envelope jitter without formant structure. Tests jitter boost false positives.
621inline Sample makeTremoloTone(float freq, float modRate, float modDepth,
622 fl::u32 timestamp, float amplitude = 16000.0f,
623 int count = 512, float sampleRate = 44100.0f) {
624 fl::vector<fl::i16> data;
625 data.reserve(count);
626 for (int i = 0; i < count; ++i) {
627 float t = static_cast<float>(i) / sampleRate;
628 float envelope = 1.0f - modDepth + modDepth * fl::sinf(2.0f * FL_M_PI * modRate * t);
629 float sample = amplitude * envelope * fl::sinf(2.0f * FL_M_PI * freq * t);
630 data.push_back(static_cast<fl::i16>(fl::clamp(sample, -32768.0f, 32767.0f)));
631 }
632 return Sample(data, timestamp);
633}
634
635/// Generate bandpass-filtered noise: ~40 random-phase sinusoids between lowFreq-highFreq.
636/// Use makeFilteredNoise(200, 4000, ts) = speech-band noise.

Callers 1

vocal.hppFile · 0.85

Calls 5

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

Tested by

no test coverage detected