OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_MEAN_CALCULATOR_H_ | |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_MEAN_CALCULATOR_H_ | |
13 | |
14 #include <stddef.h> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 // MeanCalculator calculates the mean of a block of samples. Samples are added | |
minyue-webrtc
2016/03/21 15:27:52
This should be called BlockMeanCalculator. I will
| |
21 // one after another, and the mean is updated at the end of every block. | |
22 class BlockMeanCalculator { | |
23 public: | |
24 explicit BlockMeanCalculator(size_t block_length); | |
25 | |
26 // Reset. | |
27 void Reset(); | |
28 | |
29 // Add one sample to the sequence. | |
30 void AddSample(float sample); | |
31 | |
32 // Return the number of newly added samples since latest update on mean value. | |
33 size_t SamplesSinceLastUpdate() const; | |
34 | |
35 // Return the latest mean value. | |
36 float GetLatestMean() const; | |
37 | |
38 private: | |
39 // Clear all samples added. | |
40 void Clear(); | |
41 | |
42 const size_t block_length_; | |
43 size_t count_; | |
44 float sum_; | |
45 float mean_; | |
46 | |
47 RTC_DISALLOW_COPY_AND_ASSIGN(BlockMeanCalculator); | |
48 }; | |
49 | |
50 } // namespace webrtc | |
51 | |
52 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_MEAN_CALCULATOR_H_ | |
OLD | NEW |