MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / tone

Function tone

tests/unittests/test_audio_utility_api.cpp:42–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42std::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
54void require_wav_shape(const std::filesystem::path & path, int sample_rate) {
55 const auto wav = engine::audio::read_wav_f32(path);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected