Helper to check if waveform has significant variation (not all zeros or constant)
| 20 | |
| 21 | // Helper to check if waveform has significant variation (not all zeros or constant) |
| 22 | static bool hasVariation(const float* samples, int32_t count) { |
| 23 | if (count < 2) return false; |
| 24 | |
| 25 | float minVal = samples[0]; |
| 26 | float maxVal = samples[0]; |
| 27 | for (int32_t i = 1; i < count; ++i) { |
| 28 | if (samples[i] < minVal) minVal = samples[i]; |
| 29 | if (samples[i] > maxVal) maxVal = samples[i]; |
| 30 | } |
| 31 | |
| 32 | // Waveform should have at least some variation |
| 33 | return (maxVal - minVal) > 0.1f; |
| 34 | } |
| 35 | |
| 36 | } // anonymous namespace |
| 37 |