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

Function makeChirp

tests/fl/audio/test_helpers.h:338–351  ·  view source on GitHub ↗

Generate a linear frequency sweep (chirp) with phase accumulation Tests that a sweeping tone doesn't trigger vocal detection

Source from the content-addressed store, hash-verified

336/// Generate a linear frequency sweep (chirp) with phase accumulation
337/// Tests that a sweeping tone doesn't trigger vocal detection
338inline 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

Callers 1

vocal.hppFile · 0.85

Calls 4

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

Tested by

no test coverage detected