| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 kCaptureStream, // Noise stream. | 65 kCaptureStream, // Noise stream. |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Provides access point to the frequency domain. | 68 // Provides access point to the frequency domain. |
| 69 class TransformCallback : public LappedTransform::Callback { | 69 class TransformCallback : public LappedTransform::Callback { |
| 70 public: | 70 public: |
| 71 TransformCallback(IntelligibilityEnhancer* parent, AudioSource source); | 71 TransformCallback(IntelligibilityEnhancer* parent, AudioSource source); |
| 72 | 72 |
| 73 // All in frequency domain, receives input |in_block|, applies | 73 // All in frequency domain, receives input |in_block|, applies |
| 74 // intelligibility enhancement, and writes result to |out_block|. | 74 // intelligibility enhancement, and writes result to |out_block|. |
| 75 virtual void ProcessAudioBlock(const std::complex<float>* const* in_block, | 75 void ProcessAudioBlock(const std::complex<float>* const* in_block, |
| 76 int in_channels, | 76 int in_channels, |
| 77 int frames, | 77 int frames, |
| 78 int out_channels, | 78 int out_channels, |
| 79 std::complex<float>* const* out_block); | 79 std::complex<float>* const* out_block) override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 IntelligibilityEnhancer* parent_; | 82 IntelligibilityEnhancer* parent_; |
| 83 AudioSource source_; | 83 AudioSource source_; |
| 84 }; | 84 }; |
| 85 friend class TransformCallback; | 85 friend class TransformCallback; |
| 86 | 86 |
| 87 // Sends streams to ProcessClearBlock or ProcessNoiseBlock based on source. | 87 // Sends streams to ProcessClearBlock or ProcessNoiseBlock based on source. |
| 88 void DispatchAudio(AudioSource source, | 88 void DispatchAudio(AudioSource source, |
| 89 const std::complex<float>* in_block, | 89 const std::complex<float>* in_block, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 111 // Negative gains are set to 0. Stores the results in |sols|. | 111 // Negative gains are set to 0. Stores the results in |sols|. |
| 112 void SolveForGainsGivenLambda(float lambda, int start_freq, float* sols); | 112 void SolveForGainsGivenLambda(float lambda, int start_freq, float* sols); |
| 113 | 113 |
| 114 // Computes variance across ERB filters from freq variance |var|. | 114 // Computes variance across ERB filters from freq variance |var|. |
| 115 // Stores in |result|. | 115 // Stores in |result|. |
| 116 void FilterVariance(const float* var, float* result); | 116 void FilterVariance(const float* var, float* result); |
| 117 | 117 |
| 118 // Returns dot product of vectors specified by size |length| arrays |a|,|b|. | 118 // Returns dot product of vectors specified by size |length| arrays |a|,|b|. |
| 119 static float DotProduct(const float* a, const float* b, int length); | 119 static float DotProduct(const float* a, const float* b, int length); |
| 120 | 120 |
| 121 static const int kErbResolution; | |
| 122 static const int kWindowSizeMs; | 121 static const int kWindowSizeMs; |
| 123 static const int kChunkSizeMs; | 122 static const int kChunkSizeMs; |
| 124 static const int kAnalyzeRate; // Default for |analysis_rate_|. | 123 static const int kAnalyzeRate; // Default for |analysis_rate_|. |
| 125 static const int kVarianceRate; // Default for |variance_rate_|. | 124 static const int kVarianceRate; // Default for |variance_rate_|. |
| 126 static const float kClipFreq; | 125 static const float kClipFreq; |
| 127 static const float kConfigRho; // Default production and interpretation SNR. | 126 static const float kConfigRho; // Default production and interpretation SNR. |
| 128 static const float kKbdAlpha; | 127 static const float kKbdAlpha; |
| 129 static const float kGainChangeLimit; | 128 static const float kGainChangeLimit; |
| 130 | 129 |
| 131 const int freqs_; // Num frequencies in frequency domain. | 130 const int freqs_; // Num frequencies in frequency domain. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Note: VAD currently does not affect anything in IntelligibilityEnhancer. | 168 // Note: VAD currently does not affect anything in IntelligibilityEnhancer. |
| 170 VadInst* vad_high_; | 169 VadInst* vad_high_; |
| 171 VadInst* vad_low_; | 170 VadInst* vad_low_; |
| 172 rtc::scoped_ptr<int16_t[]> vad_tmp_buffer_; | 171 rtc::scoped_ptr<int16_t[]> vad_tmp_buffer_; |
| 173 bool has_voice_low_; // Whether voice detected in speech stream. | 172 bool has_voice_low_; // Whether voice detected in speech stream. |
| 174 }; | 173 }; |
| 175 | 174 |
| 176 } // namespace webrtc | 175 } // namespace webrtc |
| 177 | 176 |
| 178 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_ENHAN
CER_H_ | 177 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_ENHAN
CER_H_ |
| OLD | NEW |