| 684 | } |
| 685 | |
| 686 | fl::vector<fl::i16> makeTwoTone(float freq1, float freq2, int count = 512, |
| 687 | float sampleRate = 44100.0f, |
| 688 | float amplitude = 8000.0f) { |
| 689 | fl::vector<fl::i16> samples; |
| 690 | samples.reserve(count); |
| 691 | for (int i = 0; i < count; ++i) { |
| 692 | float t = static_cast<float>(i) / sampleRate; |
| 693 | float s = amplitude * fl::sinf(2.0f * FL_M_PI * freq1 * t) + |
| 694 | amplitude * fl::sinf(2.0f * FL_M_PI * freq2 * t); |
| 695 | if (s > 32767.0f) s = 32767.0f; |
| 696 | if (s < -32768.0f) s = -32768.0f; |
| 697 | samples.push_back(static_cast<fl::i16>(s)); |
| 698 | } |
| 699 | return samples; |
| 700 | } |
| 701 | |
| 702 | int findPeakBin(fl::span<const float> bins) { |
| 703 | int peak = 0; |
no test coverage detected