1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #ifndef MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
- #define MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
- #include <stddef.h>
- #include <stdint.h>
- #include "absl/types/optional.h"
- #include "api/array_view.h"
- namespace webrtc {
- class RmsLevel {
- public:
- struct Levels {
- int average;
- int peak;
- };
- enum : int { kMinLevelDb = 127 };
- RmsLevel();
- ~RmsLevel();
-
-
- void Reset();
-
- void Analyze(rtc::ArrayView<const int16_t> data);
- void Analyze(rtc::ArrayView<const float> data);
-
-
- void AnalyzeMuted(size_t length);
-
-
-
-
- int Average();
-
-
- Levels AverageAndPeak();
- private:
-
-
- void CheckBlockSize(size_t block_size);
- float sum_square_;
- size_t sample_count_;
- float max_sum_square_;
- absl::optional<size_t> block_size_;
- };
- }
- #endif
|