83 for (i = 0; i < n_agc_type_str; ++i) {
87 E_FATAL(
"Unknown AGC type '%s'\n", str);
116 for (i = 1; i < n_frame; i++) {
117 if (mfc[i][0] > agc->
obs_max) {
124 for (i = 0; i < n_frame; i++)
131 agc->
max = FLOAT2MFCC(m);
132 E_INFO(
"AGCEMax: max= %.2f\n", m);
138 return MFCC2FLOAT(agc->
max);
148 for (i = 0; i < n_frame; ++i) {
149 if (mfc[i][0] > agc->
obs_max) {
153 mfc[i][0] -= agc->
max;
162 agc->obs_max_sum += agc->
obs_max;
168 agc->obs_max_sum /= 2;
176 agc->
obs_max = FLOAT2MFCC(-1000.0);
190 min_energy = cep[0][0];
191 for (i = 0; i < nfr; ++i) {
192 if (cep[i][0] < min_energy)
193 min_energy = cep[i][0];
200 for (i = 0; i < nfr; ++i) {
201 if (cep[i][0] < min_energy) {
202 noise_level += cep[i][0];
207 if (noise_frames > 0) {
208 noise_level /= noise_frames;
209 E_INFO(
"AGC NOISE: max= %6.3f\n", MFCC2FLOAT(noise_level));
211 for (i = 0; i < nfr; i++) {
212 cep[i][0] -= noise_level;
SPHINXBASE_EXPORT float32 agc_get_threshold(agc_t *agc)
Get the current AGC noise threshold.
#define E_INFO(...)
Print logging information to standard error stream.
SPHINXBASE_EXPORT void agc_noise(agc_t *agc, mfcc_t **mfc, int32 n_frame)
Apply AGC using noise threshold to the given block of MFC vectors.
mfcc_t max
Estimated max for current utterance (for AGC_EMAX)
SPHINXBASE_EXPORT void agc_max(agc_t *agc, mfcc_t **mfc, int32 n_frame)
Apply AGC to the given mfc vectors (normalize all C0 mfc coefficients in the given input such that th...
routine that implements automatic gain control
#define ckd_calloc(n, sz)
Macros to simplify the use of above functions.
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT const char * agc_type_str[]
String representations of agc_type_t values.
mfcc_t obs_max
Observed max in current utterance.
int32 obs_frame
Whether any data was observed after prev update.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
SPHINXBASE_EXPORT agc_t * agc_init(void)
Initialize AGC structure with default values.
SPHINXBASE_EXPORT void agc_free(agc_t *agc)
Free AGC structure.
enum agc_type_e agc_type_t
Types of acoustic gain control to apply to the features.
int32 obs_utt
Whether any utterances have been observed.
SPHINXBASE_EXPORT void agc_set_threshold(agc_t *agc, float32 threshold)
Set the current AGC noise threshold.
mfcc_t noise_thresh
Noise threshold (for AGC_NOISE only)
SPHINXBASE_EXPORT void agc_emax_set(agc_t *agc, float32 m)
Set the current AGC maximum estimate.
Implementation of logging routines.
Structure holding data for doing AGC.
SPHINXBASE_EXPORT void agc_emax_update(agc_t *agc)
Update AGC parameters for next utterance.
SPHINXBASE_EXPORT void agc_emax(agc_t *agc, mfcc_t **mfc, int32 n_frame)
Apply AGC to the given block of MFC vectors.
#define E_FATAL(...)
Exit with non-zero status after error message.
SPHINXBASE_EXPORT float32 agc_emax_get(agc_t *agc)
Get the current AGC maximum estimate.
SPHINXBASE_EXPORT agc_type_t agc_type_from_str(const char *str)
Convert string representation (from command-line) to agc_type_t.