OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ |
13 | 13 |
14 #include <deque> | 14 #include <deque> |
| 15 #include <memory> |
15 #include <set> | 16 #include <set> |
16 | 17 |
17 #include "webrtc/base/gtest_prod_util.h" | 18 #include "webrtc/base/gtest_prod_util.h" |
18 #include "webrtc/base/scoped_ptr.h" | |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 class TransientDetector; | 23 class TransientDetector; |
24 | 24 |
25 // Detects transients in an audio stream and suppress them using a simple | 25 // Detects transients in an audio stream and suppress them using a simple |
26 // restoration algorithm that attenuates unexpected spikes in the spectrum. | 26 // restoration algorithm that attenuates unexpected spikes in the spectrum. |
27 class TransientSuppressor { | 27 class TransientSuppressor { |
28 public: | 28 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 void Suppress(float* in_ptr, float* spectral_mean, float* out_ptr); | 64 void Suppress(float* in_ptr, float* spectral_mean, float* out_ptr); |
65 | 65 |
66 void UpdateKeypress(bool key_pressed); | 66 void UpdateKeypress(bool key_pressed); |
67 void UpdateRestoration(float voice_probability); | 67 void UpdateRestoration(float voice_probability); |
68 | 68 |
69 void UpdateBuffers(float* data); | 69 void UpdateBuffers(float* data); |
70 | 70 |
71 void HardRestoration(float* spectral_mean); | 71 void HardRestoration(float* spectral_mean); |
72 void SoftRestoration(float* spectral_mean); | 72 void SoftRestoration(float* spectral_mean); |
73 | 73 |
74 rtc::scoped_ptr<TransientDetector> detector_; | 74 std::unique_ptr<TransientDetector> detector_; |
75 | 75 |
76 size_t data_length_; | 76 size_t data_length_; |
77 size_t detection_length_; | 77 size_t detection_length_; |
78 size_t analysis_length_; | 78 size_t analysis_length_; |
79 size_t buffer_delay_; | 79 size_t buffer_delay_; |
80 size_t complex_analysis_length_; | 80 size_t complex_analysis_length_; |
81 int num_channels_; | 81 int num_channels_; |
82 // Input buffer where the original samples are stored. | 82 // Input buffer where the original samples are stored. |
83 rtc::scoped_ptr<float[]> in_buffer_; | 83 std::unique_ptr<float[]> in_buffer_; |
84 rtc::scoped_ptr<float[]> detection_buffer_; | 84 std::unique_ptr<float[]> detection_buffer_; |
85 // Output buffer where the restored samples are stored. | 85 // Output buffer where the restored samples are stored. |
86 rtc::scoped_ptr<float[]> out_buffer_; | 86 std::unique_ptr<float[]> out_buffer_; |
87 | 87 |
88 // Arrays for fft. | 88 // Arrays for fft. |
89 rtc::scoped_ptr<size_t[]> ip_; | 89 std::unique_ptr<size_t[]> ip_; |
90 rtc::scoped_ptr<float[]> wfft_; | 90 std::unique_ptr<float[]> wfft_; |
91 | 91 |
92 rtc::scoped_ptr<float[]> spectral_mean_; | 92 std::unique_ptr<float[]> spectral_mean_; |
93 | 93 |
94 // Stores the data for the fft. | 94 // Stores the data for the fft. |
95 rtc::scoped_ptr<float[]> fft_buffer_; | 95 std::unique_ptr<float[]> fft_buffer_; |
96 | 96 |
97 rtc::scoped_ptr<float[]> magnitudes_; | 97 std::unique_ptr<float[]> magnitudes_; |
98 | 98 |
99 const float* window_; | 99 const float* window_; |
100 | 100 |
101 rtc::scoped_ptr<float[]> mean_factor_; | 101 std::unique_ptr<float[]> mean_factor_; |
102 | 102 |
103 float detector_smoothed_; | 103 float detector_smoothed_; |
104 | 104 |
105 int keypress_counter_; | 105 int keypress_counter_; |
106 int chunks_since_keypress_; | 106 int chunks_since_keypress_; |
107 bool detection_enabled_; | 107 bool detection_enabled_; |
108 bool suppression_enabled_; | 108 bool suppression_enabled_; |
109 | 109 |
110 bool use_hard_restoration_; | 110 bool use_hard_restoration_; |
111 int chunks_since_voice_change_; | 111 int chunks_since_voice_change_; |
112 | 112 |
113 uint32_t seed_; | 113 uint32_t seed_; |
114 | 114 |
115 bool using_reference_; | 115 bool using_reference_; |
116 }; | 116 }; |
117 | 117 |
118 } // namespace webrtc | 118 } // namespace webrtc |
119 | 119 |
120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ | 120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ |
OLD | NEW |