pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 | |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 13 | |
kwiberg | dabf07f | 2016-02-17 07:59:48 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 16 | #include "webrtc/modules/audio_processing/vad/common.h" |
| 17 | #include "webrtc/modules/audio_processing/vad/gmm.h" |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 18 | #include "webrtc/typedefs.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class AudioFrame; |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 23 | class VadCircularBuffer; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 24 | |
| 25 | // Computes the probability of the input audio frame to be active given |
| 26 | // the corresponding pitch-gain and lag of the frame. |
| 27 | class PitchBasedVad { |
| 28 | public: |
| 29 | PitchBasedVad(); |
| 30 | ~PitchBasedVad(); |
| 31 | |
| 32 | // Compute pitch-based voicing probability, given the features. |
| 33 | // features: a structure containing features required for computing voicing |
| 34 | // probabilities. |
| 35 | // |
| 36 | // p_combined: an array which contains the combined activity probabilities |
| 37 | // computed prior to the call of this function. The method, |
| 38 | // then, computes the voicing probabilities and combine them |
| 39 | // with the given values. The result are returned in |p|. |
| 40 | int VoicingProbability(const AudioFeatures& features, double* p_combined); |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 41 | |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 42 | private: |
| 43 | int UpdatePrior(double p); |
| 44 | |
| 45 | // TODO(turajs): maybe defining this at a higher level (maybe enum) so that |
| 46 | // all the code recognize it as "no-error." |
| 47 | static const int kNoError = 0; |
| 48 | |
| 49 | GmmParameters noise_gmm_; |
| 50 | GmmParameters voice_gmm_; |
| 51 | |
| 52 | double p_prior_; |
| 53 | |
kwiberg | dabf07f | 2016-02-17 07:59:48 -0800 | [diff] [blame] | 54 | std::unique_ptr<VadCircularBuffer> circular_buffer_; |
pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace webrtc |
aluebs | ecf6b81 | 2015-06-25 12:28:48 -0700 | [diff] [blame] | 58 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_ |