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

Function makeCrashCymbal

tests/fl/audio/test_helpers.h:460–474  ·  view source on GitHub ↗

Generate a synthetic crash cymbal: broadband noise with 80ms decay All treble bins have similar energy (high flatness)

Source from the content-addressed store, hash-verified

458/// Generate a synthetic crash cymbal: broadband noise with 80ms decay
459/// All treble bins have similar energy (high flatness)
460inline Sample makeCrashCymbal(fl::u32 timestamp, float amplitude = 16000.0f,
461 int count = 512, float sampleRate = 44100.0f) {
462 fl::fl_random rng(77); // Deterministic seed
463 fl::vector<fl::i16> data(count, 0);
464 for (int i = 0; i < count; ++i) {
465 float t = static_cast<float>(i) / sampleRate;
466 float decay = fl::expf(-t / 0.080f);
467 float noiseVal = (static_cast<float>(rng.random16()) / 32767.5f) - 1.0f;
468 float sample = amplitude * decay * noiseVal;
469 if (sample > 32767.0f) sample = 32767.0f;
470 if (sample < -32768.0f) sample = -32768.0f;
471 data[i] = static_cast<fl::i16>(sample);
472 }
473 return Sample(data, timestamp);
474}
475
476// ============================================================================
477// Realistic Instrument Generators (calibrated to match real audio features)

Callers

nothing calls this directly

Calls 3

expfFunction · 0.85
random16Method · 0.80
SampleClass · 0.50

Tested by

no test coverage detected