Generate a linear frequency sweep (chirp) with phase accumulation Tests that a sweeping tone doesn't trigger vocal detection
| 336 | /// Generate a linear frequency sweep (chirp) with phase accumulation |
| 337 | /// Tests that a sweeping tone doesn't trigger vocal detection |
| 338 | inline Sample makeChirp(float startFreq, float endFreq, u32 timestamp, |
| 339 | float amplitude = 16000.0f, int count = 512, |
| 340 | float sampleRate = 44100.0f) { |
| 341 | fl::vector<fl::i16> data; |
| 342 | data.reserve(count); |
| 343 | float phase = 0.0f; |
| 344 | for (int i = 0; i < count; ++i) { |
| 345 | float t = static_cast<float>(i) / static_cast<float>(count); |
| 346 | float freq = startFreq + (endFreq - startFreq) * t; |
| 347 | phase += 2.0f * FL_M_PI * freq / sampleRate; |
| 348 | data.push_back(static_cast<fl::i16>(amplitude * fl::sinf(phase))); |
| 349 | } |
| 350 | return Sample(data, timestamp); |
| 351 | } |
| 352 | |
| 353 | // ============================================================================ |
| 354 | // Percussion Signal Generators |