SphinxBase  5prealpha
agc.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*
38  * agc.h -- Various forms of automatic gain control (AGC)
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log$
49  * Revision 1.1 2006/04/05 20:27:30 dhdfu
50  * A Great Reorganzation of header files and executables
51  *
52  * Revision 1.8 2005/06/21 19:25:41 arthchan2003
53  * 1, Fixed doxygen documentation. 2, Added $ keyword.
54  *
55  * Revision 1.4 2005/06/13 04:02:56 archan
56  * Fixed most doxygen-style documentation under libs3decoder.
57  *
58  * Revision 1.3 2005/03/30 01:22:46 archan
59  * Fixed mistakes in last updates. Add
60  *
61  *
62  * 28-Apr-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
63  * Copied from previous version.
64  */
65 
66 
67 #ifndef _S3_AGC_H_
68 #define _S3_AGC_H_
69 
70 /* Win32/WinCE DLL gunk */
71 #include <sphinxbase/sphinxbase_export.h>
72 
73 #include <sphinxbase/prim_type.h>
74 #include <sphinxbase/fe.h>
75 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 #if 0
88 /* Fool Emacs. */
89 }
90 #endif
91 
95 typedef enum agc_type_e {
96  AGC_NONE = 0,
97  AGC_MAX,
98  AGC_EMAX,
99  AGC_NOISE
100 } agc_type_t;
101 
103 SPHINXBASE_EXPORT
104 agc_type_t agc_type_from_str(const char *str);
105 
107 SPHINXBASE_EXPORT
108 extern const char *agc_type_str[];
109 
113 typedef struct agc_s {
114  mfcc_t max;
115  mfcc_t obs_max;
116  int32 obs_frame;
117  int32 obs_utt;
118  mfcc_t obs_max_sum;
119  mfcc_t noise_thresh;
120 } agc_t;
121 
125 SPHINXBASE_EXPORT
126 agc_t *agc_init(void);
127 
131 SPHINXBASE_EXPORT
132 void agc_free(agc_t *agc);
133 
140 SPHINXBASE_EXPORT
141 void agc_max(agc_t *agc,
142  mfcc_t **mfc,
143  int32 n_frame
144  );
145 
151 SPHINXBASE_EXPORT
152 void agc_emax(agc_t *agc,
153  mfcc_t **mfc,
154  int32 n_frame
155  );
156 
160 SPHINXBASE_EXPORT
161 void agc_emax_update(agc_t *agc
162  );
163 
167 SPHINXBASE_EXPORT
168 float32 agc_emax_get(agc_t *agc);
169 
173 SPHINXBASE_EXPORT
174 void agc_emax_set(agc_t *agc, float32 m);
175 
179 SPHINXBASE_EXPORT
180 void agc_noise(agc_t *agc,
181  mfcc_t **mfc,
182  int32 n_frame
183  );
184 
188 SPHINXBASE_EXPORT
189 float32 agc_get_threshold(agc_t *agc);
190 
194 SPHINXBASE_EXPORT
195 void agc_set_threshold(agc_t *agc, float32 threshold);
196 
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif
SPHINXBASE_EXPORT float32 agc_get_threshold(agc_t *agc)
Get the current AGC noise threshold.
Definition: agc.c:224
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.
Definition: agc.c:180
mfcc_t max
Estimated max for current utterance (for AGC_EMAX)
Definition: agc.h:114
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...
Definition: agc.c:109
SPHINXBASE_EXPORT const char * agc_type_str[]
String representations of agc_type_t values.
Definition: agc.c:70
mfcc_t obs_max
Observed max in current utterance.
Definition: agc.h:115
int32 obs_frame
Whether any data was observed after prev update.
Definition: agc.h:116
Basic type definitions used in Sphinx.
SPHINXBASE_EXPORT agc_t * agc_init(void)
Initialize AGC structure with default values.
Definition: agc.c:91
SPHINXBASE_EXPORT void agc_free(agc_t *agc)
Free AGC structure.
Definition: agc.c:100
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.
Definition: agc.h:117
SPHINXBASE_EXPORT void agc_set_threshold(agc_t *agc, float32 threshold)
Set the current AGC noise threshold.
Definition: agc.c:218
mfcc_t noise_thresh
Noise threshold (for AGC_NOISE only)
Definition: agc.h:119
SPHINXBASE_EXPORT void agc_emax_set(agc_t *agc, float32 m)
Set the current AGC maximum estimate.
Definition: agc.c:129
struct agc_s agc_t
Structure holding data for doing AGC.
Structure holding data for doing AGC.
Definition: agc.h:113
SPHINXBASE_EXPORT void agc_emax_update(agc_t *agc)
Update AGC parameters for next utterance.
Definition: agc.c:159
SPHINXBASE_EXPORT void agc_emax(agc_t *agc, mfcc_t **mfc, int32 n_frame)
Apply AGC to the given block of MFC vectors.
Definition: agc.c:142
agc_type_e
Types of acoustic gain control to apply to the features.
Definition: agc.h:95
SPHINXBASE_EXPORT float32 agc_emax_get(agc_t *agc)
Get the current AGC maximum estimate.
Definition: agc.c:136
SPHINXBASE_EXPORT agc_type_t agc_type_from_str(const char *str)
Convert string representation (from command-line) to agc_type_t.
Definition: agc.c:79