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

Function makeTom

tests/fl/audio/test_helpers.h:444–456  ·  view source on GitHub ↗

Generate a synthetic tom drum: single sine at tuning frequency, 60ms decay, NO click Discriminated from kick by absence of click transient

Source from the content-addressed store, hash-verified

442/// Generate a synthetic tom drum: single sine at tuning frequency, 60ms decay, NO click
443/// Discriminated from kick by absence of click transient
444inline Sample makeTom(fl::u32 timestamp, float tuningHz = 160.0f, float amplitude = 16000.0f,
445 int count = 512, float sampleRate = 44100.0f) {
446 fl::vector<fl::i16> data(count, 0);
447 for (int i = 0; i < count; ++i) {
448 float t = static_cast<float>(i) / sampleRate;
449 float decay = fl::expf(-t / 0.060f);
450 float sample = amplitude * decay * fl::sinf(2.0f * FL_M_PI * tuningHz * t);
451 if (sample > 32767.0f) sample = 32767.0f;
452 if (sample < -32768.0f) sample = -32768.0f;
453 data[i] = static_cast<fl::i16>(sample);
454 }
455 return Sample(data, timestamp);
456}
457
458/// Generate a synthetic crash cymbal: broadband noise with 80ms decay
459/// All treble bins have similar energy (high flatness)

Callers 1

percussion.hppFile · 0.85

Calls 3

expfFunction · 0.85
sinfFunction · 0.85
SampleClass · 0.50

Tested by

no test coverage detected