Initial import to Tizen
[profile/ivi/sphinxbase.git] / src / libsphinxbase / fe / fe_warp.h
1 /* ====================================================================
2  * Copyright (c) 2006 Carnegie Mellon University.  All rights 
3  * reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer. 
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * This work was supported in part by funding from the Defense Advanced 
18  * Research Projects Agency and the National Science Foundation of the 
19  * United States of America, and the CMU Sphinx Speech Consortium.
20  *
21  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
22  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
25  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * ====================================================================
34  *
35  */
36 \f
37 #ifndef FE_WARP_H
38 #define FE_WARP_H
39
40 #include "fe_internal.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 #if 0
46 /* Fool Emacs. */
47 }
48 #endif
49
50 #define FE_WARP_ID_INVERSE_LINEAR       0
51 #define FE_WARP_ID_AFFINE               1
52 #define FE_WARP_ID_PIECEWISE_LINEAR     2
53 #define FE_WARP_ID_EIDE_GISH            3
54 #define FE_WARP_ID_MAX                  2
55 #define FE_WARP_ID_NONE        0xffffffff
56
57 typedef struct {
58     void (*set_parameters)(char const *param_str, float sampling_rate);
59     const char * (*doc)(void);
60     uint32 (*id)(void);
61     uint32 (*n_param)(void);
62     float (*warped_to_unwarped)(float nonlinear);
63     float (*unwarped_to_warped)(float linear);
64     void (*print)(const char *label);
65 } fe_warp_conf_t;
66
67 int fe_warp_set(melfb_t *mel, const char *id_name);
68
69 uint32 fe_warp_id(melfb_t *mel);
70
71 const char * fe_warp_doc(melfb_t *mel);
72
73 void fe_warp_set_parameters(melfb_t *mel, char const *param_str, float sampling_rate);
74
75 uint32 fe_warp_n_param(melfb_t *mel);
76
77 float fe_warp_warped_to_unwarped(melfb_t *mel, float nonlinear);
78
79 float fe_warp_unwarped_to_warped(melfb_t *mel, float linear);
80
81 void fe_warp_print(melfb_t *mel, const char *label);
82
83 #define FE_WARP_NO_SIZE 0xffffffff
84
85 #ifdef __cplusplus
86 }
87 #endif
88
89
90 #endif /* FE_WARP_H */ 
91 \f
92 /*
93  * Log record.  Maintained by RCS.
94  *
95  * $Log: fe_warp.h,v $
96  * Revision 1.2  2006/02/17 00:31:34  egouvea
97  * Removed switch -melwarp. Changed the default for window length to
98  * 0.025625 from 0.256 (so that a window at 16kHz sampling rate has
99  * exactly 410 samples). Cleaned up include's. Replaced some E_FATAL()
100  * with E_WARN() and return.
101  *
102  * Revision 1.1  2006/02/16 00:18:26  egouvea
103  * Implemented flexible warping function. The user can specify at run
104  * time which of several shapes they want to use. Currently implemented
105  * are an affine function (y = ax + b), an inverse linear (y = a/x) and a
106  * piecewise linear (y = ax, up to a frequency F, and then it "breaks" so
107  * Nyquist frequency matches in both scales.
108  *
109  * Added two switches, -warp_type and -warp_params. The first specifies
110  * the type, which valid values:
111  *
112  * -inverse or inverse_linear
113  * -linear or affine
114  * -piecewise or piecewise_linear
115  *
116  * The inverse_linear is the same as implemented by EHT. The -mel_warp
117  * switch was kept for compatibility (maybe remove it in the
118  * future?). The code is compatible with EHT's changes: cepstra created
119  * from code after his changes should be the same as now. Scripts that
120  * worked with his changes should work now without changes. Tested a few
121  * cases, same results.
122  *
123  */