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 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 13 14 namespace 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 22 struct GmmParameters { 23 // weight[n] = log(w[n]) - |dimension|/2 * log(2*pi) - 1/2 * log(det(cov[n])); 24 // where cov[n] is the covariance matrix of mixture n; 25 const double* weight; 26 // pointer to the first element of a |num_mixtures|x|dimension| matrix 27 // where kth row is the mean of the kth mixture. 28 const double* mean; 29 // pointer to the first element of a |num_mixtures|x|dimension|x|dimension| 30 // 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 39 // 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 41 // acceptable dimension by the following function -1 is returned. 42 double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters); 43 44 } // namespace webrtc 45 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 46