OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS_H_ |
13 | 13 |
14 #include <complex> | 14 #include <complex> |
15 #include <memory> | |
16 #include <vector> | 15 #include <vector> |
17 | 16 |
18 namespace webrtc { | 17 namespace webrtc { |
19 | 18 |
20 namespace intelligibility { | 19 namespace intelligibility { |
21 | 20 |
22 // Internal helper for computing the power of a stream of arrays. | 21 // Internal helper for computing the power of a stream of arrays. |
23 // The result is an array of power per position: the i-th power is the power of | 22 // The result is an array of power per position: the i-th power is the power of |
24 // the stream of data on the i-th positions in the input arrays. | 23 // the stream of data on the i-th positions in the input arrays. |
25 template <typename T> | 24 template <typename T> |
(...skipping 22 matching lines...) Expand all Loading... |
48 class GainApplier { | 47 class GainApplier { |
49 public: | 48 public: |
50 GainApplier(size_t freqs, float relative_change_limit); | 49 GainApplier(size_t freqs, float relative_change_limit); |
51 | 50 |
52 // Copy |in_block| to |out_block|, multiplied by the current set of gains, | 51 // Copy |in_block| to |out_block|, multiplied by the current set of gains, |
53 // and step the current set of gains towards the target set. | 52 // and step the current set of gains towards the target set. |
54 void Apply(const std::complex<float>* in_block, | 53 void Apply(const std::complex<float>* in_block, |
55 std::complex<float>* out_block); | 54 std::complex<float>* out_block); |
56 | 55 |
57 // Return the current target gain set. Modify this array to set the targets. | 56 // Return the current target gain set. Modify this array to set the targets. |
58 float* target() const { return target_.get(); } | 57 float* target() { return target_.data(); } |
59 | 58 |
60 private: | 59 private: |
61 const size_t num_freqs_; | 60 const size_t num_freqs_; |
62 const float relative_change_limit_; | 61 const float relative_change_limit_; |
63 std::unique_ptr<float[]> target_; | 62 std::vector<float> target_; |
64 std::unique_ptr<float[]> current_; | 63 std::vector<float> current_; |
65 }; | 64 }; |
66 | 65 |
67 } // namespace intelligibility | 66 } // namespace intelligibility |
68 | 67 |
69 } // namespace webrtc | 68 } // namespace webrtc |
70 | 69 |
71 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS
_H_ | 70 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS
_H_ |
OLD | NEW |