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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // frequency bin to enhance speech against the noise background. | 29 // frequency bin to enhance speech against the noise background. |
30 // Details of the model and algorithm can be found in the original paper: | 30 // Details of the model and algorithm can be found in the original paper: |
31 // http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6882788 | 31 // http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6882788 |
32 class IntelligibilityEnhancer : public LappedTransform::Callback { | 32 class IntelligibilityEnhancer : public LappedTransform::Callback { |
33 public: | 33 public: |
34 IntelligibilityEnhancer(int sample_rate_hz, | 34 IntelligibilityEnhancer(int sample_rate_hz, |
35 size_t num_render_channels, | 35 size_t num_render_channels, |
36 size_t num_noise_bins); | 36 size_t num_noise_bins); |
37 | 37 |
38 // Sets the capture noise magnitude spectrum estimate. | 38 // Sets the capture noise magnitude spectrum estimate. |
39 void SetCaptureNoiseEstimate(std::vector<float> noise); | 39 void SetCaptureNoiseEstimate(std::vector<float> noise, int gain_db); |
40 | 40 |
41 // Reads chunk of speech in time domain and updates with modified signal. | 41 // Reads chunk of speech in time domain and updates with modified signal. |
42 void ProcessRenderAudio(float* const* audio, | 42 void ProcessRenderAudio(float* const* audio, |
43 int sample_rate_hz, | 43 int sample_rate_hz, |
44 size_t num_channels); | 44 size_t num_channels); |
45 bool active() const; | 45 bool active() const; |
46 | 46 |
47 protected: | 47 protected: |
48 // All in frequency domain, receives input |in_block|, applies | 48 // All in frequency domain, receives input |in_block|, applies |
49 // intelligibility enhancement, and writes result to |out_block|. | 49 // intelligibility enhancement, and writes result to |out_block|. |
50 void ProcessAudioBlock(const std::complex<float>* const* in_block, | 50 void ProcessAudioBlock(const std::complex<float>* const* in_block, |
51 size_t in_channels, | 51 size_t in_channels, |
52 size_t frames, | 52 size_t frames, |
53 size_t out_channels, | 53 size_t out_channels, |
54 std::complex<float>* const* out_block) override; | 54 std::complex<float>* const* out_block) override; |
55 | 55 |
56 private: | 56 private: |
57 FRIEND_TEST_ALL_PREFIXES(IntelligibilityEnhancerTest, TestErbCreation); | 57 FRIEND_TEST_ALL_PREFIXES(IntelligibilityEnhancerTest, TestErbCreation); |
58 FRIEND_TEST_ALL_PREFIXES(IntelligibilityEnhancerTest, TestSolveForGains); | 58 FRIEND_TEST_ALL_PREFIXES(IntelligibilityEnhancerTest, TestSolveForGains); |
| 59 FRIEND_TEST_ALL_PREFIXES(IntelligibilityEnhancerTest, |
| 60 TestNoiseGainHasExpectedResult); |
59 | 61 |
60 // Updates the SNR estimation and enables or disables this component using a | 62 // Updates the SNR estimation and enables or disables this component using a |
61 // hysteresis. | 63 // hysteresis. |
62 void SnrBasedEffectActivation(); | 64 void SnrBasedEffectActivation(); |
63 | 65 |
64 // Bisection search for optimal |lambda|. | 66 // Bisection search for optimal |lambda|. |
65 void SolveForLambda(float power_target); | 67 void SolveForLambda(float power_target); |
66 | 68 |
67 // Transforms freq gains to ERB gains. | 69 // Transforms freq gains to ERB gains. |
68 void UpdateErbGains(); | 70 void UpdateErbGains(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 bool is_active_; | 113 bool is_active_; |
112 | 114 |
113 std::vector<float> noise_estimation_buffer_; | 115 std::vector<float> noise_estimation_buffer_; |
114 SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>> | 116 SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>> |
115 noise_estimation_queue_; | 117 noise_estimation_queue_; |
116 }; | 118 }; |
117 | 119 |
118 } // namespace webrtc | 120 } // namespace webrtc |
119 | 121 |
120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_ENHAN
CER_H_ | 122 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_ENHAN
CER_H_ |
OLD | NEW |