blob: 584dcc73ce737f036814a6e344edb321261c3ba9 [file] [log] [blame]
pbos@webrtc.org788acd12014-12-15 09:41:24 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
12#define MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
pbos@webrtc.org788acd12014-12-15 09:41:24 +000013
kwibergdabf07f2016-02-17 07:59:48 -080014#include <memory>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/audio_processing/vad/common.h"
17#include "modules/audio_processing/vad/gmm.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020018#include "typedefs.h" // NOLINT(build/include)
pbos@webrtc.org788acd12014-12-15 09:41:24 +000019
20namespace webrtc {
21
22class AudioFrame;
aluebsecf6b812015-06-25 12:28:48 -070023class VadCircularBuffer;
pbos@webrtc.org788acd12014-12-15 09:41:24 +000024
25// Computes the probability of the input audio frame to be active given
26// the corresponding pitch-gain and lag of the frame.
27class 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);
aluebsecf6b812015-06-25 12:28:48 -070041
pbos@webrtc.org788acd12014-12-15 09:41:24 +000042 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
kwibergdabf07f2016-02-17 07:59:48 -080054 std::unique_ptr<VadCircularBuffer> circular_buffer_;
pbos@webrtc.org788acd12014-12-15 09:41:24 +000055};
56
57} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020058#endif // MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_