| 102 | } |
| 103 | |
| 104 | float root_mean_square_or_throw(const std::vector<float> & samples) { |
| 105 | if (samples.empty()) { |
| 106 | throw std::runtime_error("RMS input samples must not be empty"); |
| 107 | } |
| 108 | double sum = 0.0; |
| 109 | for (const float sample : samples) { |
| 110 | sum += static_cast<double>(sample) * static_cast<double>(sample); |
| 111 | } |
| 112 | return static_cast<float>(std::sqrt(sum / static_cast<double>(samples.size()))); |
| 113 | } |
| 114 | |
| 115 | std::vector<int16_t> float_to_pcm16_clipped( |
| 116 | const std::vector<float> & samples, |
no test coverage detected