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.
| 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. |
| 621 | inline 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. |