Generate a synthetic audio buffer: mix of sine waves spanning the frequency range to exercise all CQ bins.
| 26 | // Generate a synthetic audio buffer: mix of sine waves spanning the |
| 27 | // frequency range to exercise all CQ bins. |
| 28 | static void generateTestSignal(fl::vector<fl::i16> &buf, int samples, |
| 29 | int sampleRate) { |
| 30 | buf.resize(samples); |
| 31 | const float freqs[] = {200.0f, 500.0f, 1200.0f, 3000.0f}; |
| 32 | const float amps[] = {0.4f, 0.3f, 0.2f, 0.1f}; |
| 33 | for (int i = 0; i < samples; i++) { |
| 34 | float t = static_cast<float>(i) / static_cast<float>(sampleRate); |
| 35 | float signal = 0.0f; |
| 36 | for (int f = 0; f < 4; f++) { |
| 37 | signal += |
| 38 | amps[f] * fl::sinf(2.0f * static_cast<float>(FL_M_PI) * freqs[f] * t); |
| 39 | } |
| 40 | buf[i] = static_cast<fl::i16>(signal * 25000.0f); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // Generate white noise (flat spectrum, equal energy per Hz) |
| 45 | static void generateWhiteNoise(fl::vector<fl::i16> &buf, int samples) { |
no test coverage detected