blob: 4fb0c55d624b673df29a9100b37792144db687a7 [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
aluebsecf6b812015-06-25 12:28:48 -070011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
12#define WEBRTC_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
aluebsecf6b812015-06-25 12:28:48 -070016#include "webrtc/modules/audio_processing/vad/common.h"
17#include "webrtc/modules/audio_processing/vad/gmm.h"
pbos@webrtc.org788acd12014-12-15 09:41:24 +000018#include "webrtc/typedefs.h"
19
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
aluebsecf6b812015-06-25 12:28:48 -070058#endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_