1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 12*d9f75844SAndroid Build Coastguard Worker #define MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker // A structure that specifies a GMM. 17*d9f75844SAndroid Build Coastguard Worker // A GMM is formulated as 18*d9f75844SAndroid Build Coastguard Worker // f(x) = w[0] * mixture[0] + w[1] * mixture[1] + ... + 19*d9f75844SAndroid Build Coastguard Worker // w[num_mixtures - 1] * mixture[num_mixtures - 1]; 20*d9f75844SAndroid Build Coastguard Worker // Where a 'mixture' is a Gaussian density. 21*d9f75844SAndroid Build Coastguard Worker 22*d9f75844SAndroid Build Coastguard Worker struct GmmParameters { 23*d9f75844SAndroid Build Coastguard Worker // weight[n] = log(w[n]) - `dimension`/2 * log(2*pi) - 1/2 * log(det(cov[n])); 24*d9f75844SAndroid Build Coastguard Worker // where cov[n] is the covariance matrix of mixture n; 25*d9f75844SAndroid Build Coastguard Worker const double* weight; 26*d9f75844SAndroid Build Coastguard Worker // pointer to the first element of a `num_mixtures`x`dimension` matrix 27*d9f75844SAndroid Build Coastguard Worker // where kth row is the mean of the kth mixture. 28*d9f75844SAndroid Build Coastguard Worker const double* mean; 29*d9f75844SAndroid Build Coastguard Worker // pointer to the first element of a `num_mixtures`x`dimension`x`dimension` 30*d9f75844SAndroid Build Coastguard Worker // 3D-matrix, where the kth 2D-matrix is the inverse of the covariance 31*d9f75844SAndroid Build Coastguard Worker // matrix of the kth mixture. 32*d9f75844SAndroid Build Coastguard Worker const double* covar_inverse; 33*d9f75844SAndroid Build Coastguard Worker // Dimensionality of the mixtures. 34*d9f75844SAndroid Build Coastguard Worker int dimension; 35*d9f75844SAndroid Build Coastguard Worker // number of the mixtures. 36*d9f75844SAndroid Build Coastguard Worker int num_mixtures; 37*d9f75844SAndroid Build Coastguard Worker }; 38*d9f75844SAndroid Build Coastguard Worker 39*d9f75844SAndroid Build Coastguard Worker // Evaluate the given GMM, according to `gmm_parameters`, at the given point 40*d9f75844SAndroid Build Coastguard Worker // `x`. If the dimensionality of the given GMM is larger that the maximum 41*d9f75844SAndroid Build Coastguard Worker // acceptable dimension by the following function -1 is returned. 42*d9f75844SAndroid Build Coastguard Worker double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters); 43*d9f75844SAndroid Build Coastguard Worker 44*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 45*d9f75844SAndroid Build Coastguard Worker #endif // MODULES_AUDIO_PROCESSING_VAD_GMM_H_ 46