Generate a synthetic tom drum: single sine at tuning frequency, 60ms decay, NO click Discriminated from kick by absence of click transient
| 442 | /// Generate a synthetic tom drum: single sine at tuning frequency, 60ms decay, NO click |
| 443 | /// Discriminated from kick by absence of click transient |
| 444 | inline 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) |
no test coverage detected