blob: d9d68ecfdc514e3f3642d2a547e8456da4673efd [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_GMM_H_
12#define MODULES_AUDIO_PROCESSING_VAD_GMM_H_
pbos@webrtc.org788acd12014-12-15 09:41:24 +000013
14namespace webrtc {
15
16// A structure that specifies a GMM.
17// A GMM is formulated as
18// f(x) = w[0] * mixture[0] + w[1] * mixture[1] + ... +
19// w[num_mixtures - 1] * mixture[num_mixtures - 1];
20// Where a 'mixture' is a Gaussian density.
21
22struct GmmParameters {
Artem Titov0b489302021-07-28 20:50:03 +020023 // weight[n] = log(w[n]) - `dimension`/2 * log(2*pi) - 1/2 * log(det(cov[n]));
pbos@webrtc.org788acd12014-12-15 09:41:24 +000024 // where cov[n] is the covariance matrix of mixture n;
25 const double* weight;
Artem Titov0b489302021-07-28 20:50:03 +020026 // pointer to the first element of a `num_mixtures`x`dimension` matrix
pbos@webrtc.org788acd12014-12-15 09:41:24 +000027 // where kth row is the mean of the kth mixture.
28 const double* mean;
Artem Titov0b489302021-07-28 20:50:03 +020029 // pointer to the first element of a `num_mixtures`x`dimension`x`dimension`
pbos@webrtc.org788acd12014-12-15 09:41:24 +000030 // 3D-matrix, where the kth 2D-matrix is the inverse of the covariance
31 // matrix of the kth mixture.
32 const double* covar_inverse;
33 // Dimensionality of the mixtures.
34 int dimension;
35 // number of the mixtures.
36 int num_mixtures;
37};
38
Artem Titov0b489302021-07-28 20:50:03 +020039// Evaluate the given GMM, according to `gmm_parameters`, at the given point
40// `x`. If the dimensionality of the given GMM is larger that the maximum
pbos@webrtc.org788acd12014-12-15 09:41:24 +000041// acceptable dimension by the following function -1 is returned.
42double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters);
43
44} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020045#endif // MODULES_AUDIO_PROCESSING_VAD_GMM_H_