| 40 | } |
| 41 | |
| 42 | std::vector<float> tone(int sample_rate, int samples, float base_hz) { |
| 43 | constexpr float kPi = 3.14159265358979323846f; |
| 44 | std::vector<float> output(static_cast<size_t>(samples), 0.0f); |
| 45 | for (int i = 0; i < samples; ++i) { |
| 46 | const float t = static_cast<float>(i) / static_cast<float>(sample_rate); |
| 47 | output[static_cast<size_t>(i)] = |
| 48 | 0.18f * std::sin(2.0f * kPi * base_hz * t) + |
| 49 | 0.04f * std::sin(2.0f * kPi * (base_hz * 2.7f) * t + 0.31f); |
| 50 | } |
| 51 | return output; |
| 52 | } |
| 53 | |
| 54 | void require_wav_shape(const std::filesystem::path & path, int sample_rate) { |
| 55 | const auto wav = engine::audio::read_wav_f32(path); |