<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>SphinxBase: src/libsphinxbase/feat/feat.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">SphinxBase <span id="projectnumber">0.6</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('feat_8c.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <h1>src/libsphinxbase/feat/feat.c</h1> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */</span> <a name="l00002"></a>00002 <span class="comment">/* ====================================================================</span> <a name="l00003"></a>00003 <span class="comment"> * Copyright (c) 1999-2004 Carnegie Mellon University. All rights</span> <a name="l00004"></a>00004 <span class="comment"> * reserved.</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span> <a name="l00007"></a>00007 <span class="comment"> * modification, are permitted provided that the following conditions</span> <a name="l00008"></a>00008 <span class="comment"> * are met:</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span> <a name="l00011"></a>00011 <span class="comment"> * notice, this list of conditions and the following disclaimer. </span> <a name="l00012"></a>00012 <span class="comment"> *</span> <a name="l00013"></a>00013 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span> <a name="l00014"></a>00014 <span class="comment"> * notice, this list of conditions and the following disclaimer in</span> <a name="l00015"></a>00015 <span class="comment"> * the documentation and/or other materials provided with the</span> <a name="l00016"></a>00016 <span class="comment"> * distribution.</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> * This work was supported in part by funding from the Defense Advanced </span> <a name="l00019"></a>00019 <span class="comment"> * Research Projects Agency and the National Science Foundation of the </span> <a name="l00020"></a>00020 <span class="comment"> * United States of America, and the CMU Sphinx Speech Consortium.</span> <a name="l00021"></a>00021 <span class="comment"> *</span> <a name="l00022"></a>00022 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND </span> <a name="l00023"></a>00023 <span class="comment"> * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, </span> <a name="l00024"></a>00024 <span class="comment"> * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR</span> <a name="l00025"></a>00025 <span class="comment"> * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY</span> <a name="l00026"></a>00026 <span class="comment"> * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span> <a name="l00027"></a>00027 <span class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT </span> <a name="l00028"></a>00028 <span class="comment"> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, </span> <a name="l00029"></a>00029 <span class="comment"> * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY </span> <a name="l00030"></a>00030 <span class="comment"> * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT </span> <a name="l00031"></a>00031 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </span> <a name="l00032"></a>00032 <span class="comment"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00033"></a>00033 <span class="comment"> *</span> <a name="l00034"></a>00034 <span class="comment"> * ====================================================================</span> <a name="l00035"></a>00035 <span class="comment"> *</span> <a name="l00036"></a>00036 <span class="comment"> */</span> <a name="l00037"></a>00037 <span class="comment">/*</span> <a name="l00038"></a>00038 <span class="comment"> * feat.c -- Feature vector description and cepstra->feature computation.</span> <a name="l00039"></a>00039 <span class="comment"> *</span> <a name="l00040"></a>00040 <span class="comment"> * **********************************************</span> <a name="l00041"></a>00041 <span class="comment"> * CMU ARPA Speech Project</span> <a name="l00042"></a>00042 <span class="comment"> *</span> <a name="l00043"></a>00043 <span class="comment"> * Copyright (c) 1996 Carnegie Mellon University.</span> <a name="l00044"></a>00044 <span class="comment"> * ALL RIGHTS RESERVED.</span> <a name="l00045"></a>00045 <span class="comment"> * **********************************************</span> <a name="l00046"></a>00046 <span class="comment"> * </span> <a name="l00047"></a>00047 <span class="comment"> * HISTORY</span> <a name="l00048"></a>00048 <span class="comment"> * $Log$</span> <a name="l00049"></a>00049 <span class="comment"> * Revision 1.22 2006/02/23 03:59:40 arthchan2003</span> <a name="l00050"></a>00050 <span class="comment"> * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: a, Free buffers correctly. b, Fixed dox-doc.</span> <a name="l00051"></a>00051 <span class="comment"> * </span> <a name="l00052"></a>00052 <span class="comment"> * Revision 1.21.4.3 2005/10/17 04:45:57 arthchan2003</span> <a name="l00053"></a>00053 <span class="comment"> * Free stuffs in cmn and feat corectly.</span> <a name="l00054"></a>00054 <span class="comment"> *</span> <a name="l00055"></a>00055 <span class="comment"> * Revision 1.21.4.2 2005/09/26 02:19:57 arthchan2003</span> <a name="l00056"></a>00056 <span class="comment"> * Add message to show the directory which the feature is searched for.</span> <a name="l00057"></a>00057 <span class="comment"> *</span> <a name="l00058"></a>00058 <span class="comment"> * Revision 1.21.4.1 2005/07/03 22:55:50 arthchan2003</span> <a name="l00059"></a>00059 <span class="comment"> * More correct deallocation in feat.c. The cmn deallocation is still not correct at this point.</span> <a name="l00060"></a>00060 <span class="comment"> *</span> <a name="l00061"></a>00061 <span class="comment"> * Revision 1.21 2005/06/22 03:29:35 arthchan2003</span> <a name="l00062"></a>00062 <span class="comment"> * Makefile.am s for all subdirectory of libs3decoder/</span> <a name="l00063"></a>00063 <span class="comment"> *</span> <a name="l00064"></a>00064 <span class="comment"> * Revision 1.4 2005/04/21 23:50:26 archan</span> <a name="l00065"></a>00065 <span class="comment"> * Some more refactoring on the how reporting of structures inside kbcore_t is done, it is now 50% nice. Also added class-based LM test case into test-decode.sh.in. At this moment, everything in search mode 5 is already done. It is time to test the idea whether the search can really be used.</span> <a name="l00066"></a>00066 <span class="comment"> *</span> <a name="l00067"></a>00067 <span class="comment"> * Revision 1.3 2005/03/30 01:22:46 archan</span> <a name="l00068"></a>00068 <span class="comment"> * Fixed mistakes in last updates. Add</span> <a name="l00069"></a>00069 <span class="comment"> *</span> <a name="l00070"></a>00070 <span class="comment"> * </span> <a name="l00071"></a>00071 <span class="comment"> * 20.Apr.2001 RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)</span> <a name="l00072"></a>00072 <span class="comment"> * Adding feat_free() to free allocated memory</span> <a name="l00073"></a>00073 <span class="comment"> *</span> <a name="l00074"></a>00074 <span class="comment"> * 02-Jan-2001 Rita Singh (rsingh@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00075"></a>00075 <span class="comment"> * Modified feat_s2mfc2feat_block() to handle empty buffers at</span> <a name="l00076"></a>00076 <span class="comment"> * the end of an utterance</span> <a name="l00077"></a>00077 <span class="comment"> *</span> <a name="l00078"></a>00078 <span class="comment"> * 30-Dec-2000 Rita Singh (rsingh@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00079"></a>00079 <span class="comment"> * Added feat_s2mfc2feat_block() to allow feature computation</span> <a name="l00080"></a>00080 <span class="comment"> * from sequences of blocks of cepstral vectors</span> <a name="l00081"></a>00081 <span class="comment"> *</span> <a name="l00082"></a>00082 <span class="comment"> * 12-Jun-98 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00083"></a>00083 <span class="comment"> * Major changes to accommodate arbitrary feature input types. Added</span> <a name="l00084"></a>00084 <span class="comment"> * feat_read(), moved various cep2feat functions from other files into</span> <a name="l00085"></a>00085 <span class="comment"> * this one. Also, made this module object-oriented with the feat_t type.</span> <a name="l00086"></a>00086 <span class="comment"> * Changed definition of s2mfc_read to let the caller manage MFC buffers.</span> <a name="l00087"></a>00087 <span class="comment"> * </span> <a name="l00088"></a>00088 <span class="comment"> * 03-Oct-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00089"></a>00089 <span class="comment"> * Added unistd.h include.</span> <a name="l00090"></a>00090 <span class="comment"> * </span> <a name="l00091"></a>00091 <span class="comment"> * 02-Oct-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00092"></a>00092 <span class="comment"> * Added check for sf argument to s2mfc_read being within file size.</span> <a name="l00093"></a>00093 <span class="comment"> * </span> <a name="l00094"></a>00094 <span class="comment"> * 18-Sep-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00095"></a>00095 <span class="comment"> * Added sf, ef parameters to s2mfc_read().</span> <a name="l00096"></a>00096 <span class="comment"> * </span> <a name="l00097"></a>00097 <span class="comment"> * 10-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00098"></a>00098 <span class="comment"> * Added feat_cepsize().</span> <a name="l00099"></a>00099 <span class="comment"> * Added different feature-handling (s2_4x, s3_1x39 at this point).</span> <a name="l00100"></a>00100 <span class="comment"> * Moved feature-dependent functions to feature-dependent files.</span> <a name="l00101"></a>00101 <span class="comment"> * </span> <a name="l00102"></a>00102 <span class="comment"> * 09-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00103"></a>00103 <span class="comment"> * Moved constant declarations from feat.h into here.</span> <a name="l00104"></a>00104 <span class="comment"> * </span> <a name="l00105"></a>00105 <span class="comment"> * 04-Nov-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University</span> <a name="l00106"></a>00106 <span class="comment"> * Created.</span> <a name="l00107"></a>00107 <span class="comment"> */</span> <a name="l00108"></a>00108 <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="comment">/*</span> <a name="l00111"></a>00111 <span class="comment"> * This module encapsulates different feature streams used by the Sphinx group. New</span> <a name="l00112"></a>00112 <span class="comment"> * stream types can be added by augmenting feat_init() and providing an accompanying</span> <a name="l00113"></a>00113 <span class="comment"> * compute_feat function. It also provides a "generic" feature vector definition for</span> <a name="l00114"></a>00114 <span class="comment"> * handling "arbitrary" speech input feature types (see the last section in feat_init()).</span> <a name="l00115"></a>00115 <span class="comment"> * In this case the speech input data should already be feature vectors; no computation,</span> <a name="l00116"></a>00116 <span class="comment"> * such as MFC->feature conversion, is available or needed.</span> <a name="l00117"></a>00117 <span class="comment"> */</span> <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="preprocessor">#include <assert.h></span> <a name="l00120"></a>00120 <span class="preprocessor">#include <string.h></span> <a name="l00121"></a>00121 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00122"></a>00122 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span> <a name="l00123"></a>00123 <span class="preprocessor">#endif</span> <a name="l00124"></a>00124 <span class="preprocessor"></span> <a name="l00125"></a>00125 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#pragma warning (disable: 4244 4996)</span> <a name="l00127"></a>00127 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00128"></a>00128 <span class="preprocessor"></span> <a name="l00129"></a>00129 <span class="preprocessor">#include "sphinxbase/fe.h"</span> <a name="l00130"></a>00130 <span class="preprocessor">#include "sphinxbase/feat.h"</span> <a name="l00131"></a>00131 <span class="preprocessor">#include "sphinxbase/bio.h"</span> <a name="l00132"></a>00132 <span class="preprocessor">#include "sphinxbase/pio.h"</span> <a name="l00133"></a>00133 <span class="preprocessor">#include "sphinxbase/cmn.h"</span> <a name="l00134"></a>00134 <span class="preprocessor">#include "sphinxbase/agc.h"</span> <a name="l00135"></a>00135 <span class="preprocessor">#include "sphinxbase/err.h"</span> <a name="l00136"></a>00136 <span class="preprocessor">#include "sphinxbase/ckd_alloc.h"</span> <a name="l00137"></a>00137 <span class="preprocessor">#include "sphinxbase/prim_type.h"</span> <a name="l00138"></a>00138 <span class="preprocessor">#include "sphinxbase/glist.h"</span> <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="preprocessor">#define FEAT_VERSION "1.0"</span> <a name="l00141"></a>00141 <span class="preprocessor"></span><span class="preprocessor">#define FEAT_DCEP_WIN 2</span> <a name="l00142"></a>00142 <span class="preprocessor"></span> <a name="l00143"></a>00143 <span class="preprocessor">#ifdef DUMP_FEATURES</span> <a name="l00144"></a>00144 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00145"></a>00145 cep_dump_dbg(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t **mfc, int32 nfr, <span class="keyword">const</span> <span class="keywordtype">char</span> *text) <a name="l00146"></a>00146 { <a name="l00147"></a>00147 int32 i, j; <a name="l00148"></a>00148 <a name="l00149"></a>00149 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a>(<span class="stringliteral">"%s\n"</span>, text); <a name="l00150"></a>00150 <span class="keywordflow">for</span> (i = 0; i < nfr; i++) { <a name="l00151"></a>00151 <span class="keywordflow">for</span> (j = 0; j < fcb->cepsize; j++) { <a name="l00152"></a>00152 fprintf(stderr, <span class="stringliteral">"%f "</span>, MFCC2FLOAT(mfc[i][j])); <a name="l00153"></a>00153 } <a name="l00154"></a>00154 fprintf(stderr, <span class="stringliteral">"\n"</span>); <a name="l00155"></a>00155 } <a name="l00156"></a>00156 } <a name="l00157"></a>00157 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00158"></a>00158 feat_print_dbg(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t ***feat, int32 nfr, <span class="keyword">const</span> <span class="keywordtype">char</span> *text) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a>(<span class="stringliteral">"%s\n"</span>, text); <a name="l00161"></a>00161 <a class="code" href="feat_8h.html#afeaef030a5ec32c2164b5bd55e912714" title="Print the given block of feature vectors to the given FILE.">feat_print</a>(fcb, feat, nfr, stderr); <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <span class="preprocessor">#else </span><span class="comment">/* !DUMP_FEATURES */</span> <a name="l00164"></a>00164 <span class="preprocessor">#define cep_dump_dbg(fcb,mfc,nfr,text)</span> <a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">#define feat_print_dbg(fcb,mfc,nfr,text)</span> <a name="l00166"></a>00166 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00167"></a>00167 <span class="preprocessor"></span> <a name="l00168"></a>00168 int32 ** <a name="l00169"></a><a class="code" href="feat_8h.html#a613aca09a7f45f5ddc550efe685cb83b">00169</a> <a class="code" href="feat_8h.html#a613aca09a7f45f5ddc550efe685cb83b" title="Parse subvector specification string.">parse_subvecs</a>(<span class="keywordtype">char</span> <span class="keyword">const</span> *str) <a name="l00170"></a>00170 { <a name="l00171"></a>00171 <span class="keywordtype">char</span> <span class="keyword">const</span> *strp; <a name="l00172"></a>00172 int32 n, n2, l; <a name="l00173"></a>00173 <a class="code" href="structgnode__s.html" title="A node in a generic list.">glist_t</a> dimlist; <span class="comment">/* List of dimensions in one subvector */</span> <a name="l00174"></a>00174 <a class="code" href="structgnode__s.html" title="A node in a generic list.">glist_t</a> veclist; <span class="comment">/* List of dimlists (subvectors) */</span> <a name="l00175"></a>00175 int32 **subvec; <a name="l00176"></a>00176 <a class="code" href="structgnode__s.html" title="A node in a generic list.">gnode_t</a> *gn, *gn2; <a name="l00177"></a>00177 <a name="l00178"></a>00178 veclist = NULL; <a name="l00179"></a>00179 <a name="l00180"></a>00180 strp = str; <a name="l00181"></a>00181 <span class="keywordflow">for</span> (;;) { <a name="l00182"></a>00182 dimlist = NULL; <a name="l00183"></a>00183 <a name="l00184"></a>00184 <span class="keywordflow">for</span> (;;) { <a name="l00185"></a>00185 <span class="keywordflow">if</span> (sscanf(strp, <span class="stringliteral">"%d%n"</span>, &n, &l) != 1) <a name="l00186"></a>00186 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': Couldn't read int32 @pos %d\n"</span>, str, <a name="l00187"></a>00187 strp - str); <a name="l00188"></a>00188 strp += l; <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordflow">if</span> (*strp == <span class="charliteral">'-'</span>) { <a name="l00191"></a>00191 strp++; <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keywordflow">if</span> (sscanf(strp, <span class="stringliteral">"%d%n"</span>, &n2, &l) != 1) <a name="l00194"></a>00194 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': Couldn't read int32 @pos %d\n"</span>, str, <a name="l00195"></a>00195 strp - str); <a name="l00196"></a>00196 strp += l; <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <span class="keywordflow">else</span> <a name="l00199"></a>00199 n2 = n; <a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="keywordflow">if</span> ((n < 0) || (n > n2)) <a name="l00202"></a>00202 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': Bad subrange spec ending @pos %d\n"</span>, str, <a name="l00203"></a>00203 strp - str); <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="keywordflow">for</span> (; n <= n2; n++) { <a name="l00206"></a>00206 <a class="code" href="structgnode__s.html" title="A node in a generic list.">gnode_t</a> *gn; <a name="l00207"></a>00207 <span class="keywordflow">for</span> (gn = dimlist; gn; gn = gnode_next(gn)) <a name="l00208"></a>00208 <span class="keywordflow">if</span> (gnode_int32(gn) == n) <a name="l00209"></a>00209 <span class="keywordflow">break</span>; <a name="l00210"></a>00210 <span class="keywordflow">if</span> (gn != NULL) <a name="l00211"></a>00211 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': Duplicate dimension ending @pos %d\n"</span>, <a name="l00212"></a>00212 str, strp - str); <a name="l00213"></a>00213 <a name="l00214"></a>00214 dimlist = <a class="code" href="glist_8h.html#a28adfcc24a784aaed1a0b3c4c4de4c42" title="Create and prepend a new list node containing an integer.">glist_add_int32</a>(dimlist, n); <a name="l00215"></a>00215 } <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keywordflow">if</span> ((*strp == <span class="charliteral">'\0'</span>) || (*strp == <span class="charliteral">'/'</span>)) <a name="l00218"></a>00218 <span class="keywordflow">break</span>; <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="keywordflow">if</span> (*strp != <span class="charliteral">','</span>) <a name="l00221"></a>00221 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': Bad delimiter @pos %d\n"</span>, str, strp - str); <a name="l00222"></a>00222 <a name="l00223"></a>00223 strp++; <a name="l00224"></a>00224 } <a name="l00225"></a>00225 <a name="l00226"></a>00226 veclist = <a class="code" href="glist_8h.html#a77a9c20b7df5a289477af405ab778377" title="Create and prepend a new list node, with the given user-defined data, at the HEAD of the given generi...">glist_add_ptr</a>(veclist, (<span class="keywordtype">void</span> *) dimlist); <a name="l00227"></a>00227 <a name="l00228"></a>00228 <span class="keywordflow">if</span> (*strp == <span class="charliteral">'\0'</span>) <a name="l00229"></a>00229 <span class="keywordflow">break</span>; <a name="l00230"></a>00230 <a name="l00231"></a>00231 assert(*strp == <span class="charliteral">'/'</span>); <a name="l00232"></a>00232 strp++; <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="comment">/* Convert the glists to arrays; remember the glists are in reverse order of the input! */</span> <a name="l00236"></a>00236 n = <a class="code" href="glist_8h.html#aeb046e39c540d2f5f792119ea0d24c48" title="Count the number of element in a given link list.">glist_count</a>(veclist); <span class="comment">/* #Subvectors */</span> <a name="l00237"></a>00237 subvec = (int32 **) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(n + 1, <span class="keyword">sizeof</span>(int32 *)); <span class="comment">/* +1 for sentinel */</span> <a name="l00238"></a>00238 subvec[n] = NULL; <span class="comment">/* sentinel */</span> <a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="keywordflow">for</span> (--n, gn = veclist; (n >= 0) && gn; gn = gnode_next(gn), --n) { <a name="l00241"></a>00241 gn2 = (<a class="code" href="structgnode__s.html" title="A node in a generic list.">glist_t</a>) <a class="code" href="glist_8h.html#ace56682f14d84cc456c805d26fd86734" title="Head of a list of gnodes.">gnode_ptr</a>(gn); <a name="l00242"></a>00242 <a name="l00243"></a>00243 n2 = <a class="code" href="glist_8h.html#aeb046e39c540d2f5f792119ea0d24c48" title="Count the number of element in a given link list.">glist_count</a>(gn2); <span class="comment">/* Length of this subvector */</span> <a name="l00244"></a>00244 <span class="keywordflow">if</span> (n2 <= 0) <a name="l00245"></a>00245 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"'%s': 0-length subvector\n"</span>, str); <a name="l00246"></a>00246 <a name="l00247"></a>00247 subvec[n] = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(n2 + 1, <span class="keyword">sizeof</span>(int32)); <span class="comment">/* +1 for sentinel */</span> <a name="l00248"></a>00248 subvec[n][n2] = -1; <span class="comment">/* sentinel */</span> <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="keywordflow">for</span> (--n2; (n2 >= 0) && gn2; gn2 = gnode_next(gn2), --n2) <a name="l00251"></a>00251 subvec[n][n2] = gnode_int32(gn2); <a name="l00252"></a>00252 assert((n2 < 0) && (!gn2)); <a name="l00253"></a>00253 } <a name="l00254"></a>00254 assert((n < 0) && (!gn)); <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="comment">/* Free the glists */</span> <a name="l00257"></a>00257 <span class="keywordflow">for</span> (gn = veclist; gn; gn = gnode_next(gn)) { <a name="l00258"></a>00258 gn2 = (<a class="code" href="structgnode__s.html" title="A node in a generic list.">glist_t</a>) <a class="code" href="glist_8h.html#ace56682f14d84cc456c805d26fd86734" title="Head of a list of gnodes.">gnode_ptr</a>(gn); <a name="l00259"></a>00259 <a class="code" href="glist_8h.html#a45380e15d2c33afc554fd60a8828580c" title="Free the given generic list; user-defined data contained within is not automatically freed...">glist_free</a>(gn2); <a name="l00260"></a>00260 } <a name="l00261"></a>00261 <a class="code" href="glist_8h.html#a45380e15d2c33afc554fd60a8828580c" title="Free the given generic list; user-defined data contained within is not automatically freed...">glist_free</a>(veclist); <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="keywordflow">return</span> subvec; <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="keywordtype">void</span> <a name="l00267"></a><a class="code" href="feat_8h.html#ad209a1028b315a96a3a2447eccdb8605">00267</a> <a class="code" href="feat_8h.html#ad209a1028b315a96a3a2447eccdb8605" title="Free array of subvector specs.">subvecs_free</a>(int32 **subvecs) <a name="l00268"></a>00268 { <a name="l00269"></a>00269 int32 **sv; <a name="l00270"></a>00270 <a name="l00271"></a>00271 <span class="keywordflow">for</span> (sv = subvecs; sv && *sv; ++sv) <a name="l00272"></a>00272 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(*sv); <a name="l00273"></a>00273 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(subvecs); <a name="l00274"></a>00274 } <a name="l00275"></a>00275 <a name="l00276"></a>00276 <span class="keywordtype">int</span> <a name="l00277"></a><a class="code" href="feat_8h.html#a9a79c7278d484fa8178cd7c06156b794">00277</a> <a class="code" href="feat_8h.html#a9a79c7278d484fa8178cd7c06156b794" title="Add a subvector specification to the feature module.">feat_set_subvecs</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, int32 **subvecs) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 int32 **sv; <a name="l00280"></a>00280 int32 n_sv, n_dim, i; <a name="l00281"></a>00281 <a name="l00282"></a>00282 <span class="keywordflow">if</span> (subvecs == NULL) { <a name="l00283"></a>00283 <a class="code" href="feat_8h.html#ad209a1028b315a96a3a2447eccdb8605" title="Free array of subvector specs.">subvecs_free</a>(fcb->subvecs); <a name="l00284"></a>00284 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(fcb->sv_buf); <a name="l00285"></a>00285 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(fcb->sv_len); <a name="l00286"></a>00286 fcb->n_sv = 0; <a name="l00287"></a>00287 fcb->subvecs = NULL; <a name="l00288"></a>00288 fcb->sv_len = NULL; <a name="l00289"></a>00289 fcb->sv_buf = NULL; <a name="l00290"></a>00290 fcb->sv_dim = 0; <a name="l00291"></a>00291 <span class="keywordflow">return</span> 0; <a name="l00292"></a>00292 } <a name="l00293"></a>00293 <a name="l00294"></a>00294 <span class="keywordflow">if</span> (fcb->n_stream != 1) { <a name="l00295"></a>00295 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"Subvector specifications require single-stream features!"</span>); <a name="l00296"></a>00296 <span class="keywordflow">return</span> -1; <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00299"></a>00299 n_sv = 0; <a name="l00300"></a>00300 n_dim = 0; <a name="l00301"></a>00301 <span class="keywordflow">for</span> (sv = subvecs; sv && *sv; ++sv) { <a name="l00302"></a>00302 int32 *d; <a name="l00303"></a>00303 <a name="l00304"></a>00304 <span class="keywordflow">for</span> (d = *sv; d && *d != -1; ++d) { <a name="l00305"></a>00305 ++n_dim; <a name="l00306"></a>00306 } <a name="l00307"></a>00307 ++n_sv; <a name="l00308"></a>00308 } <a name="l00309"></a>00309 <span class="keywordflow">if</span> (n_dim > <a class="code" href="feat_8h.html#a66dc16aeea4307bf36ec4e08e05d0c7c" title="Total dimensionality of feature output.">feat_dimension</a>(fcb)) { <a name="l00310"></a>00310 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"Total dimensionality of subvector specification %d "</span> <a name="l00311"></a>00311 <span class="stringliteral">"> feature dimensionality %d\n"</span>, n_dim, <a class="code" href="feat_8h.html#a66dc16aeea4307bf36ec4e08e05d0c7c" title="Total dimensionality of feature output.">feat_dimension</a>(fcb)); <a name="l00312"></a>00312 <span class="keywordflow">return</span> -1; <a name="l00313"></a>00313 } <a name="l00314"></a>00314 <a name="l00315"></a>00315 fcb->n_sv = n_sv; <a name="l00316"></a>00316 fcb->subvecs = subvecs; <a name="l00317"></a>00317 fcb->sv_len = <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(n_sv, <span class="keyword">sizeof</span>(*fcb->sv_len)); <a name="l00318"></a>00318 fcb->sv_buf = <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(n_dim, <span class="keyword">sizeof</span>(*fcb->sv_buf)); <a name="l00319"></a>00319 fcb->sv_dim = n_dim; <a name="l00320"></a>00320 <span class="keywordflow">for</span> (i = 0; i < n_sv; ++i) { <a name="l00321"></a>00321 int32 *d; <a name="l00322"></a>00322 <span class="keywordflow">for</span> (d = subvecs[i]; d && *d != -1; ++d) { <a name="l00323"></a>00323 ++fcb->sv_len[i]; <a name="l00324"></a>00324 } <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keywordflow">return</span> 0; <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <a name="l00333"></a>00333 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00334"></a>00334 feat_subvec_project(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t ***inout_feat, uint32 nfr) <a name="l00335"></a>00335 { <a name="l00336"></a>00336 uint32 i; <a name="l00337"></a>00337 <a name="l00338"></a>00338 <span class="keywordflow">if</span> (fcb->subvecs == NULL) <a name="l00339"></a>00339 <span class="keywordflow">return</span>; <a name="l00340"></a>00340 <span class="keywordflow">for</span> (i = 0; i < nfr; ++i) { <a name="l00341"></a>00341 mfcc_t *out; <a name="l00342"></a>00342 int32 j; <a name="l00343"></a>00343 <a name="l00344"></a>00344 out = fcb->sv_buf; <a name="l00345"></a>00345 <span class="keywordflow">for</span> (j = 0; j < fcb->n_sv; ++j) { <a name="l00346"></a>00346 int32 *d; <a name="l00347"></a>00347 <span class="keywordflow">for</span> (d = fcb->subvecs[j]; d && *d != -1; ++d) { <a name="l00348"></a>00348 *out++ = inout_feat[i][0][*d]; <a name="l00349"></a>00349 } <a name="l00350"></a>00350 } <a name="l00351"></a>00351 memcpy(inout_feat[i][0], fcb->sv_buf, fcb->sv_dim * <span class="keyword">sizeof</span>(*fcb->sv_buf)); <a name="l00352"></a>00352 } <a name="l00353"></a>00353 } <a name="l00354"></a>00354 <a name="l00355"></a>00355 mfcc_t *** <a name="l00356"></a><a class="code" href="feat_8h.html#a03071d6d5c6b233117871f583c258b1e">00356</a> <a class="code" href="feat_8h.html#a03071d6d5c6b233117871f583c258b1e" title="Allocate an array to hold several frames worth of feature vectors.">feat_array_alloc</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, int32 nfr) <a name="l00357"></a>00357 { <a name="l00358"></a>00358 int32 i, j, k; <a name="l00359"></a>00359 mfcc_t *data, *d, ***feat; <a name="l00360"></a>00360 <a name="l00361"></a>00361 assert(fcb); <a name="l00362"></a>00362 assert(nfr > 0); <a name="l00363"></a>00363 assert(<a class="code" href="feat_8h.html#a66dc16aeea4307bf36ec4e08e05d0c7c" title="Total dimensionality of feature output.">feat_dimension</a>(fcb) > 0); <a name="l00364"></a>00364 <a name="l00365"></a>00365 <span class="comment">/* Make sure to use the dimensionality of the features *before*</span> <a name="l00366"></a>00366 <span class="comment"> LDA and subvector projection. */</span> <a name="l00367"></a>00367 k = 0; <a name="l00368"></a>00368 <span class="keywordflow">for</span> (i = 0; i < fcb->n_stream; ++i) <a name="l00369"></a>00369 k += fcb->stream_len[i]; <a name="l00370"></a>00370 assert(k >= <a class="code" href="feat_8h.html#a66dc16aeea4307bf36ec4e08e05d0c7c" title="Total dimensionality of feature output.">feat_dimension</a>(fcb)); <a name="l00371"></a>00371 assert(k >= fcb->sv_dim); <a name="l00372"></a>00372 <a name="l00373"></a>00373 feat = <a name="l00374"></a>00374 (mfcc_t ***) <a class="code" href="ckd__alloc_8h.html#a949e7b50fcd9697b1563fa57f50e9c4f" title="Macro for __ckd_calloc_2d__.">ckd_calloc_2d</a>(nfr, <a class="code" href="feat_8h.html#abadd19e2cc72df33e81e9d73a7ddffdb" title="Number of streams or subvectors in feature output.">feat_dimension1</a>(fcb), <span class="keyword">sizeof</span>(mfcc_t *)); <a name="l00375"></a>00375 data = (mfcc_t *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(nfr * k, <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00376"></a>00376 <a name="l00377"></a>00377 <span class="keywordflow">for</span> (i = 0; i < nfr; i++) { <a name="l00378"></a>00378 d = data + i * k; <a name="l00379"></a>00379 <span class="keywordflow">for</span> (j = 0; j < <a class="code" href="feat_8h.html#abadd19e2cc72df33e81e9d73a7ddffdb" title="Number of streams or subvectors in feature output.">feat_dimension1</a>(fcb); j++) { <a name="l00380"></a>00380 feat[i][j] = d; <a name="l00381"></a>00381 d += <a class="code" href="feat_8h.html#a5bd29a80c7f23f281d55555757f97f34" title="Dimensionality of stream/subvector i in feature output.">feat_dimension2</a>(fcb, j); <a name="l00382"></a>00382 } <a name="l00383"></a>00383 } <a name="l00384"></a>00384 <a name="l00385"></a>00385 <span class="keywordflow">return</span> feat; <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <a name="l00388"></a>00388 <span class="keywordtype">void</span> <a name="l00389"></a><a class="code" href="feat_8h.html#ad5c87f80af670b7a949af65bc3ba82a8">00389</a> <a class="code" href="feat_8h.html#ad5c87f80af670b7a949af65bc3ba82a8" title="Free a buffer allocated with feat_array_alloc()">feat_array_free</a>(mfcc_t ***feat) <a name="l00390"></a>00390 { <a name="l00391"></a>00391 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(feat[0][0]); <a name="l00392"></a>00392 <a class="code" href="ckd__alloc_8h.html#a8246c071ac12e98b7e1df9fe6da15aef" title="Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.">ckd_free_2d</a>((<span class="keywordtype">void</span> **)feat); <a name="l00393"></a>00393 } <a name="l00394"></a>00394 <a name="l00395"></a>00395 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00396"></a>00396 feat_s2_4x_cep2feat(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00397"></a>00397 { <a name="l00398"></a>00398 mfcc_t *f; <a name="l00399"></a>00399 mfcc_t *w, *_w; <a name="l00400"></a>00400 mfcc_t *w1, *w_1, *_w1, *_w_1; <a name="l00401"></a>00401 mfcc_t d1, d2; <a name="l00402"></a>00402 int32 i, j; <a name="l00403"></a>00403 <a name="l00404"></a>00404 assert(fcb); <a name="l00405"></a>00405 assert(<a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) == 13); <a name="l00406"></a>00406 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 4); <a name="l00407"></a>00407 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 0) == 12); <a name="l00408"></a>00408 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 1) == 24); <a name="l00409"></a>00409 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 2) == 3); <a name="l00410"></a>00410 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 3) == 12); <a name="l00411"></a>00411 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == 4); <a name="l00412"></a>00412 <a name="l00413"></a>00413 <span class="comment">/* CEP; skip C0 */</span> <a name="l00414"></a>00414 memcpy(feat[0], mfc[0] + 1, (<a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="comment">/*</span> <a name="l00417"></a>00417 <span class="comment"> * DCEP(SHORT): mfc[2] - mfc[-2]</span> <a name="l00418"></a>00418 <span class="comment"> * DCEP(LONG): mfc[4] - mfc[-4]</span> <a name="l00419"></a>00419 <span class="comment"> */</span> <a name="l00420"></a>00420 w = mfc[2] + 1; <span class="comment">/* +1 to skip C0 */</span> <a name="l00421"></a>00421 _w = mfc[-2] + 1; <a name="l00422"></a>00422 <a name="l00423"></a>00423 f = feat[1]; <a name="l00424"></a>00424 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; i++) <span class="comment">/* Short-term */</span> <a name="l00425"></a>00425 f[i] = w[i] - _w[i]; <a name="l00426"></a>00426 <a name="l00427"></a>00427 w = mfc[4] + 1; <span class="comment">/* +1 to skip C0 */</span> <a name="l00428"></a>00428 _w = mfc[-4] + 1; <a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keywordflow">for</span> (j = 0; j < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; i++, j++) <span class="comment">/* Long-term */</span> <a name="l00431"></a>00431 f[i] = w[j] - _w[j]; <a name="l00432"></a>00432 <a name="l00433"></a>00433 <span class="comment">/* D2CEP: (mfc[3] - mfc[-1]) - (mfc[1] - mfc[-3]) */</span> <a name="l00434"></a>00434 w1 = mfc[3] + 1; <span class="comment">/* Final +1 to skip C0 */</span> <a name="l00435"></a>00435 _w1 = mfc[-1] + 1; <a name="l00436"></a>00436 w_1 = mfc[1] + 1; <a name="l00437"></a>00437 _w_1 = mfc[-3] + 1; <a name="l00438"></a>00438 <a name="l00439"></a>00439 f = feat[3]; <a name="l00440"></a>00440 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; i++) { <a name="l00441"></a>00441 d1 = w1[i] - _w1[i]; <a name="l00442"></a>00442 d2 = w_1[i] - _w_1[i]; <a name="l00443"></a>00443 <a name="l00444"></a>00444 f[i] = d1 - d2; <a name="l00445"></a>00445 } <a name="l00446"></a>00446 <a name="l00447"></a>00447 <span class="comment">/* POW: C0, DC0, D2C0; differences computed as above for rest of cep */</span> <a name="l00448"></a>00448 f = feat[2]; <a name="l00449"></a>00449 f[0] = mfc[0][0]; <a name="l00450"></a>00450 f[1] = mfc[2][0] - mfc[-2][0]; <a name="l00451"></a>00451 <a name="l00452"></a>00452 d1 = mfc[3][0] - mfc[-1][0]; <a name="l00453"></a>00453 d2 = mfc[1][0] - mfc[-3][0]; <a name="l00454"></a>00454 f[2] = d1 - d2; <a name="l00455"></a>00455 } <a name="l00456"></a>00456 <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00459"></a>00459 feat_s3_1x39_cep2feat(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00460"></a>00460 { <a name="l00461"></a>00461 mfcc_t *f; <a name="l00462"></a>00462 mfcc_t *w, *_w; <a name="l00463"></a>00463 mfcc_t *w1, *w_1, *_w1, *_w_1; <a name="l00464"></a>00464 mfcc_t d1, d2; <a name="l00465"></a>00465 int32 i; <a name="l00466"></a>00466 <a name="l00467"></a>00467 assert(fcb); <a name="l00468"></a>00468 assert(<a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) == 13); <a name="l00469"></a>00469 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00470"></a>00470 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 0) == 39); <a name="l00471"></a>00471 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == 3); <a name="l00472"></a>00472 <a name="l00473"></a>00473 <span class="comment">/* CEP; skip C0 */</span> <a name="l00474"></a>00474 memcpy(feat[0], mfc[0] + 1, (<a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00475"></a>00475 <span class="comment">/*</span> <a name="l00476"></a>00476 <span class="comment"> * DCEP: mfc[2] - mfc[-2];</span> <a name="l00477"></a>00477 <span class="comment"> */</span> <a name="l00478"></a>00478 f = feat[0] + <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; <a name="l00479"></a>00479 w = mfc[2] + 1; <span class="comment">/* +1 to skip C0 */</span> <a name="l00480"></a>00480 _w = mfc[-2] + 1; <a name="l00481"></a>00481 <a name="l00482"></a>00482 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; i++) <a name="l00483"></a>00483 f[i] = w[i] - _w[i]; <a name="l00484"></a>00484 <a name="l00485"></a>00485 <span class="comment">/* POW: C0, DC0, D2C0 */</span> <a name="l00486"></a>00486 f += <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; <a name="l00487"></a>00487 <a name="l00488"></a>00488 f[0] = mfc[0][0]; <a name="l00489"></a>00489 f[1] = mfc[2][0] - mfc[-2][0]; <a name="l00490"></a>00490 <a name="l00491"></a>00491 d1 = mfc[3][0] - mfc[-1][0]; <a name="l00492"></a>00492 d2 = mfc[1][0] - mfc[-3][0]; <a name="l00493"></a>00493 f[2] = d1 - d2; <a name="l00494"></a>00494 <a name="l00495"></a>00495 <span class="comment">/* D2CEP: (mfc[3] - mfc[-1]) - (mfc[1] - mfc[-3]) */</span> <a name="l00496"></a>00496 f += 3; <a name="l00497"></a>00497 <a name="l00498"></a>00498 w1 = mfc[3] + 1; <span class="comment">/* Final +1 to skip C0 */</span> <a name="l00499"></a>00499 _w1 = mfc[-1] + 1; <a name="l00500"></a>00500 w_1 = mfc[1] + 1; <a name="l00501"></a>00501 _w_1 = mfc[-3] + 1; <a name="l00502"></a>00502 <a name="l00503"></a>00503 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) - 1; i++) { <a name="l00504"></a>00504 d1 = w1[i] - _w1[i]; <a name="l00505"></a>00505 d2 = w_1[i] - _w_1[i]; <a name="l00506"></a>00506 <a name="l00507"></a>00507 f[i] = d1 - d2; <a name="l00508"></a>00508 } <a name="l00509"></a>00509 } <a name="l00510"></a>00510 <a name="l00511"></a>00511 <a name="l00512"></a>00512 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00513"></a>00513 feat_s3_cep(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00514"></a>00514 { <a name="l00515"></a>00515 assert(fcb); <a name="l00516"></a>00516 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00517"></a>00517 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == 0); <a name="l00518"></a>00518 <a name="l00519"></a>00519 <span class="comment">/* CEP */</span> <a name="l00520"></a>00520 memcpy(feat[0], mfc[0], <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00521"></a>00521 } <a name="l00522"></a>00522 <a name="l00523"></a>00523 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00524"></a>00524 feat_s3_cepwin(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00525"></a>00525 { <a name="l00526"></a>00526 assert(fcb); <a name="l00527"></a>00527 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00528"></a>00528 <a name="l00529"></a>00529 <span class="comment">/* CEP */</span> <a name="l00530"></a>00530 memcpy(feat[0], mfc[ -<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb)], <a name="l00531"></a>00531 (1 + 2 * <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a> (fcb)) * <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00532"></a>00532 } <a name="l00533"></a>00533 <a name="l00534"></a>00534 <a name="l00535"></a>00535 <a name="l00536"></a>00536 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00537"></a>00537 feat_s3_cep_dcep(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00538"></a>00538 { <a name="l00539"></a>00539 mfcc_t *f; <a name="l00540"></a>00540 mfcc_t *w, *_w; <a name="l00541"></a>00541 int32 i; <a name="l00542"></a>00542 <a name="l00543"></a>00543 assert(fcb); <a name="l00544"></a>00544 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00545"></a>00545 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 0) == <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * 2); <a name="l00546"></a>00546 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == 2); <a name="l00547"></a>00547 <a name="l00548"></a>00548 <span class="comment">/* CEP */</span> <a name="l00549"></a>00549 memcpy(feat[0], mfc[0], <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00550"></a>00550 <a name="l00551"></a>00551 <span class="comment">/*</span> <a name="l00552"></a>00552 <span class="comment"> * DCEP: mfc[2] - mfc[-2];</span> <a name="l00553"></a>00553 <span class="comment"> */</span> <a name="l00554"></a>00554 f = feat[0] + <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00555"></a>00555 w = mfc[2]; <a name="l00556"></a>00556 _w = mfc[-2]; <a name="l00557"></a>00557 <a name="l00558"></a>00558 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) <a name="l00559"></a>00559 f[i] = w[i] - _w[i]; <a name="l00560"></a>00560 } <a name="l00561"></a>00561 <a name="l00562"></a>00562 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00563"></a>00563 feat_1s_c_d_dd_cep2feat(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00564"></a>00564 { <a name="l00565"></a>00565 mfcc_t *f; <a name="l00566"></a>00566 mfcc_t *w, *_w; <a name="l00567"></a>00567 mfcc_t *w1, *w_1, *_w1, *_w_1; <a name="l00568"></a>00568 mfcc_t d1, d2; <a name="l00569"></a>00569 int32 i; <a name="l00570"></a>00570 <a name="l00571"></a>00571 assert(fcb); <a name="l00572"></a>00572 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00573"></a>00573 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 0) == <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * 3); <a name="l00574"></a>00574 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == FEAT_DCEP_WIN + 1); <a name="l00575"></a>00575 <a name="l00576"></a>00576 <span class="comment">/* CEP */</span> <a name="l00577"></a>00577 memcpy(feat[0], mfc[0], <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00578"></a>00578 <a name="l00579"></a>00579 <span class="comment">/*</span> <a name="l00580"></a>00580 <span class="comment"> * DCEP: mfc[w] - mfc[-w], where w = FEAT_DCEP_WIN;</span> <a name="l00581"></a>00581 <span class="comment"> */</span> <a name="l00582"></a>00582 f = feat[0] + <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00583"></a>00583 w = mfc[FEAT_DCEP_WIN]; <a name="l00584"></a>00584 _w = mfc[-FEAT_DCEP_WIN]; <a name="l00585"></a>00585 <a name="l00586"></a>00586 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) <a name="l00587"></a>00587 f[i] = w[i] - _w[i]; <a name="l00588"></a>00588 <a name="l00589"></a>00589 <span class="comment">/* </span> <a name="l00590"></a>00590 <span class="comment"> * D2CEP: (mfc[w+1] - mfc[-w+1]) - (mfc[w-1] - mfc[-w-1]), </span> <a name="l00591"></a>00591 <span class="comment"> * where w = FEAT_DCEP_WIN </span> <a name="l00592"></a>00592 <span class="comment"> */</span> <a name="l00593"></a>00593 f += <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00594"></a>00594 <a name="l00595"></a>00595 w1 = mfc[FEAT_DCEP_WIN + 1]; <a name="l00596"></a>00596 _w1 = mfc[-FEAT_DCEP_WIN + 1]; <a name="l00597"></a>00597 w_1 = mfc[FEAT_DCEP_WIN - 1]; <a name="l00598"></a>00598 _w_1 = mfc[-FEAT_DCEP_WIN - 1]; <a name="l00599"></a>00599 <a name="l00600"></a>00600 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) { <a name="l00601"></a>00601 d1 = w1[i] - _w1[i]; <a name="l00602"></a>00602 d2 = w_1[i] - _w_1[i]; <a name="l00603"></a>00603 <a name="l00604"></a>00604 f[i] = d1 - d2; <a name="l00605"></a>00605 } <a name="l00606"></a>00606 } <a name="l00607"></a>00607 <a name="l00608"></a>00608 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00609"></a>00609 feat_1s_c_d_ld_dd_cep2feat(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00610"></a>00610 { <a name="l00611"></a>00611 mfcc_t *f; <a name="l00612"></a>00612 mfcc_t *w, *_w; <a name="l00613"></a>00613 mfcc_t *w1, *w_1, *_w1, *_w_1; <a name="l00614"></a>00614 mfcc_t d1, d2; <a name="l00615"></a>00615 int32 i; <a name="l00616"></a>00616 <a name="l00617"></a>00617 assert(fcb); <a name="l00618"></a>00618 assert(<a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb) == 1); <a name="l00619"></a>00619 assert(<a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, 0) == <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * 4); <a name="l00620"></a>00620 assert(<a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) == FEAT_DCEP_WIN * 2); <a name="l00621"></a>00621 <a name="l00622"></a>00622 <span class="comment">/* CEP */</span> <a name="l00623"></a>00623 memcpy(feat[0], mfc[0], <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00624"></a>00624 <a name="l00625"></a>00625 <span class="comment">/*</span> <a name="l00626"></a>00626 <span class="comment"> * DCEP: mfc[w] - mfc[-w], where w = FEAT_DCEP_WIN;</span> <a name="l00627"></a>00627 <span class="comment"> */</span> <a name="l00628"></a>00628 f = feat[0] + <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00629"></a>00629 w = mfc[FEAT_DCEP_WIN]; <a name="l00630"></a>00630 _w = mfc[-FEAT_DCEP_WIN]; <a name="l00631"></a>00631 <a name="l00632"></a>00632 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) <a name="l00633"></a>00633 f[i] = w[i] - _w[i]; <a name="l00634"></a>00634 <a name="l00635"></a>00635 <span class="comment">/*</span> <a name="l00636"></a>00636 <span class="comment"> * LDCEP: mfc[w] - mfc[-w], where w = FEAT_DCEP_WIN * 2;</span> <a name="l00637"></a>00637 <span class="comment"> */</span> <a name="l00638"></a>00638 f += <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00639"></a>00639 w = mfc[FEAT_DCEP_WIN * 2]; <a name="l00640"></a>00640 _w = mfc[-FEAT_DCEP_WIN * 2]; <a name="l00641"></a>00641 <a name="l00642"></a>00642 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) <a name="l00643"></a>00643 f[i] = w[i] - _w[i]; <a name="l00644"></a>00644 <a name="l00645"></a>00645 <span class="comment">/* </span> <a name="l00646"></a>00646 <span class="comment"> * D2CEP: (mfc[w+1] - mfc[-w+1]) - (mfc[w-1] - mfc[-w-1]), </span> <a name="l00647"></a>00647 <span class="comment"> * where w = FEAT_DCEP_WIN </span> <a name="l00648"></a>00648 <span class="comment"> */</span> <a name="l00649"></a>00649 f += <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00650"></a>00650 <a name="l00651"></a>00651 w1 = mfc[FEAT_DCEP_WIN + 1]; <a name="l00652"></a>00652 _w1 = mfc[-FEAT_DCEP_WIN + 1]; <a name="l00653"></a>00653 w_1 = mfc[FEAT_DCEP_WIN - 1]; <a name="l00654"></a>00654 _w_1 = mfc[-FEAT_DCEP_WIN - 1]; <a name="l00655"></a>00655 <a name="l00656"></a>00656 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); i++) { <a name="l00657"></a>00657 d1 = w1[i] - _w1[i]; <a name="l00658"></a>00658 d2 = w_1[i] - _w_1[i]; <a name="l00659"></a>00659 <a name="l00660"></a>00660 f[i] = d1 - d2; <a name="l00661"></a>00661 } <a name="l00662"></a>00662 } <a name="l00663"></a>00663 <a name="l00664"></a>00664 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00665"></a>00665 feat_copy(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** mfc, mfcc_t ** feat) <a name="l00666"></a>00666 { <a name="l00667"></a>00667 int32 win, i, j; <a name="l00668"></a>00668 <a name="l00669"></a>00669 win = <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb); <a name="l00670"></a>00670 <a name="l00671"></a>00671 <span class="comment">/* Concatenate input features */</span> <a name="l00672"></a>00672 <span class="keywordflow">for</span> (i = -win; i <= win; ++i) { <a name="l00673"></a>00673 uint32 spos = 0; <a name="l00674"></a>00674 <a name="l00675"></a>00675 <span class="keywordflow">for</span> (j = 0; j < <a class="code" href="feat_8h.html#a1fe686c88d5b0598d7509af21acd9b76" title="Number of feature streams.">feat_n_stream</a>(fcb); ++j) { <a name="l00676"></a>00676 uint32 stream_len; <a name="l00677"></a>00677 <a name="l00678"></a>00678 <span class="comment">/* Unscale the stream length by the window. */</span> <a name="l00679"></a>00679 stream_len = <a class="code" href="feat_8h.html#a3d50283fc416fff87f3b907a12c2c11e" title="Length of feature stream i.">feat_stream_len</a>(fcb, j) / (2 * win + 1); <a name="l00680"></a>00680 memcpy(feat[j] + ((i + win) * stream_len), <a name="l00681"></a>00681 mfc[i] + spos, <a name="l00682"></a>00682 stream_len * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00683"></a>00683 spos += stream_len; <a name="l00684"></a>00684 } <a name="l00685"></a>00685 } <a name="l00686"></a>00686 } <a name="l00687"></a>00687 <a name="l00688"></a>00688 <a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * <a name="l00689"></a><a class="code" href="feat_8h.html#a7a5e2e02e99e368e1e9e3b1ded35e3dc">00689</a> <a class="code" href="feat_8h.html#a7a5e2e02e99e368e1e9e3b1ded35e3dc" title="Initialize feature module to use the selected type of feature stream.">feat_init</a>(<span class="keywordtype">char</span> <span class="keyword">const</span> *type, <a class="code" href="cmn_8h.html#a9384c411b10e9db9745cfb550a5c7652" title="Types of cepstral mean normalization to apply to the features.">cmn_type_t</a> cmn, int32 varnorm, <a name="l00690"></a>00690 <a class="code" href="agc_8h.html#a5524df49e0425cc6b1c002bc704a8103" title="Types of acoustic gain control to apply to the features.">agc_type_t</a> agc, int32 breport, int32 cepsize) <a name="l00691"></a>00691 { <a name="l00692"></a>00692 <a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb; <a name="l00693"></a>00693 <a name="l00694"></a>00694 <span class="keywordflow">if</span> (cepsize == 0) <a name="l00695"></a>00695 cepsize = 13; <a name="l00696"></a>00696 <span class="keywordflow">if</span> (breport) <a name="l00697"></a>00697 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a> <a name="l00698"></a>00698 (<span class="stringliteral">"Initializing feature stream to type: '%s', ceplen=%d, CMN='%s', VARNORM='%s', AGC='%s'\n"</span>, <a name="l00699"></a>00699 type, cepsize, <a class="code" href="cmn_8h.html#ae2ab0bad7168386076c43fc2a421867f" title="String representations of cmn_type_t values.">cmn_type_str</a>[cmn], varnorm ? <span class="stringliteral">"yes"</span> : <span class="stringliteral">"no"</span>, <a class="code" href="agc_8h.html#a6ea1b2b3d482cf08eb36084629503c80" title="String representations of agc_type_t values.">agc_type_str</a>[agc]); <a name="l00700"></a>00700 <a name="l00701"></a>00701 fcb = (<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a>)); <a name="l00702"></a>00702 fcb->refcount = 1; <a name="l00703"></a>00703 fcb->name = (<span class="keywordtype">char</span> *) <a class="code" href="ckd__alloc_8h.html#ad313f92478859f9e4ea99d0f6e78c393" title="Macro for __ckd_salloc__.">ckd_salloc</a>(type); <a name="l00704"></a>00704 <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"s2_4x"</span>) == 0) { <a name="l00705"></a>00705 <span class="comment">/* Sphinx-II format 4-stream feature (Hack!! hardwired constants below) */</span> <a name="l00706"></a>00706 <span class="keywordflow">if</span> (cepsize != 13) { <a name="l00707"></a>00707 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"s2_4x features require cepsize == 13\n"</span>); <a name="l00708"></a>00708 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(fcb); <a name="l00709"></a>00709 <span class="keywordflow">return</span> NULL; <a name="l00710"></a>00710 } <a name="l00711"></a>00711 fcb->cepsize = 13; <a name="l00712"></a>00712 fcb->n_stream = 4; <a name="l00713"></a>00713 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(4, <span class="keyword">sizeof</span>(int32)); <a name="l00714"></a>00714 fcb->stream_len[0] = 12; <a name="l00715"></a>00715 fcb->stream_len[1] = 24; <a name="l00716"></a>00716 fcb->stream_len[2] = 3; <a name="l00717"></a>00717 fcb->stream_len[3] = 12; <a name="l00718"></a>00718 fcb->out_dim = 51; <a name="l00719"></a>00719 fcb->window_size = 4; <a name="l00720"></a>00720 fcb->compute_feat = feat_s2_4x_cep2feat; <a name="l00721"></a>00721 } <a name="l00722"></a>00722 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((strcmp(type, <span class="stringliteral">"s3_1x39"</span>) == 0) || (strcmp(type, <span class="stringliteral">"1s_12c_12d_3p_12dd"</span>) == 0)) { <a name="l00723"></a>00723 <span class="comment">/* 1-stream cep/dcep/pow/ddcep (Hack!! hardwired constants below) */</span> <a name="l00724"></a>00724 <span class="keywordflow">if</span> (cepsize != 13) { <a name="l00725"></a>00725 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"s2_4x features require cepsize == 13\n"</span>); <a name="l00726"></a>00726 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(fcb); <a name="l00727"></a>00727 <span class="keywordflow">return</span> NULL; <a name="l00728"></a>00728 } <a name="l00729"></a>00729 fcb->cepsize = 13; <a name="l00730"></a>00730 fcb->n_stream = 1; <a name="l00731"></a>00731 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00732"></a>00732 fcb->stream_len[0] = 39; <a name="l00733"></a>00733 fcb->out_dim = 39; <a name="l00734"></a>00734 fcb->window_size = 3; <a name="l00735"></a>00735 fcb->compute_feat = feat_s3_1x39_cep2feat; <a name="l00736"></a>00736 } <a name="l00737"></a>00737 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"1s_c_d_dd"</span>, 9) == 0) { <a name="l00738"></a>00738 fcb->cepsize = cepsize; <a name="l00739"></a>00739 fcb->n_stream = 1; <a name="l00740"></a>00740 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00741"></a>00741 fcb->stream_len[0] = cepsize * 3; <a name="l00742"></a>00742 fcb->out_dim = cepsize * 3; <a name="l00743"></a>00743 fcb->window_size = FEAT_DCEP_WIN + 1; <span class="comment">/* ddcep needs the extra 1 */</span> <a name="l00744"></a>00744 fcb->compute_feat = feat_1s_c_d_dd_cep2feat; <a name="l00745"></a>00745 } <a name="l00746"></a>00746 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"1s_c_d_ld_dd"</span>, 12) == 0) { <a name="l00747"></a>00747 fcb->cepsize = cepsize; <a name="l00748"></a>00748 fcb->n_stream = 1; <a name="l00749"></a>00749 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00750"></a>00750 fcb->stream_len[0] = cepsize * 4; <a name="l00751"></a>00751 fcb->out_dim = cepsize * 4; <a name="l00752"></a>00752 fcb->window_size = FEAT_DCEP_WIN * 2; <a name="l00753"></a>00753 fcb->compute_feat = feat_1s_c_d_ld_dd_cep2feat; <a name="l00754"></a>00754 } <a name="l00755"></a>00755 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"cep_dcep"</span>, 8) == 0 || strncmp(type, <span class="stringliteral">"1s_c_d"</span>, 6) == 0) { <a name="l00756"></a>00756 <span class="comment">/* 1-stream cep/dcep */</span> <a name="l00757"></a>00757 fcb->cepsize = cepsize; <a name="l00758"></a>00758 fcb->n_stream = 1; <a name="l00759"></a>00759 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00760"></a>00760 fcb->stream_len[0] = <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * 2; <a name="l00761"></a>00761 fcb->out_dim = fcb->stream_len[0]; <a name="l00762"></a>00762 fcb->window_size = 2; <a name="l00763"></a>00763 fcb->compute_feat = feat_s3_cep_dcep; <a name="l00764"></a>00764 } <a name="l00765"></a>00765 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"cep"</span>, 3) == 0 || strncmp(type, <span class="stringliteral">"1s_c"</span>, 4) == 0) { <a name="l00766"></a>00766 <span class="comment">/* 1-stream cep */</span> <a name="l00767"></a>00767 fcb->cepsize = cepsize; <a name="l00768"></a>00768 fcb->n_stream = 1; <a name="l00769"></a>00769 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00770"></a>00770 fcb->stream_len[0] = <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l00771"></a>00771 fcb->out_dim = fcb->stream_len[0]; <a name="l00772"></a>00772 fcb->window_size = 0; <a name="l00773"></a>00773 fcb->compute_feat = feat_s3_cep; <a name="l00774"></a>00774 } <a name="l00775"></a>00775 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"1s_3c"</span>, 5) == 0 || strncmp(type, <span class="stringliteral">"1s_4c"</span>, 5) == 0) { <a name="l00776"></a>00776 <span class="comment">/* 1-stream cep with frames concatenated, so called cepwin features */</span> <a name="l00777"></a>00777 <span class="keywordflow">if</span> (strncmp(type, <span class="stringliteral">"1s_3c"</span>, 5) == 0) <a name="l00778"></a>00778 fcb->window_size = 3; <a name="l00779"></a>00779 <span class="keywordflow">else</span> <a name="l00780"></a>00780 fcb->window_size = 4; <a name="l00781"></a>00781 <a name="l00782"></a>00782 fcb->cepsize = cepsize; <a name="l00783"></a>00783 fcb->n_stream = 1; <a name="l00784"></a>00784 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(1, <span class="keyword">sizeof</span>(int32)); <a name="l00785"></a>00785 fcb->stream_len[0] = <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb) * (2 * fcb->window_size + 1); <a name="l00786"></a>00786 fcb->out_dim = fcb->stream_len[0]; <a name="l00787"></a>00787 fcb->compute_feat = feat_s3_cepwin; <a name="l00788"></a>00788 } <a name="l00789"></a>00789 <span class="keywordflow">else</span> { <a name="l00790"></a>00790 int32 i, l, k; <a name="l00791"></a>00791 <span class="keywordtype">char</span> *strp; <a name="l00792"></a>00792 <span class="keywordtype">char</span> *mtype = <a class="code" href="ckd__alloc_8h.html#ad313f92478859f9e4ea99d0f6e78c393" title="Macro for __ckd_salloc__.">ckd_salloc</a>(type); <a name="l00793"></a>00793 <span class="keywordtype">char</span> *wd = <a class="code" href="ckd__alloc_8h.html#ad313f92478859f9e4ea99d0f6e78c393" title="Macro for __ckd_salloc__.">ckd_salloc</a>(type); <a name="l00794"></a>00794 <span class="comment">/*</span> <a name="l00795"></a>00795 <span class="comment"> * Generic definition: Format should be %d,%d,%d,...,%d (i.e.,</span> <a name="l00796"></a>00796 <span class="comment"> * comma separated list of feature stream widths; #items =</span> <a name="l00797"></a>00797 <span class="comment"> * #streams). An optional window size (frames will be</span> <a name="l00798"></a>00798 <span class="comment"> * concatenated) is also allowed, which can be specified with</span> <a name="l00799"></a>00799 <span class="comment"> * a colon after the list of feature streams.</span> <a name="l00800"></a>00800 <span class="comment"> */</span> <a name="l00801"></a>00801 l = strlen(mtype); <a name="l00802"></a>00802 k = 0; <a name="l00803"></a>00803 <span class="keywordflow">for</span> (i = 1; i < l - 1; i++) { <a name="l00804"></a>00804 <span class="keywordflow">if</span> (mtype[i] == <span class="charliteral">','</span>) { <a name="l00805"></a>00805 mtype[i] = <span class="charliteral">' '</span>; <a name="l00806"></a>00806 k++; <a name="l00807"></a>00807 } <a name="l00808"></a>00808 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mtype[i] == <span class="charliteral">':'</span>) { <a name="l00809"></a>00809 mtype[i] = <span class="charliteral">'\0'</span>; <a name="l00810"></a>00810 fcb->window_size = atoi(mtype + i + 1); <a name="l00811"></a>00811 <span class="keywordflow">break</span>; <a name="l00812"></a>00812 } <a name="l00813"></a>00813 } <a name="l00814"></a>00814 k++; <span class="comment">/* Presumably there are (#commas+1) streams */</span> <a name="l00815"></a>00815 fcb->n_stream = k; <a name="l00816"></a>00816 fcb->stream_len = (int32 *) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(k, <span class="keyword">sizeof</span>(int32)); <a name="l00817"></a>00817 <a name="l00818"></a>00818 <span class="comment">/* Scan individual feature stream lengths */</span> <a name="l00819"></a>00819 strp = mtype; <a name="l00820"></a>00820 i = 0; <a name="l00821"></a>00821 fcb->out_dim = 0; <a name="l00822"></a>00822 fcb->cepsize = 0; <a name="l00823"></a>00823 <span class="keywordflow">while</span> (sscanf(strp, <span class="stringliteral">"%s%n"</span>, wd, &l) == 1) { <a name="l00824"></a>00824 strp += l; <a name="l00825"></a>00825 <span class="keywordflow">if</span> ((i >= fcb->n_stream) <a name="l00826"></a>00826 || (sscanf(wd, <span class="stringliteral">"%d"</span>, &(fcb->stream_len[i])) != 1) <a name="l00827"></a>00827 || (fcb->stream_len[i] <= 0)) <a name="l00828"></a>00828 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"Bad feature type argument\n"</span>); <a name="l00829"></a>00829 <span class="comment">/* Input size before windowing */</span> <a name="l00830"></a>00830 fcb->cepsize += fcb->stream_len[i]; <a name="l00831"></a>00831 <span class="keywordflow">if</span> (fcb->window_size > 0) <a name="l00832"></a>00832 fcb->stream_len[i] *= (fcb->window_size * 2 + 1); <a name="l00833"></a>00833 <span class="comment">/* Output size after windowing */</span> <a name="l00834"></a>00834 fcb->out_dim += fcb->stream_len[i]; <a name="l00835"></a>00835 i++; <a name="l00836"></a>00836 } <a name="l00837"></a>00837 <span class="keywordflow">if</span> (i != fcb->n_stream) <a name="l00838"></a>00838 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"Bad feature type argument\n"</span>); <a name="l00839"></a>00839 <span class="keywordflow">if</span> (fcb->cepsize != cepsize) <a name="l00840"></a>00840 <a class="code" href="err_8h.html#a1a4495946ab2449d61108fe829a94613" title="Exit with non-zero status after error message.">E_FATAL</a>(<span class="stringliteral">"Bad feature type argument\n"</span>); <a name="l00841"></a>00841 <a name="l00842"></a>00842 <span class="comment">/* Input is already the feature stream */</span> <a name="l00843"></a>00843 fcb->compute_feat = feat_copy; <a name="l00844"></a>00844 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(mtype); <a name="l00845"></a>00845 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(wd); <a name="l00846"></a>00846 } <a name="l00847"></a>00847 <a name="l00848"></a>00848 <span class="keywordflow">if</span> (cmn != CMN_NONE) <a name="l00849"></a>00849 fcb->cmn_struct = cmn_init(<a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb)); <a name="l00850"></a>00850 fcb->cmn = cmn; <a name="l00851"></a>00851 fcb->varnorm = varnorm; <a name="l00852"></a>00852 <span class="keywordflow">if</span> (agc != AGC_NONE) { <a name="l00853"></a>00853 fcb->agc_struct = <a class="code" href="agc_8h.html#a5c7ee7b19f8dcfd0c28b4dc76a283dc7" title="Initialize AGC structure with default values.">agc_init</a>(); <a name="l00854"></a>00854 <span class="comment">/*</span> <a name="l00855"></a>00855 <span class="comment"> * No need to check if agc is set to EMAX; agc_emax_set() changes only emax related things</span> <a name="l00856"></a>00856 <span class="comment"> * Moreover, if agc is not NONE and block mode is used, feat_agc() SILENTLY</span> <a name="l00857"></a>00857 <span class="comment"> * switches to EMAX</span> <a name="l00858"></a>00858 <span class="comment"> */</span> <a name="l00859"></a>00859 <span class="comment">/* HACK: hardwired initial estimates based on use of CMN (from Sphinx2) */</span> <a name="l00860"></a>00860 <a class="code" href="agc_8h.html#a4fd17f224b5d8f7bfcaa9389d11716eb" title="Set the current AGC maximum estimate.">agc_emax_set</a>(fcb->agc_struct, (cmn != CMN_NONE) ? 5.0 : 10.0); <a name="l00861"></a>00861 } <a name="l00862"></a>00862 fcb->agc = agc; <a name="l00863"></a>00863 <span class="comment">/*</span> <a name="l00864"></a>00864 <span class="comment"> * Make sure this buffer is large enough to be used in feat_s2mfc2feat_block_utt()</span> <a name="l00865"></a>00865 <span class="comment"> */</span> <a name="l00866"></a>00866 fcb->cepbuf = (mfcc_t **) <a class="code" href="ckd__alloc_8h.html#a949e7b50fcd9697b1563fa57f50e9c4f" title="Macro for __ckd_calloc_2d__.">ckd_calloc_2d</a>((LIVEBUFBLOCKSIZE < <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) * 2) ? <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) * 2 : LIVEBUFBLOCKSIZE, <a name="l00867"></a>00867 <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb), <a name="l00868"></a>00868 <span class="keyword">sizeof</span>(mfcc_t)); <a name="l00869"></a>00869 <span class="comment">/* This one is actually just an array of pointers to "flatten out"</span> <a name="l00870"></a>00870 <span class="comment"> * wraparounds. */</span> <a name="l00871"></a>00871 fcb->tmpcepbuf = <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(2 * <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb) + 1, <a name="l00872"></a>00872 <span class="keyword">sizeof</span>(*fcb->tmpcepbuf)); <a name="l00873"></a>00873 <a name="l00874"></a>00874 <span class="keywordflow">return</span> fcb; <a name="l00875"></a>00875 } <a name="l00876"></a>00876 <a name="l00877"></a>00877 <a name="l00878"></a>00878 <span class="keywordtype">void</span> <a name="l00879"></a><a class="code" href="feat_8h.html#afeaef030a5ec32c2164b5bd55e912714">00879</a> <a class="code" href="feat_8h.html#afeaef030a5ec32c2164b5bd55e912714" title="Print the given block of feature vectors to the given FILE.">feat_print</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t *** feat, int32 nfr, FILE * fp) <a name="l00880"></a>00880 { <a name="l00881"></a>00881 int32 i, j, k; <a name="l00882"></a>00882 <a name="l00883"></a>00883 <span class="keywordflow">for</span> (i = 0; i < nfr; i++) { <a name="l00884"></a>00884 fprintf(fp, <span class="stringliteral">"%8d:\n"</span>, i); <a name="l00885"></a>00885 <a name="l00886"></a>00886 <span class="keywordflow">for</span> (j = 0; j < <a class="code" href="feat_8h.html#abadd19e2cc72df33e81e9d73a7ddffdb" title="Number of streams or subvectors in feature output.">feat_dimension1</a>(fcb); j++) { <a name="l00887"></a>00887 fprintf(fp, <span class="stringliteral">"\t%2d:"</span>, j); <a name="l00888"></a>00888 <a name="l00889"></a>00889 <span class="keywordflow">for</span> (k = 0; k < <a class="code" href="feat_8h.html#a5bd29a80c7f23f281d55555757f97f34" title="Dimensionality of stream/subvector i in feature output.">feat_dimension2</a>(fcb, j); k++) <a name="l00890"></a>00890 fprintf(fp, <span class="stringliteral">" %8.4f"</span>, MFCC2FLOAT(feat[i][j][k])); <a name="l00891"></a>00891 fprintf(fp, <span class="stringliteral">"\n"</span>); <a name="l00892"></a>00892 } <a name="l00893"></a>00893 } <a name="l00894"></a>00894 <a name="l00895"></a>00895 fflush(fp); <a name="l00896"></a>00896 } <a name="l00897"></a>00897 <a name="l00898"></a>00898 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00899"></a>00899 feat_cmn(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t **mfc, int32 nfr, int32 beginutt, int32 endutt) <a name="l00900"></a>00900 { <a name="l00901"></a>00901 <a class="code" href="cmn_8h.html#a9384c411b10e9db9745cfb550a5c7652" title="Types of cepstral mean normalization to apply to the features.">cmn_type_t</a> cmn_type = fcb->cmn; <a name="l00902"></a>00902 <a name="l00903"></a>00903 <span class="keywordflow">if</span> (!(beginutt && endutt) <a name="l00904"></a>00904 && cmn_type != CMN_NONE) <span class="comment">/* Only cmn_prior in block computation mode. */</span> <a name="l00905"></a>00905 cmn_type = CMN_PRIOR; <a name="l00906"></a>00906 <a name="l00907"></a>00907 <span class="keywordflow">switch</span> (cmn_type) { <a name="l00908"></a>00908 <span class="keywordflow">case</span> CMN_CURRENT: <a name="l00909"></a>00909 <a class="code" href="cmn_8h.html#accf10de8ef4d98b4bf591529cf16565e" title="CMN for the whole sentence.">cmn</a>(fcb->cmn_struct, mfc, fcb->varnorm, nfr); <a name="l00910"></a>00910 <span class="keywordflow">break</span>; <a name="l00911"></a>00911 <span class="keywordflow">case</span> CMN_PRIOR: <a name="l00912"></a>00912 <a class="code" href="cmn_8h.html#aa622cf1b6a1b9a9bffd8f60b903bfc42" title="CMN for one block of data, using prior mean.">cmn_prior</a>(fcb->cmn_struct, mfc, fcb->varnorm, nfr); <a name="l00913"></a>00913 <span class="keywordflow">if</span> (endutt) <a name="l00914"></a>00914 <a class="code" href="cmn_8h.html#aae61df2ec71082520669fc63d94bb1ef" title="Update prior mean based on observed data.">cmn_prior_update</a>(fcb->cmn_struct); <a name="l00915"></a>00915 <span class="keywordflow">break</span>; <a name="l00916"></a>00916 <span class="keywordflow">default</span>: <a name="l00917"></a>00917 ; <a name="l00918"></a>00918 } <a name="l00919"></a>00919 cep_dump_dbg(fcb, mfc, nfr, <span class="stringliteral">"After CMN"</span>); <a name="l00920"></a>00920 } <a name="l00921"></a>00921 <a name="l00922"></a>00922 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00923"></a>00923 feat_agc(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t **mfc, int32 nfr, int32 beginutt, int32 endutt) <a name="l00924"></a>00924 { <a name="l00925"></a>00925 <a class="code" href="agc_8h.html#a5524df49e0425cc6b1c002bc704a8103" title="Types of acoustic gain control to apply to the features.">agc_type_t</a> agc_type = fcb->agc; <a name="l00926"></a>00926 <a name="l00927"></a>00927 <span class="keywordflow">if</span> (!(beginutt && endutt) <a name="l00928"></a>00928 && agc_type != AGC_NONE) <span class="comment">/* Only agc_emax in block computation mode. */</span> <a name="l00929"></a>00929 agc_type = AGC_EMAX; <a name="l00930"></a>00930 <a name="l00931"></a>00931 <span class="keywordflow">switch</span> (agc_type) { <a name="l00932"></a>00932 <span class="keywordflow">case</span> AGC_MAX: <a name="l00933"></a>00933 <a class="code" href="agc_8h.html#a29a2a4dd80141af1c3476094c353b739" title="Apply AGC to the given mfc vectors (normalize all C0 mfc coefficients in the given input such that th...">agc_max</a>(fcb->agc_struct, mfc, nfr); <a name="l00934"></a>00934 <span class="keywordflow">break</span>; <a name="l00935"></a>00935 <span class="keywordflow">case</span> AGC_EMAX: <a name="l00936"></a>00936 <a class="code" href="agc_8h.html#ac2cdd4c519b46824c5b28c5b769b5ecd" title="Apply AGC to the given block of MFC vectors.">agc_emax</a>(fcb->agc_struct, mfc, nfr); <a name="l00937"></a>00937 <span class="keywordflow">if</span> (endutt) <a name="l00938"></a>00938 <a class="code" href="agc_8h.html#af47b6004f2f963ae0019a67450b892c2" title="Update AGC parameters for next utterance.">agc_emax_update</a>(fcb->agc_struct); <a name="l00939"></a>00939 <span class="keywordflow">break</span>; <a name="l00940"></a>00940 <span class="keywordflow">case</span> AGC_NOISE: <a name="l00941"></a>00941 <a class="code" href="agc_8h.html#ae65d4be1d74aea11b7e16e3777272d13" title="Apply AGC using noise threshold to the given block of MFC vectors.">agc_noise</a>(fcb->agc_struct, mfc, nfr); <a name="l00942"></a>00942 <span class="keywordflow">break</span>; <a name="l00943"></a>00943 <span class="keywordflow">default</span>: <a name="l00944"></a>00944 ; <a name="l00945"></a>00945 } <a name="l00946"></a>00946 cep_dump_dbg(fcb, mfc, nfr, <span class="stringliteral">"After AGC"</span>); <a name="l00947"></a>00947 } <a name="l00948"></a>00948 <a name="l00949"></a>00949 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00950"></a>00950 feat_compute_utt(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, mfcc_t **mfc, int32 nfr, int32 win, mfcc_t ***feat) <a name="l00951"></a>00951 { <a name="l00952"></a>00952 int32 i; <a name="l00953"></a>00953 <a name="l00954"></a>00954 cep_dump_dbg(fcb, mfc, nfr, <span class="stringliteral">"Incoming features (after padding)"</span>); <a name="l00955"></a>00955 <a name="l00956"></a>00956 <span class="comment">/* Create feature vectors */</span> <a name="l00957"></a>00957 <span class="keywordflow">for</span> (i = win; i < nfr - win; i++) { <a name="l00958"></a>00958 fcb->compute_feat(fcb, mfc + i, feat[i - win]); <a name="l00959"></a>00959 } <a name="l00960"></a>00960 <a name="l00961"></a>00961 feat_print_dbg(fcb, feat, nfr - win * 2, <span class="stringliteral">"After dynamic feature computation"</span>); <a name="l00962"></a>00962 <a name="l00963"></a>00963 <span class="keywordflow">if</span> (fcb->lda) { <a name="l00964"></a>00964 <a class="code" href="feat_8h.html#a7452702cb435ea9244c7e1f61bbf5da1" title="Transform a block of features using the feature module&#39;s LDA transform.">feat_lda_transform</a>(fcb, feat, nfr - win * 2); <a name="l00965"></a>00965 feat_print_dbg(fcb, feat, nfr - win * 2, <span class="stringliteral">"After LDA"</span>); <a name="l00966"></a>00966 } <a name="l00967"></a>00967 <a name="l00968"></a>00968 <span class="keywordflow">if</span> (fcb->subvecs) { <a name="l00969"></a>00969 feat_subvec_project(fcb, feat, nfr - win * 2); <a name="l00970"></a>00970 feat_print_dbg(fcb, feat, nfr - win * 2, <span class="stringliteral">"After subvector projection"</span>); <a name="l00971"></a>00971 } <a name="l00972"></a>00972 } <a name="l00973"></a>00973 <a name="l00974"></a>00974 <a name="l00987"></a>00987 <span class="keyword">static</span> int32 <a name="l00988"></a>00988 feat_s2mfc_read_norm_pad(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *fcb, <span class="keywordtype">char</span> *file, int32 win, <a name="l00989"></a>00989 int32 sf, int32 ef, <a name="l00990"></a>00990 mfcc_t ***out_mfc, <a name="l00991"></a>00991 int32 maxfr, <a name="l00992"></a>00992 int32 cepsize) <a name="l00993"></a>00993 { <a name="l00994"></a>00994 FILE *fp; <a name="l00995"></a>00995 int32 n_float32; <a name="l00996"></a>00996 float32 *float_feat; <a name="l00997"></a>00997 <span class="keyword">struct </span>stat statbuf; <a name="l00998"></a>00998 int32 i, n, byterev; <a name="l00999"></a>00999 int32 start_pad, end_pad; <a name="l01000"></a>01000 mfcc_t **mfc; <a name="l01001"></a>01001 <a name="l01002"></a>01002 <span class="comment">/* Initialize the output pointer to NULL, so that any attempts to</span> <a name="l01003"></a>01003 <span class="comment"> free() it if we fail before allocating it will not segfault! */</span> <a name="l01004"></a>01004 <span class="keywordflow">if</span> (out_mfc) <a name="l01005"></a>01005 *out_mfc = NULL; <a name="l01006"></a>01006 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a>(<span class="stringliteral">"Reading mfc file: '%s'[%d..%d]\n"</span>, file, sf, ef); <a name="l01007"></a>01007 <span class="keywordflow">if</span> (ef >= 0 && ef <= sf) { <a name="l01008"></a>01008 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: End frame (%d) <= Start frame (%d)\n"</span>, file, ef, sf); <a name="l01009"></a>01009 <span class="keywordflow">return</span> -1; <a name="l01010"></a>01010 } <a name="l01011"></a>01011 <a name="l01012"></a>01012 <span class="comment">/* Find filesize; HACK!! To get around intermittent NFS failures, use stat_retry */</span> <a name="l01013"></a>01013 <span class="keywordflow">if</span> ((<a class="code" href="pio_8h.html#a0ba35509687e80ee65ba731c7cfcad9b" title="There is no bitstream decoder, because a stream abstraction is too slow.">stat_retry</a>(file, &statbuf) < 0) <a name="l01014"></a>01014 || ((fp = fopen(file, <span class="stringliteral">"rb"</span>)) == NULL)) { <a name="l01015"></a>01015 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"Failed to open file '%s' for reading: %s\n"</span>, file, strerror(errno)); <a name="l01016"></a>01016 <span class="keywordflow">return</span> -1; <a name="l01017"></a>01017 } <a name="l01018"></a>01018 <a name="l01019"></a>01019 <span class="comment">/* Read #floats in header */</span> <a name="l01020"></a>01020 <span class="keywordflow">if</span> (<a class="code" href="pio_8h.html#a601277430d3221bf1906bb879ae26d3e" title="NFS file reads seem to fail now and then.">fread_retry</a>(&n_float32, <span class="keyword">sizeof</span>(int32), 1, fp) != 1) { <a name="l01021"></a>01021 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: fread(#floats) failed\n"</span>, file); <a name="l01022"></a>01022 fclose(fp); <a name="l01023"></a>01023 <span class="keywordflow">return</span> -1; <a name="l01024"></a>01024 } <a name="l01025"></a>01025 <a name="l01026"></a>01026 <span class="comment">/* Check if n_float32 matches file size */</span> <a name="l01027"></a>01027 byterev = 0; <a name="l01028"></a>01028 <span class="keywordflow">if</span> ((int32) (n_float32 * <span class="keyword">sizeof</span>(float32) + 4) != (int32) statbuf.st_size) { <span class="comment">/* RAH, typecast both sides to remove compile warning */</span> <a name="l01029"></a>01029 n = n_float32; <a name="l01030"></a>01030 SWAP_INT32(&n); <a name="l01031"></a>01031 <a name="l01032"></a>01032 <span class="keywordflow">if</span> ((int32) (n * <span class="keyword">sizeof</span>(float32) + 4) != (int32) (statbuf.st_size)) { <span class="comment">/* RAH, typecast both sides to remove compile warning */</span> <a name="l01033"></a>01033 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a> <a name="l01034"></a>01034 (<span class="stringliteral">"%s: Header size field: %d(%08x); filesize: %d(%08x)\n"</span>, <a name="l01035"></a>01035 file, n_float32, n_float32, statbuf.st_size, <a name="l01036"></a>01036 statbuf.st_size); <a name="l01037"></a>01037 fclose(fp); <a name="l01038"></a>01038 <span class="keywordflow">return</span> -1; <a name="l01039"></a>01039 } <a name="l01040"></a>01040 <a name="l01041"></a>01041 n_float32 = n; <a name="l01042"></a>01042 byterev = 1; <a name="l01043"></a>01043 } <a name="l01044"></a>01044 <span class="keywordflow">if</span> (n_float32 <= 0) { <a name="l01045"></a>01045 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: Header size field (#floats) = %d\n"</span>, file, n_float32); <a name="l01046"></a>01046 fclose(fp); <a name="l01047"></a>01047 <span class="keywordflow">return</span> -1; <a name="l01048"></a>01048 } <a name="l01049"></a>01049 <a name="l01050"></a>01050 <span class="comment">/* Convert n to #frames of input */</span> <a name="l01051"></a>01051 n = n_float32 / cepsize; <a name="l01052"></a>01052 <span class="keywordflow">if</span> (n * cepsize != n_float32) { <a name="l01053"></a>01053 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"Header size field: %d; not multiple of %d\n"</span>, n_float32, <a name="l01054"></a>01054 cepsize); <a name="l01055"></a>01055 fclose(fp); <a name="l01056"></a>01056 <span class="keywordflow">return</span> -1; <a name="l01057"></a>01057 } <a name="l01058"></a>01058 <a name="l01059"></a>01059 <span class="comment">/* Check start and end frames */</span> <a name="l01060"></a>01060 <span class="keywordflow">if</span> (sf > 0) { <a name="l01061"></a>01061 <span class="keywordflow">if</span> (sf >= n) { <a name="l01062"></a>01062 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: Start frame (%d) beyond file size (%d)\n"</span>, file, <a name="l01063"></a>01063 sf, n); <a name="l01064"></a>01064 fclose(fp); <a name="l01065"></a>01065 <span class="keywordflow">return</span> -1; <a name="l01066"></a>01066 } <a name="l01067"></a>01067 } <a name="l01068"></a>01068 <span class="keywordflow">if</span> (ef < 0) <a name="l01069"></a>01069 ef = n-1; <a name="l01070"></a>01070 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ef >= n) { <a name="l01071"></a>01071 <a class="code" href="err_8h.html#a6a794bec721b555ac1f2167f9e12f662" title="Print warning information to standard error stream.">E_WARN</a>(<span class="stringliteral">"%s: End frame (%d) beyond file size (%d), will truncate\n"</span>, <a name="l01072"></a>01072 file, ef, n); <a name="l01073"></a>01073 ef = n-1; <a name="l01074"></a>01074 } <a name="l01075"></a>01075 <a name="l01076"></a>01076 <span class="comment">/* Add window to start and end frames */</span> <a name="l01077"></a>01077 sf -= win; <a name="l01078"></a>01078 ef += win; <a name="l01079"></a>01079 <span class="keywordflow">if</span> (sf < 0) { <a name="l01080"></a>01080 start_pad = -sf; <a name="l01081"></a>01081 sf = 0; <a name="l01082"></a>01082 } <a name="l01083"></a>01083 <span class="keywordflow">else</span> <a name="l01084"></a>01084 start_pad = 0; <a name="l01085"></a>01085 <span class="keywordflow">if</span> (ef >= n) { <a name="l01086"></a>01086 end_pad = ef - n + 1; <a name="l01087"></a>01087 ef = n - 1; <a name="l01088"></a>01088 } <a name="l01089"></a>01089 <span class="keywordflow">else</span> <a name="l01090"></a>01090 end_pad = 0; <a name="l01091"></a>01091 <a name="l01092"></a>01092 <span class="comment">/* Limit n if indicated by [sf..ef] */</span> <a name="l01093"></a>01093 <span class="keywordflow">if</span> ((ef - sf + 1) < n) <a name="l01094"></a>01094 n = (ef - sf + 1); <a name="l01095"></a>01095 <span class="keywordflow">if</span> (maxfr > 0 && n + start_pad + end_pad > maxfr) { <a name="l01096"></a>01096 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: Maximum output size(%d frames) < actual #frames(%d)\n"</span>, <a name="l01097"></a>01097 file, maxfr, n + start_pad + end_pad); <a name="l01098"></a>01098 fclose(fp); <a name="l01099"></a>01099 <span class="keywordflow">return</span> -1; <a name="l01100"></a>01100 } <a name="l01101"></a>01101 <a name="l01102"></a>01102 <span class="comment">/* If no output buffer was supplied, then skip the actual data reading. */</span> <a name="l01103"></a>01103 <span class="keywordflow">if</span> (out_mfc != NULL) { <a name="l01104"></a>01104 <span class="comment">/* Position at desired start frame and read actual MFC data */</span> <a name="l01105"></a>01105 mfc = (mfcc_t **)<a class="code" href="ckd__alloc_8h.html#a949e7b50fcd9697b1563fa57f50e9c4f" title="Macro for __ckd_calloc_2d__.">ckd_calloc_2d</a>(n + start_pad + end_pad, cepsize, <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01106"></a>01106 <span class="keywordflow">if</span> (sf > 0) <a name="l01107"></a>01107 fseek(fp, sf * cepsize * <span class="keyword">sizeof</span>(float32), SEEK_CUR); <a name="l01108"></a>01108 n_float32 = n * cepsize; <a name="l01109"></a>01109 <span class="preprocessor">#ifdef FIXED_POINT</span> <a name="l01110"></a>01110 <span class="preprocessor"></span> float_feat = <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(n_float32, <span class="keyword">sizeof</span>(float32)); <a name="l01111"></a>01111 <span class="preprocessor">#else</span> <a name="l01112"></a>01112 <span class="preprocessor"></span> float_feat = mfc[start_pad]; <a name="l01113"></a>01113 <span class="preprocessor">#endif</span> <a name="l01114"></a>01114 <span class="preprocessor"></span> <span class="keywordflow">if</span> (<a class="code" href="pio_8h.html#a601277430d3221bf1906bb879ae26d3e" title="NFS file reads seem to fail now and then.">fread_retry</a>(float_feat, <span class="keyword">sizeof</span>(float32), n_float32, fp) != n_float32) { <a name="l01115"></a>01115 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"%s: fread(%dx%d) (MFC data) failed\n"</span>, file, n, cepsize); <a name="l01116"></a>01116 <a class="code" href="ckd__alloc_8h.html#a8246c071ac12e98b7e1df9fe6da15aef" title="Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.">ckd_free_2d</a>(mfc); <a name="l01117"></a>01117 fclose(fp); <a name="l01118"></a>01118 <span class="keywordflow">return</span> -1; <a name="l01119"></a>01119 } <a name="l01120"></a>01120 <span class="keywordflow">if</span> (byterev) { <a name="l01121"></a>01121 <span class="keywordflow">for</span> (i = 0; i < n_float32; i++) { <a name="l01122"></a>01122 SWAP_FLOAT32(&float_feat[i]); <a name="l01123"></a>01123 } <a name="l01124"></a>01124 } <a name="l01125"></a>01125 <span class="preprocessor">#ifdef FIXED_POINT</span> <a name="l01126"></a>01126 <span class="preprocessor"></span> <span class="keywordflow">for</span> (i = 0; i < n_float32; ++i) { <a name="l01127"></a>01127 mfc[start_pad][i] = FLOAT2MFCC(float_feat[i]); <a name="l01128"></a>01128 } <a name="l01129"></a>01129 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(float_feat); <a name="l01130"></a>01130 <span class="preprocessor">#endif</span> <a name="l01131"></a>01131 <span class="preprocessor"></span> <a name="l01132"></a>01132 <span class="comment">/* Normalize */</span> <a name="l01133"></a>01133 feat_cmn(fcb, mfc + start_pad, n, 1, 1); <a name="l01134"></a>01134 feat_agc(fcb, mfc + start_pad, n, 1, 1); <a name="l01135"></a>01135 <a name="l01136"></a>01136 <span class="comment">/* Replicate start and end frames if necessary. */</span> <a name="l01137"></a>01137 <span class="keywordflow">for</span> (i = 0; i < start_pad; ++i) <a name="l01138"></a>01138 memcpy(mfc[i], mfc[start_pad], cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01139"></a>01139 <span class="keywordflow">for</span> (i = 0; i < end_pad; ++i) <a name="l01140"></a>01140 memcpy(mfc[start_pad + n + i], mfc[start_pad + n - 1], <a name="l01141"></a>01141 cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01142"></a>01142 <a name="l01143"></a>01143 *out_mfc = mfc; <a name="l01144"></a>01144 } <a name="l01145"></a>01145 <a name="l01146"></a>01146 fclose(fp); <a name="l01147"></a>01147 <span class="keywordflow">return</span> n + start_pad + end_pad; <a name="l01148"></a>01148 } <a name="l01149"></a>01149 <a name="l01150"></a>01150 <a name="l01151"></a>01151 <a name="l01152"></a>01152 int32 <a name="l01153"></a><a class="code" href="feat_8h.html#a918e21c2b28a6951a83c64f7023126a7">01153</a> <a class="code" href="feat_8h.html#a918e21c2b28a6951a83c64f7023126a7" title="Read a specified MFC file (or given segment within it), perform CMN/AGC as indicated by fcb...">feat_s2mfc2feat</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, <span class="keyword">const</span> <span class="keywordtype">char</span> *file, <span class="keyword">const</span> <span class="keywordtype">char</span> *dir, <span class="keyword">const</span> <span class="keywordtype">char</span> *cepext, <a name="l01154"></a>01154 int32 sf, int32 ef, mfcc_t *** feat, int32 maxfr) <a name="l01155"></a>01155 { <a name="l01156"></a>01156 <span class="keywordtype">char</span> *path; <a name="l01157"></a>01157 <span class="keywordtype">char</span> *ps = <span class="stringliteral">"/"</span>; <a name="l01158"></a>01158 int32 win, nfr; <a name="l01159"></a>01159 int32 file_length, cepext_length, path_length = 0; <a name="l01160"></a>01160 mfcc_t **mfc; <a name="l01161"></a>01161 <a name="l01162"></a>01162 <span class="keywordflow">if</span> (fcb->cepsize <= 0) { <a name="l01163"></a>01163 <a class="code" href="err_8h.html#a5f7b2f58f5a663a6bdd51f197ae21993" title="Print error message to standard error stream.">E_ERROR</a>(<span class="stringliteral">"Bad cepsize: %d\n"</span>, fcb->cepsize); <a name="l01164"></a>01164 <span class="keywordflow">return</span> -1; <a name="l01165"></a>01165 } <a name="l01166"></a>01166 <a name="l01167"></a>01167 <span class="keywordflow">if</span> (cepext == NULL) <a name="l01168"></a>01168 cepext = <span class="stringliteral">""</span>; <a name="l01169"></a>01169 <a name="l01170"></a>01170 <span class="comment">/*</span> <a name="l01171"></a>01171 <span class="comment"> * Create mfc filename, combining file, dir and extension if</span> <a name="l01172"></a>01172 <span class="comment"> * necessary</span> <a name="l01173"></a>01173 <span class="comment"> */</span> <a name="l01174"></a>01174 <a name="l01175"></a>01175 <span class="comment">/*</span> <a name="l01176"></a>01176 <span class="comment"> * First we decide about the path. If dir is defined, then use</span> <a name="l01177"></a>01177 <span class="comment"> * it. Otherwise assume the filename already contains the path.</span> <a name="l01178"></a>01178 <span class="comment"> */</span> <a name="l01179"></a>01179 <span class="keywordflow">if</span> (dir == NULL) { <a name="l01180"></a>01180 dir = <span class="stringliteral">""</span>; <a name="l01181"></a>01181 ps = <span class="stringliteral">""</span>; <a name="l01182"></a>01182 <span class="comment">/*</span> <a name="l01183"></a>01183 <span class="comment"> * This is not true but some 3rd party apps</span> <a name="l01184"></a>01184 <span class="comment"> * may parse the output explicitly checking for this line</span> <a name="l01185"></a>01185 <span class="comment"> */</span> <a name="l01186"></a>01186 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a>(<span class="stringliteral">"At directory . (current directory)\n"</span>); <a name="l01187"></a>01187 } <a name="l01188"></a>01188 <span class="keywordflow">else</span> { <a name="l01189"></a>01189 <a class="code" href="err_8h.html#ac3c705943d946708cea0a1443be1c853" title="Print logging information to standard error stream.">E_INFO</a>(<span class="stringliteral">"At directory %s\n"</span>, dir); <a name="l01190"></a>01190 <span class="comment">/*</span> <a name="l01191"></a>01191 <span class="comment"> * Do not forget the path separator!</span> <a name="l01192"></a>01192 <span class="comment"> */</span> <a name="l01193"></a>01193 path_length += strlen(dir) + 1; <a name="l01194"></a>01194 } <a name="l01195"></a>01195 <a name="l01196"></a>01196 <span class="comment">/*</span> <a name="l01197"></a>01197 <span class="comment"> * Include cepext, if it's not already part of the filename.</span> <a name="l01198"></a>01198 <span class="comment"> */</span> <a name="l01199"></a>01199 file_length = strlen(file); <a name="l01200"></a>01200 cepext_length = strlen(cepext); <a name="l01201"></a>01201 <span class="keywordflow">if</span> ((file_length > cepext_length) <a name="l01202"></a>01202 && (strcmp(file + file_length - cepext_length, cepext) == 0)) { <a name="l01203"></a>01203 cepext = <span class="stringliteral">""</span>; <a name="l01204"></a>01204 cepext_length = 0; <a name="l01205"></a>01205 } <a name="l01206"></a>01206 <a name="l01207"></a>01207 <span class="comment">/*</span> <a name="l01208"></a>01208 <span class="comment"> * Do not forget the '\0'</span> <a name="l01209"></a>01209 <span class="comment"> */</span> <a name="l01210"></a>01210 path_length += file_length + cepext_length + 1; <a name="l01211"></a>01211 path = (<span class="keywordtype">char</span>*) <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(path_length, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)); <a name="l01212"></a>01212 <a name="l01213"></a>01213 <span class="preprocessor">#ifdef HAVE_SNPRINTF</span> <a name="l01214"></a>01214 <span class="preprocessor"></span> <span class="comment">/*</span> <a name="l01215"></a>01215 <span class="comment"> * Paranoia is our best friend...</span> <a name="l01216"></a>01216 <span class="comment"> */</span> <a name="l01217"></a>01217 <span class="keywordflow">while</span> ((file_length = snprintf(path, path_length, <span class="stringliteral">"%s%s%s%s"</span>, dir, ps, file, cepext)) > path_length) { <a name="l01218"></a>01218 path_length = file_length; <a name="l01219"></a>01219 path = (<span class="keywordtype">char</span>*) <a class="code" href="ckd__alloc_8h.html#afd496738b3e114bd494c5a0955f1bfb3" title="Macro for __ckd_realloc__.">ckd_realloc</a>(path, path_length * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)); <a name="l01220"></a>01220 } <a name="l01221"></a>01221 <span class="preprocessor">#else</span> <a name="l01222"></a>01222 <span class="preprocessor"></span> sprintf(path, <span class="stringliteral">"%s%s%s%s"</span>, dir, ps, file, cepext); <a name="l01223"></a>01223 <span class="preprocessor">#endif</span> <a name="l01224"></a>01224 <span class="preprocessor"></span> <a name="l01225"></a>01225 win = <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb); <a name="l01226"></a>01226 <span class="comment">/* Pad maxfr with win, so we read enough raw feature data to</span> <a name="l01227"></a>01227 <span class="comment"> * calculate the requisite number of dynamic features. */</span> <a name="l01228"></a>01228 <span class="keywordflow">if</span> (maxfr >= 0) <a name="l01229"></a>01229 maxfr += win * 2; <a name="l01230"></a>01230 <a name="l01231"></a>01231 <span class="keywordflow">if</span> (feat != NULL) { <a name="l01232"></a>01232 <span class="comment">/* Read mfc file including window or padding if necessary. */</span> <a name="l01233"></a>01233 nfr = feat_s2mfc_read_norm_pad(fcb, path, win, sf, ef, &mfc, maxfr, fcb->cepsize); <a name="l01234"></a>01234 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(path); <a name="l01235"></a>01235 <span class="keywordflow">if</span> (nfr < 0) { <a name="l01236"></a>01236 <a class="code" href="ckd__alloc_8h.html#a8246c071ac12e98b7e1df9fe6da15aef" title="Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.">ckd_free_2d</a>((<span class="keywordtype">void</span> **) mfc); <a name="l01237"></a>01237 <span class="keywordflow">return</span> -1; <a name="l01238"></a>01238 } <a name="l01239"></a>01239 <a name="l01240"></a>01240 <span class="comment">/* Actually compute the features */</span> <a name="l01241"></a>01241 feat_compute_utt(fcb, mfc, nfr, win, feat); <a name="l01242"></a>01242 <a name="l01243"></a>01243 <a class="code" href="ckd__alloc_8h.html#a8246c071ac12e98b7e1df9fe6da15aef" title="Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.">ckd_free_2d</a>((<span class="keywordtype">void</span> **) mfc); <a name="l01244"></a>01244 } <a name="l01245"></a>01245 <span class="keywordflow">else</span> { <a name="l01246"></a>01246 <span class="comment">/* Just calculate the number of frames we would need. */</span> <a name="l01247"></a>01247 nfr = feat_s2mfc_read_norm_pad(fcb, path, win, sf, ef, NULL, maxfr, fcb->cepsize); <a name="l01248"></a>01248 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(path); <a name="l01249"></a>01249 <span class="keywordflow">if</span> (nfr < 0) <a name="l01250"></a>01250 <span class="keywordflow">return</span> nfr; <a name="l01251"></a>01251 } <a name="l01252"></a>01252 <a name="l01253"></a>01253 <a name="l01254"></a>01254 <span class="keywordflow">return</span> (nfr - win * 2); <a name="l01255"></a>01255 } <a name="l01256"></a>01256 <a name="l01257"></a>01257 <span class="keyword">static</span> int32 <a name="l01258"></a>01258 feat_s2mfc2feat_block_utt(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** uttcep, <a name="l01259"></a>01259 int32 nfr, mfcc_t *** ofeat) <a name="l01260"></a>01260 { <a name="l01261"></a>01261 mfcc_t **cepbuf; <a name="l01262"></a>01262 int32 i, win, cepsize; <a name="l01263"></a>01263 <a name="l01264"></a>01264 win = <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb); <a name="l01265"></a>01265 cepsize = <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l01266"></a>01266 <a name="l01267"></a>01267 <span class="comment">/* Copy and pad out the utterance (this requires that the</span> <a name="l01268"></a>01268 <span class="comment"> * feature computation functions always access the buffer via</span> <a name="l01269"></a>01269 <span class="comment"> * the frame pointers, which they do) */</span> <a name="l01270"></a>01270 cepbuf = <a class="code" href="ckd__alloc_8h.html#aa00ef21903bc4f8a972488417adc8d2e" title="Macros to simplify the use of above functions.">ckd_calloc</a>(nfr + win * 2, <span class="keyword">sizeof</span>(mfcc_t *)); <a name="l01271"></a>01271 memcpy(cepbuf + win, uttcep, nfr * <span class="keyword">sizeof</span>(mfcc_t *)); <a name="l01272"></a>01272 <a name="l01273"></a>01273 <span class="comment">/* Do normalization before we interpolate on the boundary */</span> <a name="l01274"></a>01274 feat_cmn(fcb, cepbuf + win, nfr, 1, 1); <a name="l01275"></a>01275 feat_agc(fcb, cepbuf + win, nfr, 1, 1); <a name="l01276"></a>01276 <a name="l01277"></a>01277 <span class="comment">/* Now interpolate */</span> <a name="l01278"></a>01278 <span class="keywordflow">for</span> (i = 0; i < win; ++i) { <a name="l01279"></a>01279 cepbuf[i] = fcb->cepbuf[i]; <a name="l01280"></a>01280 memcpy(cepbuf[i], uttcep[0], cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01281"></a>01281 cepbuf[nfr + win + i] = fcb->cepbuf[win + i]; <a name="l01282"></a>01282 memcpy(cepbuf[nfr + win + i], uttcep[nfr - 1], cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01283"></a>01283 } <a name="l01284"></a>01284 <span class="comment">/* Compute as usual. */</span> <a name="l01285"></a>01285 feat_compute_utt(fcb, cepbuf, nfr + win * 2, win, ofeat); <a name="l01286"></a>01286 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(cepbuf); <a name="l01287"></a>01287 <span class="keywordflow">return</span> nfr; <a name="l01288"></a>01288 } <a name="l01289"></a>01289 <a name="l01290"></a>01290 int32 <a name="l01291"></a><a class="code" href="feat_8h.html#a68bf7d2c15e3f76b08833449eb254aed">01291</a> <a class="code" href="feat_8h.html#a68bf7d2c15e3f76b08833449eb254aed" title="Feature computation routine for live mode decoder.">feat_s2mfc2feat_live</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * fcb, mfcc_t ** uttcep, int32 *inout_ncep, <a name="l01292"></a>01292 int32 beginutt, int32 endutt, mfcc_t *** ofeat) <a name="l01293"></a>01293 { <a name="l01294"></a>01294 int32 win, cepsize, nbufcep; <a name="l01295"></a>01295 int32 i, j, nfeatvec; <a name="l01296"></a>01296 int32 zero = 0; <a name="l01297"></a>01297 <a name="l01298"></a>01298 <span class="comment">/* Avoid having to check this everywhere. */</span> <a name="l01299"></a>01299 <span class="keywordflow">if</span> (inout_ncep == NULL) inout_ncep = &zero; <a name="l01300"></a>01300 <a name="l01301"></a>01301 <span class="comment">/* Special case for entire utterances. */</span> <a name="l01302"></a>01302 <span class="keywordflow">if</span> (beginutt && endutt && *inout_ncep > 0) <a name="l01303"></a>01303 <span class="keywordflow">return</span> feat_s2mfc2feat_block_utt(fcb, uttcep, *inout_ncep, ofeat); <a name="l01304"></a>01304 <a name="l01305"></a>01305 win = <a class="code" href="feat_8h.html#a69cdcd91578c26565c7653ad6f2eb510" title="Size of dynamic feature window.">feat_window_size</a>(fcb); <a name="l01306"></a>01306 cepsize = <a class="code" href="feat_8h.html#ac691993ec890de3daefbcffe89788f5a" title="Input dimensionality of feature.">feat_cepsize</a>(fcb); <a name="l01307"></a>01307 <a name="l01308"></a>01308 <span class="comment">/* Empty the input buffer on start of utterance. */</span> <a name="l01309"></a>01309 <span class="keywordflow">if</span> (beginutt) <a name="l01310"></a>01310 fcb->bufpos = fcb->curpos; <a name="l01311"></a>01311 <a name="l01312"></a>01312 <span class="comment">/* Calculate how much data is in the buffer already. */</span> <a name="l01313"></a>01313 nbufcep = fcb->bufpos - fcb->curpos; <a name="l01314"></a>01314 <span class="keywordflow">if</span> (nbufcep < 0) <a name="l01315"></a>01315 nbufcep = fcb->bufpos + LIVEBUFBLOCKSIZE - fcb->curpos; <a name="l01316"></a>01316 <span class="comment">/* Add any data that we have to replicate. */</span> <a name="l01317"></a>01317 <span class="keywordflow">if</span> (beginutt && *inout_ncep > 0) <a name="l01318"></a>01318 nbufcep += win; <a name="l01319"></a>01319 <span class="keywordflow">if</span> (endutt) <a name="l01320"></a>01320 nbufcep += win; <a name="l01321"></a>01321 <a name="l01322"></a>01322 <span class="comment">/* Only consume as much input as will fit in the buffer. */</span> <a name="l01323"></a>01323 <span class="keywordflow">if</span> (nbufcep + *inout_ncep > LIVEBUFBLOCKSIZE) { <a name="l01324"></a>01324 <span class="comment">/* We also can't overwrite the trailing window, hence the</span> <a name="l01325"></a>01325 <span class="comment"> * reason why win is subtracted here. */</span> <a name="l01326"></a>01326 *inout_ncep = LIVEBUFBLOCKSIZE - nbufcep - win; <a name="l01327"></a>01327 <span class="comment">/* Cancel end of utterance processing. */</span> <a name="l01328"></a>01328 endutt = FALSE; <a name="l01329"></a>01329 } <a name="l01330"></a>01330 <a name="l01331"></a>01331 <span class="comment">/* FIXME: Don't modify the input! */</span> <a name="l01332"></a>01332 feat_cmn(fcb, uttcep, *inout_ncep, beginutt, endutt); <a name="l01333"></a>01333 feat_agc(fcb, uttcep, *inout_ncep, beginutt, endutt); <a name="l01334"></a>01334 <a name="l01335"></a>01335 <span class="comment">/* Replicate first frame into the first win frames if we're at the</span> <a name="l01336"></a>01336 <span class="comment"> * beginning of the utterance and there was some actual input to</span> <a name="l01337"></a>01337 <span class="comment"> * deal with. (FIXME: Not entirely sure why that condition) */</span> <a name="l01338"></a>01338 <span class="keywordflow">if</span> (beginutt && *inout_ncep > 0) { <a name="l01339"></a>01339 <span class="keywordflow">for</span> (i = 0; i < win; i++) { <a name="l01340"></a>01340 memcpy(fcb->cepbuf[fcb->bufpos++], uttcep[0], <a name="l01341"></a>01341 cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01342"></a>01342 fcb->bufpos %= LIVEBUFBLOCKSIZE; <a name="l01343"></a>01343 } <a name="l01344"></a>01344 <span class="comment">/* Move the current pointer past this data. */</span> <a name="l01345"></a>01345 fcb->curpos = fcb->bufpos; <a name="l01346"></a>01346 nbufcep -= win; <a name="l01347"></a>01347 } <a name="l01348"></a>01348 <a name="l01349"></a>01349 <span class="comment">/* Copy in frame data to the circular buffer. */</span> <a name="l01350"></a>01350 <span class="keywordflow">for</span> (i = 0; i < *inout_ncep; ++i) { <a name="l01351"></a>01351 memcpy(fcb->cepbuf[fcb->bufpos++], uttcep[i], <a name="l01352"></a>01352 cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01353"></a>01353 fcb->bufpos %= LIVEBUFBLOCKSIZE; <a name="l01354"></a>01354 ++nbufcep; <a name="l01355"></a>01355 } <a name="l01356"></a>01356 <a name="l01357"></a>01357 <span class="comment">/* Replicate last frame into the last win frames if we're at the</span> <a name="l01358"></a>01358 <span class="comment"> * end of the utterance (even if there was no input, so we can</span> <a name="l01359"></a>01359 <span class="comment"> * flush the output). */</span> <a name="l01360"></a>01360 <span class="keywordflow">if</span> (endutt) { <a name="l01361"></a>01361 int32 tpos; <span class="comment">/* Index of last input frame. */</span> <a name="l01362"></a>01362 <span class="keywordflow">if</span> (fcb->bufpos == 0) <a name="l01363"></a>01363 tpos = LIVEBUFBLOCKSIZE - 1; <a name="l01364"></a>01364 <span class="keywordflow">else</span> <a name="l01365"></a>01365 tpos = fcb->bufpos - 1; <a name="l01366"></a>01366 <span class="keywordflow">for</span> (i = 0; i < win; ++i) { <a name="l01367"></a>01367 memcpy(fcb->cepbuf[fcb->bufpos++], fcb->cepbuf[tpos], <a name="l01368"></a>01368 cepsize * <span class="keyword">sizeof</span>(mfcc_t)); <a name="l01369"></a>01369 fcb->bufpos %= LIVEBUFBLOCKSIZE; <a name="l01370"></a>01370 } <a name="l01371"></a>01371 } <a name="l01372"></a>01372 <a name="l01373"></a>01373 <span class="comment">/* We have to leave the trailing window of frames. */</span> <a name="l01374"></a>01374 nfeatvec = nbufcep - win; <a name="l01375"></a>01375 <span class="keywordflow">if</span> (nfeatvec <= 0) <a name="l01376"></a>01376 <span class="keywordflow">return</span> 0; <span class="comment">/* Do nothing. */</span> <a name="l01377"></a>01377 <a name="l01378"></a>01378 <span class="keywordflow">for</span> (i = 0; i < nfeatvec; ++i) { <a name="l01379"></a>01379 <span class="comment">/* Handle wraparound cases. */</span> <a name="l01380"></a>01380 <span class="keywordflow">if</span> (fcb->curpos - win < 0 || fcb->curpos + win >= LIVEBUFBLOCKSIZE) { <a name="l01381"></a>01381 <span class="comment">/* Use tmpcepbuf for this case. Actually, we just need the pointers. */</span> <a name="l01382"></a>01382 <span class="keywordflow">for</span> (j = -win; j <= win; ++j) { <a name="l01383"></a>01383 int32 tmppos = <a name="l01384"></a>01384 (fcb->curpos + j + LIVEBUFBLOCKSIZE) % LIVEBUFBLOCKSIZE; <a name="l01385"></a>01385 fcb->tmpcepbuf[win + j] = fcb->cepbuf[tmppos]; <a name="l01386"></a>01386 } <a name="l01387"></a>01387 fcb->compute_feat(fcb, fcb->tmpcepbuf + win, ofeat[i]); <a name="l01388"></a>01388 } <a name="l01389"></a>01389 <span class="keywordflow">else</span> { <a name="l01390"></a>01390 fcb->compute_feat(fcb, fcb->cepbuf + fcb->curpos, ofeat[i]); <a name="l01391"></a>01391 } <a name="l01392"></a>01392 <span class="comment">/* Move the read pointer forward. */</span> <a name="l01393"></a>01393 ++fcb->curpos; <a name="l01394"></a>01394 fcb->curpos %= LIVEBUFBLOCKSIZE; <a name="l01395"></a>01395 } <a name="l01396"></a>01396 <a name="l01397"></a>01397 <span class="keywordflow">if</span> (fcb->lda) <a name="l01398"></a>01398 <a class="code" href="feat_8h.html#a7452702cb435ea9244c7e1f61bbf5da1" title="Transform a block of features using the feature module&#39;s LDA transform.">feat_lda_transform</a>(fcb, ofeat, nfeatvec); <a name="l01399"></a>01399 <a name="l01400"></a>01400 <span class="keywordflow">if</span> (fcb->subvecs) <a name="l01401"></a>01401 feat_subvec_project(fcb, ofeat, nfeatvec); <a name="l01402"></a>01402 <a name="l01403"></a>01403 <span class="keywordflow">return</span> nfeatvec; <a name="l01404"></a>01404 } <a name="l01405"></a>01405 <a name="l01406"></a>01406 <a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * <a name="l01407"></a><a class="code" href="feat_8h.html#a80d6eabf01ff119d324a07c1de8fda80">01407</a> <a class="code" href="feat_8h.html#a80d6eabf01ff119d324a07c1de8fda80" title="Retain ownership of feat_t.">feat_retain</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> *f) <a name="l01408"></a>01408 { <a name="l01409"></a>01409 ++f->refcount; <a name="l01410"></a>01410 <span class="keywordflow">return</span> f; <a name="l01411"></a>01411 } <a name="l01412"></a>01412 <a name="l01413"></a>01413 <span class="keywordtype">int</span> <a name="l01414"></a><a class="code" href="feat_8h.html#a98463b4ab5fe4265fc817523b0e25ee9">01414</a> <a class="code" href="feat_8h.html#a98463b4ab5fe4265fc817523b0e25ee9" title="Release resource associated with feat_t.">feat_free</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * f) <a name="l01415"></a>01415 { <a name="l01416"></a>01416 <span class="keywordflow">if</span> (f == NULL) <a name="l01417"></a>01417 <span class="keywordflow">return</span> 0; <a name="l01418"></a>01418 <span class="keywordflow">if</span> (--f->refcount > 0) <a name="l01419"></a>01419 <span class="keywordflow">return</span> f->refcount; <a name="l01420"></a>01420 <a name="l01421"></a>01421 <span class="keywordflow">if</span> (f->cepbuf) <a name="l01422"></a>01422 <a class="code" href="ckd__alloc_8h.html#a8246c071ac12e98b7e1df9fe6da15aef" title="Free a 2-D array (ptr) previously allocated by ckd_calloc_2d.">ckd_free_2d</a>((<span class="keywordtype">void</span> **) f->cepbuf); <a name="l01423"></a>01423 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(f->tmpcepbuf); <a name="l01424"></a>01424 <a name="l01425"></a>01425 <span class="keywordflow">if</span> (f->name) { <a name="l01426"></a>01426 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>((<span class="keywordtype">void</span> *) f->name); <a name="l01427"></a>01427 } <a name="l01428"></a>01428 <span class="keywordflow">if</span> (f->lda) <a name="l01429"></a>01429 <a class="code" href="ckd__alloc_8h.html#a443accde4663a4a07c6d147088614d57" title="Free a 3-D array (ptr) previously allocated by ckd_calloc_3d.">ckd_free_3d</a>((<span class="keywordtype">void</span> ***) f->lda); <a name="l01430"></a>01430 <a name="l01431"></a>01431 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(f->stream_len); <a name="l01432"></a>01432 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(f->sv_len); <a name="l01433"></a>01433 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(f->sv_buf); <a name="l01434"></a>01434 <a class="code" href="feat_8h.html#ad209a1028b315a96a3a2447eccdb8605" title="Free array of subvector specs.">subvecs_free</a>(f->subvecs); <a name="l01435"></a>01435 <a name="l01436"></a>01436 cmn_free(f->cmn_struct); <a name="l01437"></a>01437 <a class="code" href="agc_8h.html#a6a050fc4b079be05b1946636d5d7f3aa" title="Free AGC structure.">agc_free</a>(f->agc_struct); <a name="l01438"></a>01438 <a name="l01439"></a>01439 <a class="code" href="ckd__alloc_8h.html#a31c6b405558620ac37599737b5722fbf" title="Test and free a 1-D array.">ckd_free</a>(f); <a name="l01440"></a>01440 <span class="keywordflow">return</span> 0; <a name="l01441"></a>01441 } <a name="l01442"></a>01442 <a name="l01443"></a>01443 <a name="l01444"></a>01444 <span class="keywordtype">void</span> <a name="l01445"></a><a class="code" href="feat_8h.html#ae3e67bd629f9756ddb6c5a599d223f6e">01445</a> <a class="code" href="feat_8h.html#ae3e67bd629f9756ddb6c5a599d223f6e" title="Report the feat_t data structure.">feat_report</a>(<a class="code" href="structfeat__t.html" title="Structure for describing a speech feature type Structure for describing a speech feature type (no...">feat_t</a> * f) <a name="l01446"></a>01446 { <a name="l01447"></a>01447 <span class="keywordtype">int</span> i; <a name="l01448"></a>01448 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Initialization of feat_t, report:\n"</span>); <a name="l01449"></a>01449 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Feature type = %s\n"</span>, f->name); <a name="l01450"></a>01450 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Cepstral size = %d\n"</span>, f->cepsize); <a name="l01451"></a>01451 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Number of streams = %d\n"</span>, f->n_stream); <a name="l01452"></a>01452 <span class="keywordflow">for</span> (i = 0; i < f->n_stream; i++) { <a name="l01453"></a>01453 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Vector size of stream[%d]: %d\n"</span>, i, <a name="l01454"></a>01454 f->stream_len[i]); <a name="l01455"></a>01455 } <a name="l01456"></a>01456 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Number of subvectors = %d\n"</span>, f->n_sv); <a name="l01457"></a>01457 <span class="keywordflow">for</span> (i = 0; i < f->n_sv; i++) { <a name="l01458"></a>01458 int32 *sv; <a name="l01459"></a>01459 <a name="l01460"></a>01460 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Components of subvector[%d]:"</span>, i); <a name="l01461"></a>01461 <span class="keywordflow">for</span> (sv = f->subvecs[i]; sv && *sv != -1; ++sv) <a name="l01462"></a>01462 <a class="code" href="err_8h.html#ae5a17ac5be8c738d3d977b1bea2d4538" title="Print logging information without header, to standard error stream.">E_INFOCONT</a>(<span class="stringliteral">" %d"</span>, *sv); <a name="l01463"></a>01463 <a class="code" href="err_8h.html#ae5a17ac5be8c738d3d977b1bea2d4538" title="Print logging information without header, to standard error stream.">E_INFOCONT</a>(<span class="stringliteral">"\n"</span>); <a name="l01464"></a>01464 } <a name="l01465"></a>01465 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Whether CMN is used = %d\n"</span>, f->cmn); <a name="l01466"></a>01466 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Whether AGC is used = %d\n"</span>, f->agc); <a name="l01467"></a>01467 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"Whether variance is normalized = %d\n"</span>, f->varnorm); <a name="l01468"></a>01468 <a class="code" href="err_8h.html#ad95ccef073dd6f3c81c84e6aedca1f16" title="Print logging information without filename.">E_INFO_NOFN</a>(<span class="stringliteral">"\n"</span>); <a name="l01469"></a>01469 } </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><b>feat.c</b> </li> <li class="footer">Generated on Tue Apr 19 2011 for SphinxBase by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>