\doxysection{fe\+\_\+interface.\+c}
\label{fe__interface_8c_source}\index{src/libsphinxbase/fe/fe\_interface.c@{src/libsphinxbase/fe/fe\_interface.c}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1996-\/2004\ Carnegie\ Mellon\ University.\ \ All\ rights\ }}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.\ }}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced\ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the\ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND\ }}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,\ }}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT\ }}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,\ }}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY\ }}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE\ }}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ <math.h>}}
\DoxyCodeLine{00040\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ <assert.h>}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#ifdef\ \_WIN32\_WCE}}
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\#include\ <windows.h>}}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#include\ <time.h>}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#include\ <config.h>}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/prim\_type.h"{}}}
\DoxyCodeLine{00053\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/byteorder.h"{}}}
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/fixpoint.h"{}}}
\DoxyCodeLine{00055\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/genrand.h"{}}}
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/err.h"{}}}
\DoxyCodeLine{00057\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/cmd\_ln.h"{}}}
\DoxyCodeLine{00058\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/ckd\_alloc.h"{}}}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00060\ \textcolor{preprocessor}{\#include\ "{}fe\_internal.h"{}}}
\DoxyCodeLine{00061\ \textcolor{preprocessor}{\#include\ "{}fe\_warp.h"{}}}
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00063\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ arg\_t\ fe\_args[]\ =\ \{}
\DoxyCodeLine{00064\ \ \ \ \ waveform\_to\_cepstral\_command\_line\_macro(),}
\DoxyCodeLine{00065\ \ \ \ \ \{\ NULL,\ 0,\ NULL,\ NULL\ \}}
\DoxyCodeLine{00066\ \};}
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00068\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00069\ fe\_parse\_general\_params(cmd\_ln\_t\ *config,\ fe\_t\ *\ fe)}
\DoxyCodeLine{00070\ \{}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keywordtype}{int}\ j,\ frate;}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \ \ \ \ fe-\/>config\ =\ config;}
\DoxyCodeLine{00074\ \ \ \ \ fe-\/>sampling\_rate\ =\ cmd\_ln\_float32\_r(config,\ \textcolor{stringliteral}{"{}-\/samprate"{}});}
\DoxyCodeLine{00075\ \ \ \ \ frate\ =\ cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/frate"{}});}
\DoxyCodeLine{00076\ \ \ \ \ \textcolor{keywordflow}{if}\ (frate\ >\ MAX\_INT16\ ||\ frate\ >\ fe-\/>sampling\_rate\ ||\ frate\ <\ 1)\ \{}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ E\_ERROR}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Frame\ rate\ \%d\ can\ not\ be\ bigger\ than\ sample\ rate\ \%.02f\(\backslash\)n"{}},}
\DoxyCodeLine{00079\ \ \ \ \ \ \ \ \ \ \ \ \ \ frate,\ fe-\/>sampling\_rate);}
\DoxyCodeLine{00080\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00081\ \ \ \ \ \}}
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00083\ \ \ \ \ fe-\/>frame\_rate\ =\ (int16)frate;}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/dither"{}}))\ \{}
\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ fe-\/>dither\ =\ 1;}
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ fe-\/>seed\ =\ cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/seed"{}});}
\DoxyCodeLine{00087\ \ \ \ \ \}}
\DoxyCodeLine{00088\ \textcolor{preprocessor}{\#ifdef\ WORDS\_BIGENDIAN}}
\DoxyCodeLine{00089\ \ \ \ \ fe-\/>swap\ =\ strcmp(\textcolor{stringliteral}{"{}big"{}},\ cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/input\_endian"{}}))\ ==\ 0\ ?\ 0\ :\ 1;}
\DoxyCodeLine{00090\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ }}
\DoxyCodeLine{00091\ \ \ \ \ fe-\/>swap\ =\ strcmp(\textcolor{stringliteral}{"{}little"{}},\ cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/input\_endian"{}}))\ ==\ 0\ ?\ 0\ :\ 1;}
\DoxyCodeLine{00092\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00093\ \ \ \ \ fe-\/>window\_length\ =\ cmd\_ln\_float32\_r(config,\ \textcolor{stringliteral}{"{}-\/wlen"{}});}
\DoxyCodeLine{00094\ \ \ \ \ fe-\/>pre\_emphasis\_alpha\ =\ cmd\_ln\_float32\_r(config,\ \textcolor{stringliteral}{"{}-\/alpha"{}});}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \ \ \ \ fe-\/>num\_cepstra\ =\ (uint8)cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/ncep"{}});}
\DoxyCodeLine{00097\ \ \ \ \ fe-\/>fft\_size\ =\ (int16)cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/nfft"{}});}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{comment}{/*\ Check\ FFT\ size,\ compute\ FFT\ order\ (log\_2(n))\ */}}
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ fe-\/>fft\_size,\ fe-\/>fft\_order\ =\ 0;\ j\ >\ 1;\ j\ >>=\ 1,\ fe-\/>fft\_order++)\ \{}
\DoxyCodeLine{00101\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (((j\ \%\ 2)\ !=\ 0)\ ||\ (fe-\/>fft\_size\ <=\ 0))\ \{}
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}fft:\ number\ of\ points\ must\ be\ a\ power\ of\ 2\ (is\ \%d)\(\backslash\)n"{}},}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>fft\_size);}
\DoxyCodeLine{00104\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00105\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00106\ \ \ \ \ \}}
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{comment}{/*\ Verify\ that\ FFT\ size\ is\ greater\ or\ equal\ to\ window\ length.\ */}}
\DoxyCodeLine{00108\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>fft\_size\ <\ (\textcolor{keywordtype}{int})(fe-\/>window\_length\ *\ fe-\/>sampling\_rate))\ \{}
\DoxyCodeLine{00109\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}FFT:\ Number\ of\ points\ must\ be\ greater\ or\ equal\ to\ frame\ size\ (\%d\ samples)\(\backslash\)n"{}},}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{int})(fe-\/>window\_length\ *\ fe-\/>sampling\_rate));}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00112\ \ \ \ \ \}}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00114\ \ \ \ \ fe-\/>remove\_dc\ =\ cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/remove\_dc"{}});}
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ ==\ strcmp(cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/transform"{}}),\ \textcolor{stringliteral}{"{}dct"{}}))}
\DoxyCodeLine{00117\ \ \ \ \ \ \ \ \ fe-\/>transform\ =\ DCT\_II;}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (0\ ==\ strcmp(cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/transform"{}}),\ \textcolor{stringliteral}{"{}legacy"{}}))}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ fe-\/>transform\ =\ LEGACY\_DCT;}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (0\ ==\ strcmp(cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/transform"{}}),\ \textcolor{stringliteral}{"{}htk"{}}))}
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ fe-\/>transform\ =\ DCT\_HTK;}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ transform\ type\ (values\ are\ 'dct',\ 'legacy',\ 'htk')\(\backslash\)n"{}});}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00125\ \ \ \ \ \}}
\DoxyCodeLine{00126\ }
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/logspec"{}}))}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ fe-\/>log\_spec\ =\ RAW\_LOG\_SPEC;}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/smoothspec"{}}))}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ fe-\/>log\_spec\ =\ SMOOTH\_LOG\_SPEC;}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00132\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00133\ \}}
\DoxyCodeLine{00134\ }
\DoxyCodeLine{00135\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00136\ fe\_parse\_melfb\_params(cmd\_ln\_t\ *config,\ fe\_t\ *fe,\ melfb\_t\ *\ mel)}
\DoxyCodeLine{00137\ \{}
\DoxyCodeLine{00138\ \ \ \ \ mel-\/>sampling\_rate\ =\ fe-\/>sampling\_rate;}
\DoxyCodeLine{00139\ \ \ \ \ mel-\/>fft\_size\ =\ fe-\/>fft\_size;}
\DoxyCodeLine{00140\ \ \ \ \ mel-\/>num\_cepstra\ =\ fe-\/>num\_cepstra;}
\DoxyCodeLine{00141\ \ \ \ \ mel-\/>num\_filters\ =\ cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/nfilt"{}});}
\DoxyCodeLine{00142\ }
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>log\_spec)}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ fe-\/>feature\_dimension\ =\ mel-\/>num\_filters;}
\DoxyCodeLine{00145\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ fe-\/>feature\_dimension\ =\ fe-\/>num\_cepstra;}
\DoxyCodeLine{00147\ }
\DoxyCodeLine{00148\ \ \ \ \ mel-\/>upper\_filt\_freq\ =\ cmd\_ln\_float32\_r(config,\ \textcolor{stringliteral}{"{}-\/upperf"{}});}
\DoxyCodeLine{00149\ \ \ \ \ mel-\/>lower\_filt\_freq\ =\ cmd\_ln\_float32\_r(config,\ \textcolor{stringliteral}{"{}-\/lowerf"{}});}
\DoxyCodeLine{00150\ }
\DoxyCodeLine{00151\ \ \ \ \ mel-\/>doublewide\ =\ cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/doublebw"{}});}
\DoxyCodeLine{00152\ }
\DoxyCodeLine{00153\ \ \ \ \ mel-\/>warp\_type\ =\ cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/warp\_type"{}});}
\DoxyCodeLine{00154\ \ \ \ \ mel-\/>warp\_params\ =\ cmd\_ln\_str\_r(config,\ \textcolor{stringliteral}{"{}-\/warp\_params"{}});}
\DoxyCodeLine{00155\ \ \ \ \ mel-\/>lifter\_val\ =\ cmd\_ln\_int32\_r(config,\ \textcolor{stringliteral}{"{}-\/lifter"{}});}
\DoxyCodeLine{00156\ }
\DoxyCodeLine{00157\ \ \ \ \ mel-\/>unit\_area\ =\ cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/unit\_area"{}});}
\DoxyCodeLine{00158\ \ \ \ \ mel-\/>round\_filters\ =\ cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/round\_filters"{}});}
\DoxyCodeLine{00159\ }
\DoxyCodeLine{00160\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe\_warp\_set(mel,\ mel-\/>warp\_type)\ !=\ FE\_SUCCESS)\ \{}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ initialize\ the\ warping\ function.\(\backslash\)n"{}});}
\DoxyCodeLine{00162\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00163\ \ \ \ \ \}}
\DoxyCodeLine{00164\ \ \ \ \ fe\_warp\_set\_parameters(mel,\ mel-\/>warp\_params,\ mel-\/>sampling\_rate);}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00166\ \}}
\DoxyCodeLine{00167\ }
\DoxyCodeLine{00168\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00169\ fe\_print\_current(fe\_t\ \textcolor{keyword}{const}\ *fe)}
\DoxyCodeLine{00170\ \{}
\DoxyCodeLine{00171\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Current\ FE\ Parameters:\(\backslash\)n"{}});}
\DoxyCodeLine{00172\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tSampling\ Rate:\ \ \ \ \ \ \ \ \ \ \ \ \ \%f\(\backslash\)n"{}},\ fe-\/>sampling\_rate);}
\DoxyCodeLine{00173\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tFrame\ Size:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \%d\(\backslash\)n"{}},\ fe-\/>frame\_size);}
\DoxyCodeLine{00174\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tFrame\ Shift:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \%d\(\backslash\)n"{}},\ fe-\/>frame\_shift);}
\DoxyCodeLine{00175\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tFFT\ Size:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \%d\(\backslash\)n"{}},\ fe-\/>fft\_size);}
\DoxyCodeLine{00176\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tLower\ Frequency:\ \ \ \ \ \ \ \ \ \ \ \%g\(\backslash\)n"{}},}
\DoxyCodeLine{00177\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>lower\_filt\_freq);}
\DoxyCodeLine{00178\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tUpper\ Frequency:\ \ \ \ \ \ \ \ \ \ \ \%g\(\backslash\)n"{}},}
\DoxyCodeLine{00179\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>upper\_filt\_freq);}
\DoxyCodeLine{00180\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tNumber\ of\ filters:\ \ \ \ \ \ \ \ \ \%d\(\backslash\)n"{}},\ fe-\/>mel\_fb-\/>num\_filters);}
\DoxyCodeLine{00181\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tNumber\ of\ Overflow\ Samps:\ \ \%d\(\backslash\)n"{}},\ fe-\/>num\_overflow\_samps);}
\DoxyCodeLine{00182\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\(\backslash\)tStart\ Utt\ Status:\ \ \ \ \ \ \ \ \ \ \%d\(\backslash\)n"{}},\ fe-\/>start\_flag);}
\DoxyCodeLine{00183\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ \%sremove\ DC\ offset\ at\ frame\ level\(\backslash\)n"{}},}
\DoxyCodeLine{00184\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>remove\_dc\ ?\ \textcolor{stringliteral}{"{}"{}}\ :\ \textcolor{stringliteral}{"{}not\ "{}});}
\DoxyCodeLine{00185\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>dither)\ \{}
\DoxyCodeLine{00186\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ add\ dither\ to\ audio\(\backslash\)n"{}});}
\DoxyCodeLine{00187\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Dither\ seeded\ with\ \%d\(\backslash\)n"{}},\ fe-\/>seed);}
\DoxyCodeLine{00188\ \ \ \ \ \}}
\DoxyCodeLine{00189\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00190\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ not\ add\ dither\ to\ audio\(\backslash\)n"{}});}
\DoxyCodeLine{00191\ \ \ \ \ \}}
\DoxyCodeLine{00192\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>mel\_fb-\/>lifter\_val)\ \{}
\DoxyCodeLine{00193\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ apply\ sine-\/curve\ liftering,\ period\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00194\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>lifter\_val);}
\DoxyCodeLine{00195\ \ \ \ \ \}}
\DoxyCodeLine{00196\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ \%snormalize\ filters\ to\ unit\ area\(\backslash\)n"{}},}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>unit\_area\ ?\ \textcolor{stringliteral}{"{}"{}}\ :\ \textcolor{stringliteral}{"{}not\ "{}});}
\DoxyCodeLine{00198\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ \%sround\ filter\ frequencies\ to\ DFT\ points\(\backslash\)n"{}},}
\DoxyCodeLine{00199\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>round\_filters\ ?\ \textcolor{stringliteral}{"{}"{}}\ :\ \textcolor{stringliteral}{"{}not\ "{}});}
\DoxyCodeLine{00200\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Will\ \%suse\ double\ bandwidth\ in\ mel\ filter\(\backslash\)n"{}},}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>doublewide\ ?\ \textcolor{stringliteral}{"{}"{}}\ :\ \textcolor{stringliteral}{"{}not\ "{}});}
\DoxyCodeLine{00202\ \}}
\DoxyCodeLine{00203\ }
\DoxyCodeLine{00204\ fe\_t\ *}
\DoxyCodeLine{00205\ fe\_init\_auto()}
\DoxyCodeLine{00206\ \{}
\DoxyCodeLine{00207\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_init\_auto\_r(cmd\_ln\_get());}
\DoxyCodeLine{00208\ \}}
\DoxyCodeLine{00209\ }
\DoxyCodeLine{00210\ fe\_t\ *}
\DoxyCodeLine{00211\ fe\_init\_auto\_r(cmd\_ln\_t\ *config)}
\DoxyCodeLine{00212\ \{}
\DoxyCodeLine{00213\ \ \ \ \ fe\_t\ *fe;}
\DoxyCodeLine{00214\ }
\DoxyCodeLine{00215\ \ \ \ \ fe\ =\ ckd\_calloc(1,\ \textcolor{keyword}{sizeof}(*fe));}
\DoxyCodeLine{00216\ \ \ \ \ fe-\/>refcount\ =\ 1;}
\DoxyCodeLine{00217\ }
\DoxyCodeLine{00218\ \ \ \ \ \textcolor{comment}{/*\ transfer\ params\ to\ front\ end\ */}}
\DoxyCodeLine{00219\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe\_parse\_general\_params(cmd\_ln\_retain(config),\ fe)\ <\ 0)\ \{}
\DoxyCodeLine{00220\ \ \ \ \ \ \ \ \ fe\_free(fe);}
\DoxyCodeLine{00221\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00222\ \ \ \ \ \}}
\DoxyCodeLine{00223\ }
\DoxyCodeLine{00224\ \ \ \ \ \textcolor{comment}{/*\ compute\ remaining\ fe\ parameters\ */}}
\DoxyCodeLine{00225\ \ \ \ \ \textcolor{comment}{/*\ We\ add\ 0.5\ so\ approximate\ the\ float\ with\ the\ closest}}
\DoxyCodeLine{00226\ \textcolor{comment}{\ \ \ \ \ *\ integer.\ E.g.,\ 2.3\ is\ truncate\ to\ 2,\ whereas\ 3.7\ becomes\ 4}}
\DoxyCodeLine{00227\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00228\ \ \ \ \ fe-\/>frame\_shift\ =\ (int32)\ (fe-\/>sampling\_rate\ /\ fe-\/>frame\_rate\ +\ 0.5);}
\DoxyCodeLine{00229\ \ \ \ \ fe-\/>frame\_size\ =\ (int32)\ (fe-\/>window\_length\ *\ fe-\/>sampling\_rate\ +\ 0.5);}
\DoxyCodeLine{00230\ \ \ \ \ fe-\/>prior\ =\ 0;}
\DoxyCodeLine{00231\ \ \ \ \ fe-\/>frame\_counter\ =\ 0;}
\DoxyCodeLine{00232\ }
\DoxyCodeLine{00233\ \ \ \ \ assert\ (fe-\/>frame\_shift\ >\ 1);}
\DoxyCodeLine{00234\ }
\DoxyCodeLine{00235\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>frame\_size\ >\ (fe-\/>fft\_size))\ \{}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ E\_WARN}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Number\ of\ FFT\ points\ has\ to\ be\ a\ power\ of\ 2\ higher\ than\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \ \ \ \ \ (fe-\/>frame\_size));}
\DoxyCodeLine{00239\ \ \ \ \ \ \ \ \ fe\_free(fe);}
\DoxyCodeLine{00240\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (NULL);}
\DoxyCodeLine{00241\ \ \ \ \ \}}
\DoxyCodeLine{00242\ }
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>dither)}
\DoxyCodeLine{00244\ \ \ \ \ \ \ \ \ fe\_init\_dither(fe-\/>seed);}
\DoxyCodeLine{00245\ }
\DoxyCodeLine{00246\ \ \ \ \ \textcolor{comment}{/*\ establish\ buffers\ for\ overflow\ samps\ and\ hamming\ window\ */}}
\DoxyCodeLine{00247\ \ \ \ \ fe-\/>overflow\_samps\ =\ ckd\_calloc(fe-\/>frame\_size,\ \textcolor{keyword}{sizeof}(int16));}
\DoxyCodeLine{00248\ \ \ \ \ fe-\/>hamming\_window\ =\ ckd\_calloc(fe-\/>frame\_size/2,\ \textcolor{keyword}{sizeof}(window\_t));}
\DoxyCodeLine{00249\ }
\DoxyCodeLine{00250\ \ \ \ \ \textcolor{comment}{/*\ create\ hamming\ window\ */}}
\DoxyCodeLine{00251\ \ \ \ \ fe\_create\_hamming(fe-\/>hamming\_window,\ fe-\/>frame\_size);}
\DoxyCodeLine{00252\ }
\DoxyCodeLine{00253\ \ \ \ \ \textcolor{comment}{/*\ init\ and\ fill\ appropriate\ filter\ structure\ */}}
\DoxyCodeLine{00254\ \ \ \ \ fe-\/>mel\_fb\ =\ ckd\_calloc(1,\ \textcolor{keyword}{sizeof}(*fe-\/>mel\_fb));}
\DoxyCodeLine{00255\ }
\DoxyCodeLine{00256\ \ \ \ \ \textcolor{comment}{/*\ transfer\ params\ to\ mel\ fb\ */}}
\DoxyCodeLine{00257\ \ \ \ \ fe\_parse\_melfb\_params(config,\ fe,\ fe-\/>mel\_fb);}
\DoxyCodeLine{00258\ \ \ \ \ fe\_build\_melfilters(fe-\/>mel\_fb);}
\DoxyCodeLine{00259\ \ \ \ \ fe\_compute\_melcosine(fe-\/>mel\_fb);}
\DoxyCodeLine{00260\ }
\DoxyCodeLine{00261\ \ \ \ \ \textcolor{comment}{/*\ Create\ temporary\ FFT,\ spectrum\ and\ mel-\/spectrum\ buffers.\ */}}
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{comment}{/*\ FIXME:\ Gosh\ there\ are\ a\ lot\ of\ these.\ */}}
\DoxyCodeLine{00263\ \ \ \ \ fe-\/>spch\ =\ ckd\_calloc(fe-\/>frame\_size,\ \textcolor{keyword}{sizeof}(*fe-\/>spch));}
\DoxyCodeLine{00264\ \ \ \ \ fe-\/>frame\ =\ ckd\_calloc(fe-\/>fft\_size,\ \textcolor{keyword}{sizeof}(*fe-\/>frame));}
\DoxyCodeLine{00265\ \ \ \ \ fe-\/>spec\ =\ ckd\_calloc(fe-\/>fft\_size,\ \textcolor{keyword}{sizeof}(*fe-\/>spec));}
\DoxyCodeLine{00266\ \ \ \ \ fe-\/>mfspec\ =\ ckd\_calloc(fe-\/>mel\_fb-\/>num\_filters,\ \textcolor{keyword}{sizeof}(*fe-\/>mfspec));}
\DoxyCodeLine{00267\ }
\DoxyCodeLine{00268\ \ \ \ \ \textcolor{comment}{/*\ create\ twiddle\ factors\ */}}
\DoxyCodeLine{00269\ \ \ \ \ fe-\/>ccc\ =\ ckd\_calloc(fe-\/>fft\_size\ /\ 4,\ \textcolor{keyword}{sizeof}(*fe-\/>ccc));}
\DoxyCodeLine{00270\ \ \ \ \ fe-\/>sss\ =\ ckd\_calloc(fe-\/>fft\_size\ /\ 4,\ \textcolor{keyword}{sizeof}(*fe-\/>sss));}
\DoxyCodeLine{00271\ \ \ \ \ fe\_create\_twiddle(fe);}
\DoxyCodeLine{00272\ }
\DoxyCodeLine{00273\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean\_r(config,\ \textcolor{stringliteral}{"{}-\/verbose"{}}))\ \{}
\DoxyCodeLine{00274\ \ \ \ \ \ \ \ \ fe\_print\_current(fe);}
\DoxyCodeLine{00275\ \ \ \ \ \}}
\DoxyCodeLine{00276\ }
\DoxyCodeLine{00277\ \textcolor{comment}{\ \ \ \ /***\ Z.A.B.\ ***/}}
\DoxyCodeLine{00278\ \textcolor{comment}{\ \ \ \ /***\ Initialize\ the\ overflow\ buffers\ ***/}}
\DoxyCodeLine{00279\ \ \ \ \ fe\_start\_utt(fe);}
\DoxyCodeLine{00280\ \ \ \ \ \textcolor{keywordflow}{return}\ fe;}
\DoxyCodeLine{00281\ \}}
\DoxyCodeLine{00282\ }
\DoxyCodeLine{00283\ arg\_t\ \textcolor{keyword}{const}\ *}
\DoxyCodeLine{00284\ fe\_get\_args(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00285\ \{}
\DoxyCodeLine{00286\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_args;}
\DoxyCodeLine{00287\ \}}
\DoxyCodeLine{00288\ }
\DoxyCodeLine{00289\ \textcolor{keyword}{const}\ cmd\_ln\_t\ *}
\DoxyCodeLine{00290\ fe\_get\_config(fe\_t\ *fe)}
\DoxyCodeLine{00291\ \{}
\DoxyCodeLine{00292\ \ \ \ \ \textcolor{keywordflow}{return}\ fe-\/>config;}
\DoxyCodeLine{00293\ \}}
\DoxyCodeLine{00294\ }
\DoxyCodeLine{00295\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00296\ fe\_init\_dither(int32\ seed)}
\DoxyCodeLine{00297\ \{}
\DoxyCodeLine{00298\ \ \ \ \ \textcolor{keywordflow}{if}\ (seed\ <\ 0)\ \{}
\DoxyCodeLine{00299\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}You\ are\ using\ the\ internal\ mechanism\ to\ generate\ the\ seed.\(\backslash\)n"{}});}
\DoxyCodeLine{00300\ \textcolor{preprocessor}{\#ifdef\ \_WIN32\_WCE}}
\DoxyCodeLine{00301\ \ \ \ \ \ \ \ \ s3\_rand\_seed(GetTickCount());}
\DoxyCodeLine{00302\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00303\ \ \ \ \ \ \ \ \ s3\_rand\_seed((\textcolor{keywordtype}{long})\ time(0));}
\DoxyCodeLine{00304\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00305\ \ \ \ \ \}}
\DoxyCodeLine{00306\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00307\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}You\ are\ using\ \%d\ as\ the\ seed.\(\backslash\)n"{}},\ seed);}
\DoxyCodeLine{00308\ \ \ \ \ \ \ \ \ s3\_rand\_seed(seed);}
\DoxyCodeLine{00309\ \ \ \ \ \}}
\DoxyCodeLine{00310\ \}}
\DoxyCodeLine{00311\ }
\DoxyCodeLine{00312\ int32}
\DoxyCodeLine{00313\ fe\_start\_utt(fe\_t\ *\ fe)}
\DoxyCodeLine{00314\ \{}
\DoxyCodeLine{00315\ \ \ \ \ fe-\/>num\_overflow\_samps\ =\ 0;}
\DoxyCodeLine{00316\ \ \ \ \ memset(fe-\/>overflow\_samps,\ 0,\ fe-\/>frame\_size\ *\ \textcolor{keyword}{sizeof}(int16));}
\DoxyCodeLine{00317\ \ \ \ \ fe-\/>start\_flag\ =\ 1;}
\DoxyCodeLine{00318\ \ \ \ \ fe-\/>prior\ =\ 0;}
\DoxyCodeLine{00319\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00320\ \}}
\DoxyCodeLine{00321\ }
\DoxyCodeLine{00322\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00323\ fe\_get\_output\_size(fe\_t\ *fe)}
\DoxyCodeLine{00324\ \{}
\DoxyCodeLine{00325\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{int})fe-\/>feature\_dimension;}
\DoxyCodeLine{00326\ \}}
\DoxyCodeLine{00327\ }
\DoxyCodeLine{00328\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00329\ fe\_get\_input\_size(fe\_t\ *fe,\ \textcolor{keywordtype}{int}\ *out\_frame\_shift,}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ *out\_frame\_size)}
\DoxyCodeLine{00331\ \{}
\DoxyCodeLine{00332\ \ \ \ \ \textcolor{keywordflow}{if}\ (out\_frame\_shift)}
\DoxyCodeLine{00333\ \ \ \ \ \ \ \ \ *out\_frame\_shift\ =\ fe-\/>frame\_shift;}
\DoxyCodeLine{00334\ \ \ \ \ \textcolor{keywordflow}{if}\ (out\_frame\_size)}
\DoxyCodeLine{00335\ \ \ \ \ \ \ \ \ *out\_frame\_size\ =\ fe-\/>frame\_size;}
\DoxyCodeLine{00336\ \}}
\DoxyCodeLine{00337\ }
\DoxyCodeLine{00338\ int32}
\DoxyCodeLine{00339\ fe\_process\_frame(fe\_t\ *\ fe,\ int16\ \textcolor{keyword}{const}\ *spch,\ int32\ nsamps,\ mfcc\_t\ *\ fr\_cep)}
\DoxyCodeLine{00340\ \{}
\DoxyCodeLine{00341\ \ \ \ \ fe\_read\_frame(fe,\ spch,\ nsamps);}
\DoxyCodeLine{00342\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_write\_frame(fe,\ fr\_cep);}
\DoxyCodeLine{00343\ \}}
\DoxyCodeLine{00344\ }
\DoxyCodeLine{00345\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00346\ fe\_process\_frames(fe\_t\ *fe,}
\DoxyCodeLine{00347\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int16\ \textcolor{keyword}{const}\ **inout\_spch,}
\DoxyCodeLine{00348\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{size\_t}\ *inout\_nsamps,}
\DoxyCodeLine{00349\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mfcc\_t\ **buf\_cep,}
\DoxyCodeLine{00350\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\ *inout\_nframes)}
\DoxyCodeLine{00351\ \{}
\DoxyCodeLine{00352\ \ \ \ \ int32\ frame\_count;}
\DoxyCodeLine{00353\ \ \ \ \ \textcolor{keywordtype}{int}\ outidx,\ i,\ n,\ n\_overflow,\ orig\_n\_overflow;}
\DoxyCodeLine{00354\ \ \ \ \ int16\ \textcolor{keyword}{const}\ *orig\_spch;}
\DoxyCodeLine{00355\ }
\DoxyCodeLine{00356\ \ \ \ \ \textcolor{comment}{/*\ In\ the\ special\ case\ where\ there\ is\ no\ output\ buffer,\ return\ the}}
\DoxyCodeLine{00357\ \textcolor{comment}{\ \ \ \ \ *\ maximum\ number\ of\ frames\ which\ would\ be\ generated.\ */}}
\DoxyCodeLine{00358\ \ \ \ \ \textcolor{keywordflow}{if}\ (buf\_cep\ ==\ NULL)\ \{}
\DoxyCodeLine{00359\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*inout\_nsamps\ +\ fe-\/>num\_overflow\_samps\ <\ (\textcolor{keywordtype}{size\_t})fe-\/>frame\_size)}
\DoxyCodeLine{00360\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_nframes\ =\ 0;}
\DoxyCodeLine{00361\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ }
\DoxyCodeLine{00362\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_nframes\ =\ 1}
\DoxyCodeLine{00363\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\ ((*inout\_nsamps\ +\ fe-\/>num\_overflow\_samps\ -\/\ fe-\/>frame\_size)}
\DoxyCodeLine{00364\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ /\ fe-\/>frame\_shift);}
\DoxyCodeLine{00365\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ *inout\_nframes;}
\DoxyCodeLine{00366\ \ \ \ \ \}}
\DoxyCodeLine{00367\ }
\DoxyCodeLine{00368\ \ \ \ \ \textcolor{comment}{/*\ Are\ there\ not\ enough\ samples\ to\ make\ at\ least\ 1\ frame?\ */}}
\DoxyCodeLine{00369\ \ \ \ \ \textcolor{keywordflow}{if}\ (*inout\_nsamps\ +\ fe-\/>num\_overflow\_samps\ <\ (\textcolor{keywordtype}{size\_t})fe-\/>frame\_size)\ \{}
\DoxyCodeLine{00370\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (*inout\_nsamps\ >\ 0)\ \{}
\DoxyCodeLine{00371\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Append\ them\ to\ the\ overflow\ buffer.\ */}}
\DoxyCodeLine{00372\ \ \ \ \ \ \ \ \ \ \ \ \ memcpy(fe-\/>overflow\_samps\ +\ fe-\/>num\_overflow\_samps,}
\DoxyCodeLine{00373\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch,\ *inout\_nsamps\ *\ (\textcolor{keyword}{sizeof}(int16)));}
\DoxyCodeLine{00374\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ +=\ *inout\_nsamps;}
\DoxyCodeLine{00375\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Update\ input-\/output\ pointers\ and\ counters.\ */}}
\DoxyCodeLine{00376\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ *inout\_nsamps;}
\DoxyCodeLine{00377\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_nsamps\ =\ 0;}
\DoxyCodeLine{00378\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00379\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ We\ produced\ no\ frames\ of\ output,\ sorry!\ */}}
\DoxyCodeLine{00380\ \ \ \ \ \ \ \ \ *inout\_nframes\ =\ 0;}
\DoxyCodeLine{00381\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00382\ \ \ \ \ \}}
\DoxyCodeLine{00383\ }
\DoxyCodeLine{00384\ \ \ \ \ \textcolor{comment}{/*\ Can't\ write\ a\ frame?\ \ Then\ do\ nothing!\ */}}
\DoxyCodeLine{00385\ \ \ \ \ \textcolor{keywordflow}{if}\ (*inout\_nframes\ <\ 1)\ \{}
\DoxyCodeLine{00386\ \ \ \ \ \ \ \ \ *inout\_nframes\ =\ 0;}
\DoxyCodeLine{00387\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00388\ \ \ \ \ \}}
\DoxyCodeLine{00389\ }
\DoxyCodeLine{00390\ \ \ \ \ \textcolor{comment}{/*\ Keep\ track\ of\ the\ original\ start\ of\ the\ buffer.\ */}}
\DoxyCodeLine{00391\ \ \ \ \ orig\_spch\ =\ *inout\_spch;}
\DoxyCodeLine{00392\ \ \ \ \ orig\_n\_overflow\ =\ fe-\/>num\_overflow\_samps;}
\DoxyCodeLine{00393\ \ \ \ \ \textcolor{comment}{/*\ How\ many\ frames\ will\ we\ be\ able\ to\ get?\ */}}
\DoxyCodeLine{00394\ \ \ \ \ frame\_count\ =\ 1}
\DoxyCodeLine{00395\ \ \ \ \ \ \ \ \ +\ ((*inout\_nsamps\ +\ fe-\/>num\_overflow\_samps\ -\/\ fe-\/>frame\_size)}
\DoxyCodeLine{00396\ \ \ \ \ \ \ \ \ \ \ \ /\ fe-\/>frame\_shift);}
\DoxyCodeLine{00397\ \ \ \ \ \textcolor{comment}{/*\ Limit\ it\ to\ the\ number\ of\ output\ frames\ available.\ */}}
\DoxyCodeLine{00398\ \ \ \ \ \textcolor{keywordflow}{if}\ (frame\_count\ >\ *inout\_nframes)}
\DoxyCodeLine{00399\ \ \ \ \ \ \ \ \ frame\_count\ =\ *inout\_nframes;}
\DoxyCodeLine{00400\ \ \ \ \ \textcolor{comment}{/*\ Index\ of\ output\ frame.\ */}}
\DoxyCodeLine{00401\ \ \ \ \ outidx\ =\ 0;}
\DoxyCodeLine{00402\ }
\DoxyCodeLine{00403\ \ \ \ \ \textcolor{comment}{/*\ Start\ processing,\ taking\ care\ of\ any\ incoming\ overflow.\ */}}
\DoxyCodeLine{00404\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps)\ \{}
\DoxyCodeLine{00405\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ offset\ =\ fe-\/>frame\_size\ -\/\ fe-\/>num\_overflow\_samps;}
\DoxyCodeLine{00406\ }
\DoxyCodeLine{00407\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Append\ start\ of\ spch\ to\ overflow\ samples\ to\ make\ a\ full\ frame.\ */}}
\DoxyCodeLine{00408\ \ \ \ \ \ \ \ \ memcpy(fe-\/>overflow\_samps\ +\ fe-\/>num\_overflow\_samps,}
\DoxyCodeLine{00409\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch,\ offset\ *\ \textcolor{keyword}{sizeof}(**inout\_spch));}
\DoxyCodeLine{00410\ \ \ \ \ \ \ \ \ fe\_read\_frame(fe,\ fe-\/>overflow\_samps,\ fe-\/>frame\_size);}
\DoxyCodeLine{00411\ \ \ \ \ \ \ \ \ assert(outidx\ <\ frame\_count);}
\DoxyCodeLine{00412\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((n\ =\ fe\_write\_frame(fe,\ buf\_cep[outidx]))\ <\ 0)}
\DoxyCodeLine{00413\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00414\ \ \ \ \ \ \ \ \ outidx\ +=\ n;}
\DoxyCodeLine{00415\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Update\ input-\/output\ pointers\ and\ counters.\ */}}
\DoxyCodeLine{00416\ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ offset;}
\DoxyCodeLine{00417\ \ \ \ \ \ \ \ \ *inout\_nsamps\ -\/=\ offset;}
\DoxyCodeLine{00418\ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ -\/=\ fe-\/>frame\_shift;}
\DoxyCodeLine{00419\ \ \ \ \ \}}
\DoxyCodeLine{00420\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00421\ \ \ \ \ \ \ \ \ fe\_read\_frame(fe,\ *inout\_spch,\ fe-\/>frame\_size);}
\DoxyCodeLine{00422\ \ \ \ \ \ \ \ \ assert(outidx\ <\ frame\_count);}
\DoxyCodeLine{00423\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((n\ =\ fe\_write\_frame(fe,\ buf\_cep[outidx]))\ <\ 0)}
\DoxyCodeLine{00424\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00425\ \ \ \ \ \ \ \ \ outidx\ +=\ n;}
\DoxyCodeLine{00426\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Update\ input-\/output\ pointers\ and\ counters.\ */}}
\DoxyCodeLine{00427\ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ fe-\/>frame\_size;}
\DoxyCodeLine{00428\ \ \ \ \ \ \ \ \ *inout\_nsamps\ -\/=\ fe-\/>frame\_size;}
\DoxyCodeLine{00429\ \ \ \ \ \}}
\DoxyCodeLine{00430\ }
\DoxyCodeLine{00431\ \ \ \ \ \textcolor{comment}{/*\ Process\ all\ remaining\ frames.\ */}}
\DoxyCodeLine{00432\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ frame\_count;\ ++i)\ \{}
\DoxyCodeLine{00433\ \ \ \ \ \ \ \ \ assert(*inout\_nsamps\ >=\ (\textcolor{keywordtype}{size\_t})fe-\/>frame\_shift);}
\DoxyCodeLine{00434\ }
\DoxyCodeLine{00435\ \ \ \ \ \ \ \ \ fe\_shift\_frame(fe,\ *inout\_spch,\ fe-\/>frame\_shift);}
\DoxyCodeLine{00436\ \ \ \ \ \ \ \ \ assert(outidx\ <\ frame\_count);}
\DoxyCodeLine{00437\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((n\ =\ fe\_write\_frame(fe,\ buf\_cep[outidx]))\ <\ 0)}
\DoxyCodeLine{00438\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00439\ \ \ \ \ \ \ \ \ outidx\ +=\ n;}
\DoxyCodeLine{00440\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Update\ input-\/output\ pointers\ and\ counters.\ */}}
\DoxyCodeLine{00441\ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ fe-\/>frame\_shift;}
\DoxyCodeLine{00442\ \ \ \ \ \ \ \ \ *inout\_nsamps\ -\/=\ fe-\/>frame\_shift;}
\DoxyCodeLine{00443\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Amount\ of\ data\ behind\ the\ original\ input\ which\ is\ still\ needed.\ */}}
\DoxyCodeLine{00444\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps\ >\ 0)}
\DoxyCodeLine{00445\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ -\/=\ fe-\/>frame\_shift;}
\DoxyCodeLine{00446\ \ \ \ \ \}}
\DoxyCodeLine{00447\ }
\DoxyCodeLine{00448\ \ \ \ \ \textcolor{comment}{/*\ How\ many\ relevant\ overflow\ samples\ are\ there\ left?\ */}}
\DoxyCodeLine{00449\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps\ <=\ 0)\ \{}
\DoxyCodeLine{00450\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Maximum\ number\ of\ overflow\ samples\ past\ *inout\_spch\ to\ save.\ */}}
\DoxyCodeLine{00451\ \ \ \ \ \ \ \ \ n\_overflow\ =\ *inout\_nsamps;}
\DoxyCodeLine{00452\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (n\_overflow\ >\ fe-\/>frame\_shift)}
\DoxyCodeLine{00453\ \ \ \ \ \ \ \ \ \ \ \ \ n\_overflow\ =\ fe-\/>frame\_shift;}
\DoxyCodeLine{00454\ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ =\ fe-\/>frame\_size\ -\/\ fe-\/>frame\_shift;}
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Make\ sure\ this\ isn't\ an\ illegal\ read!\ */}}
\DoxyCodeLine{00456\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps\ >\ *inout\_spch\ -\/\ orig\_spch)}
\DoxyCodeLine{00457\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ =\ *inout\_spch\ -\/\ orig\_spch;}
\DoxyCodeLine{00458\ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ +=\ n\_overflow;}
\DoxyCodeLine{00459\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps\ >\ 0)\ \{}
\DoxyCodeLine{00460\ \ \ \ \ \ \ \ \ \ \ \ \ memcpy(fe-\/>overflow\_samps,}
\DoxyCodeLine{00461\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch\ -\/\ (fe-\/>frame\_size\ -\/\ fe-\/>frame\_shift),}
\DoxyCodeLine{00462\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ *\ \textcolor{keyword}{sizeof}(**inout\_spch));}
\DoxyCodeLine{00463\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Update\ the\ input\ pointer\ to\ cover\ this\ stuff.\ */}}
\DoxyCodeLine{00464\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ n\_overflow;}
\DoxyCodeLine{00465\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_nsamps\ -\/=\ n\_overflow;}
\DoxyCodeLine{00466\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00467\ \ \ \ \ \}}
\DoxyCodeLine{00468\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00469\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ There\ is\ still\ some\ relevant\ data\ left\ in\ the\ overflow\ buffer.\ */}}
\DoxyCodeLine{00470\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Shift\ existing\ data\ to\ the\ beginning.\ */}}
\DoxyCodeLine{00471\ \ \ \ \ \ \ \ \ memmove(fe-\/>overflow\_samps,}
\DoxyCodeLine{00472\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>overflow\_samps\ +\ orig\_n\_overflow\ -\/\ fe-\/>num\_overflow\_samps,}
\DoxyCodeLine{00473\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ *\ \textcolor{keyword}{sizeof}(*fe-\/>overflow\_samps));}
\DoxyCodeLine{00474\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Copy\ in\ whatever\ we\ had\ in\ the\ original\ speech\ buffer.\ */}}
\DoxyCodeLine{00475\ \ \ \ \ \ \ \ \ n\_overflow\ =\ *inout\_spch\ -\/\ orig\_spch\ +\ *inout\_nsamps;}
\DoxyCodeLine{00476\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (n\_overflow\ >\ fe-\/>frame\_size\ -\/\ fe-\/>num\_overflow\_samps)}
\DoxyCodeLine{00477\ \ \ \ \ \ \ \ \ \ \ \ \ n\_overflow\ =\ fe-\/>frame\_size\ -\/\ fe-\/>num\_overflow\_samps;}
\DoxyCodeLine{00478\ \ \ \ \ \ \ \ \ memcpy(fe-\/>overflow\_samps\ +\ fe-\/>num\_overflow\_samps,}
\DoxyCodeLine{00479\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ orig\_spch,\ n\_overflow\ *\ \textcolor{keyword}{sizeof}(*orig\_spch));}
\DoxyCodeLine{00480\ \ \ \ \ \ \ \ \ fe-\/>num\_overflow\_samps\ +=\ n\_overflow;}
\DoxyCodeLine{00481\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Advance\ the\ input\ pointers.\ */}}
\DoxyCodeLine{00482\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (n\_overflow\ >\ *inout\_spch\ -\/\ orig\_spch)\ \{}
\DoxyCodeLine{00483\ \ \ \ \ \ \ \ \ \ \ \ \ n\_overflow\ -\/=\ (*inout\_spch\ -\/\ orig\_spch);}
\DoxyCodeLine{00484\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_spch\ +=\ n\_overflow;}
\DoxyCodeLine{00485\ \ \ \ \ \ \ \ \ \ \ \ \ *inout\_nsamps\ -\/=\ n\_overflow;}
\DoxyCodeLine{00486\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00487\ \ \ \ \ \}}
\DoxyCodeLine{00488\ }
\DoxyCodeLine{00489\ \ \ \ \ \textcolor{comment}{/*\ Finally\ update\ the\ frame\ counter\ with\ the\ number\ of\ frames\ we\ procesed.\ */}}
\DoxyCodeLine{00490\ \ \ \ \ *inout\_nframes\ =\ outidx;\ \textcolor{comment}{/*\ FIXME:\ Not\ sure\ why\ I\ wrote\ it\ this\ way...\ */}}
\DoxyCodeLine{00491\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00492\ \}}
\DoxyCodeLine{00493\ }
\DoxyCodeLine{00494\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00495\ fe\_process\_utt(fe\_t\ *\ fe,\ int16\ \textcolor{keyword}{const}\ *\ spch,\ \textcolor{keywordtype}{size\_t}\ nsamps,}
\DoxyCodeLine{00496\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mfcc\_t\ ***\ cep\_block,\ int32\ *\ nframes)}
\DoxyCodeLine{00497\ \{}
\DoxyCodeLine{00498\ \ \ \ \ mfcc\_t\ **cep;}
\DoxyCodeLine{00499\ \ \ \ \ \textcolor{keywordtype}{int}\ rv;}
\DoxyCodeLine{00500\ }
\DoxyCodeLine{00501\ \ \ \ \ \textcolor{comment}{/*\ Figure\ out\ how\ many\ frames\ we\ will\ need.\ */}}
\DoxyCodeLine{00502\ \ \ \ \ fe\_process\_frames(fe,\ NULL,\ \&nsamps,\ NULL,\ nframes);}
\DoxyCodeLine{00503\ \ \ \ \ \textcolor{comment}{/*\ Create\ the\ output\ buffer\ (it\ has\ to\ exist,\ even\ if\ there\ are\ no\ output\ frames).\ */}}
\DoxyCodeLine{00504\ \ \ \ \ \textcolor{keywordflow}{if}\ (*nframes)}
\DoxyCodeLine{00505\ \ \ \ \ \ \ \ \ cep\ =\ (mfcc\_t\ **)ckd\_calloc\_2d(*nframes,\ fe-\/>feature\_dimension,\ \textcolor{keyword}{sizeof}(**cep));}
\DoxyCodeLine{00506\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00507\ \ \ \ \ \ \ \ \ cep\ =\ (mfcc\_t\ **)ckd\_calloc\_2d(1,\ fe-\/>feature\_dimension,\ \textcolor{keyword}{sizeof}(**cep));}
\DoxyCodeLine{00508\ \ \ \ \ \textcolor{comment}{/*\ Now\ just\ call\ fe\_process\_frames()\ with\ the\ allocated\ buffer.\ */}}
\DoxyCodeLine{00509\ \ \ \ \ rv\ =\ fe\_process\_frames(fe,\ \&spch,\ \&nsamps,\ cep,\ nframes);}
\DoxyCodeLine{00510\ \ \ \ \ *cep\_block\ =\ cep;}
\DoxyCodeLine{00511\ }
\DoxyCodeLine{00512\ \ \ \ \ \textcolor{keywordflow}{return}\ rv;}
\DoxyCodeLine{00513\ \}}
\DoxyCodeLine{00514\ }
\DoxyCodeLine{00515\ }
\DoxyCodeLine{00516\ int32}
\DoxyCodeLine{00517\ fe\_end\_utt(fe\_t\ *\ fe,\ mfcc\_t\ *\ cepvector,\ int32\ *\ nframes)}
\DoxyCodeLine{00518\ \{}
\DoxyCodeLine{00519\ \ \ \ \ \textcolor{comment}{/*\ Process\ any\ remaining\ data.\ */}}
\DoxyCodeLine{00520\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>num\_overflow\_samps\ >\ 0)\ \{}
\DoxyCodeLine{00521\ \ \ \ \ \ \ \ \ fe\_read\_frame(fe,\ fe-\/>overflow\_samps,\ fe-\/>num\_overflow\_samps);}
\DoxyCodeLine{00522\ \ \ \ \ \ \ \ \ *nframes\ =\ fe\_write\_frame(fe,\ cepvector);}
\DoxyCodeLine{00523\ \ \ \ \ \}}
\DoxyCodeLine{00524\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00525\ \ \ \ \ \ \ \ \ *nframes\ =\ 0;}
\DoxyCodeLine{00526\ \ \ \ \ \}}
\DoxyCodeLine{00527\ }
\DoxyCodeLine{00528\ \ \ \ \ \textcolor{comment}{/*\ reset\ overflow\ buffers...\ */}}
\DoxyCodeLine{00529\ \ \ \ \ fe-\/>num\_overflow\_samps\ =\ 0;}
\DoxyCodeLine{00530\ \ \ \ \ fe-\/>start\_flag\ =\ 0;}
\DoxyCodeLine{00531\ }
\DoxyCodeLine{00532\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00533\ \}}
\DoxyCodeLine{00534\ }
\DoxyCodeLine{00535\ fe\_t\ *}
\DoxyCodeLine{00536\ fe\_retain(fe\_t\ *fe)}
\DoxyCodeLine{00537\ \{}
\DoxyCodeLine{00538\ \ \ \ \ ++fe-\/>refcount;}
\DoxyCodeLine{00539\ \ \ \ \ \textcolor{keywordflow}{return}\ fe;}
\DoxyCodeLine{00540\ \}}
\DoxyCodeLine{00541\ }
\DoxyCodeLine{00542\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00543\ fe\_free(fe\_t\ *\ fe)}
\DoxyCodeLine{00544\ \{}
\DoxyCodeLine{00545\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe\ ==\ NULL)}
\DoxyCodeLine{00546\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00547\ \ \ \ \ \textcolor{keywordflow}{if}\ (-\/-\/fe-\/>refcount\ >\ 0)}
\DoxyCodeLine{00548\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ fe-\/>refcount;}
\DoxyCodeLine{00549\ }
\DoxyCodeLine{00550\ \ \ \ \ \textcolor{comment}{/*\ kill\ FE\ instance\ -\/\ free\ everything...\ */}}
\DoxyCodeLine{00551\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>mel\_fb)\ \{}
\DoxyCodeLine{00552\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>mel\_fb-\/>mel\_cosine)}
\DoxyCodeLine{00553\ \ \ \ \ \ \ \ \ \ \ \ \ fe\_free\_2d((\textcolor{keywordtype}{void}\ *)\ fe-\/>mel\_fb-\/>mel\_cosine);}
\DoxyCodeLine{00554\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb-\/>lifter);}
\DoxyCodeLine{00555\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb-\/>spec\_start);}
\DoxyCodeLine{00556\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb-\/>filt\_start);}
\DoxyCodeLine{00557\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb-\/>filt\_width);}
\DoxyCodeLine{00558\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb-\/>filt\_coeffs);}
\DoxyCodeLine{00559\ \ \ \ \ \ \ \ \ ckd\_free(fe-\/>mel\_fb);}
\DoxyCodeLine{00560\ \ \ \ \ \}}
\DoxyCodeLine{00561\ \ \ \ \ ckd\_free(fe-\/>spch);}
\DoxyCodeLine{00562\ \ \ \ \ ckd\_free(fe-\/>frame);}
\DoxyCodeLine{00563\ \ \ \ \ ckd\_free(fe-\/>ccc);}
\DoxyCodeLine{00564\ \ \ \ \ ckd\_free(fe-\/>sss);}
\DoxyCodeLine{00565\ \ \ \ \ ckd\_free(fe-\/>spec);}
\DoxyCodeLine{00566\ \ \ \ \ ckd\_free(fe-\/>mfspec);}
\DoxyCodeLine{00567\ \ \ \ \ ckd\_free(fe-\/>overflow\_samps);}
\DoxyCodeLine{00568\ \ \ \ \ ckd\_free(fe-\/>hamming\_window);}
\DoxyCodeLine{00569\ \ \ \ \ cmd\_ln\_free\_r(fe-\/>config);}
\DoxyCodeLine{00570\ \ \ \ \ ckd\_free(fe);}
\DoxyCodeLine{00571\ }
\DoxyCodeLine{00572\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00573\ \}}
\DoxyCodeLine{00574\ }
\DoxyCodeLine{00578\ int32}
\DoxyCodeLine{00579\ fe\_mfcc\_to\_float(fe\_t\ *\ fe,}
\DoxyCodeLine{00580\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mfcc\_t\ **\ input,\ float32\ **\ output,\ int32\ nframes)}
\DoxyCodeLine{00581\ \{}
\DoxyCodeLine{00582\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00583\ }
\DoxyCodeLine{00584\ \textcolor{preprocessor}{\#ifndef\ FIXED\_POINT}}
\DoxyCodeLine{00585\ \ \ \ \ \textcolor{keywordflow}{if}\ ((\textcolor{keywordtype}{void}\ *)\ input\ ==\ (\textcolor{keywordtype}{void}\ *)\ output)}
\DoxyCodeLine{00586\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ nframes\ *\ fe-\/>feature\_dimension;}
\DoxyCodeLine{00587\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00588\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ nframes\ *\ fe-\/>feature\_dimension;\ ++i)}
\DoxyCodeLine{00589\ \ \ \ \ \ \ \ \ output[0][i]\ =\ MFCC2FLOAT(input[0][i]);}
\DoxyCodeLine{00590\ }
\DoxyCodeLine{00591\ \ \ \ \ \textcolor{keywordflow}{return}\ i;}
\DoxyCodeLine{00592\ \}}
\DoxyCodeLine{00593\ }
\DoxyCodeLine{00597\ int32}
\DoxyCodeLine{00598\ fe\_float\_to\_mfcc(fe\_t\ *\ fe,}
\DoxyCodeLine{00599\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ float32\ **\ input,\ mfcc\_t\ **\ output,\ int32\ nframes)}
\DoxyCodeLine{00600\ \{}
\DoxyCodeLine{00601\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00602\ }
\DoxyCodeLine{00603\ \textcolor{preprocessor}{\#ifndef\ FIXED\_POINT}}
\DoxyCodeLine{00604\ \ \ \ \ \textcolor{keywordflow}{if}\ ((\textcolor{keywordtype}{void}\ *)\ input\ ==\ (\textcolor{keywordtype}{void}\ *)\ output)}
\DoxyCodeLine{00605\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ nframes\ *\ fe-\/>feature\_dimension;}
\DoxyCodeLine{00606\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00607\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ nframes\ *\ fe-\/>feature\_dimension;\ ++i)}
\DoxyCodeLine{00608\ \ \ \ \ \ \ \ \ output[0][i]\ =\ FLOAT2MFCC(input[0][i]);}
\DoxyCodeLine{00609\ }
\DoxyCodeLine{00610\ \ \ \ \ \textcolor{keywordflow}{return}\ i;}
\DoxyCodeLine{00611\ \}}
\DoxyCodeLine{00612\ }
\DoxyCodeLine{00613\ int32}
\DoxyCodeLine{00614\ fe\_logspec\_to\_mfcc(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ mfcc\_t\ *\ fr\_spec,\ mfcc\_t\ *\ fr\_cep)}
\DoxyCodeLine{00615\ \{}
\DoxyCodeLine{00616\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00617\ \ \ \ \ fe\_spec2cep(fe,\ fr\_spec,\ fr\_cep);}
\DoxyCodeLine{00618\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00619\ \ \ \ \ powspec\_t\ *powspec;}
\DoxyCodeLine{00620\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00621\ }
\DoxyCodeLine{00622\ \ \ \ \ powspec\ =\ ckd\_malloc(fe-\/>mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(powspec\_t));}
\DoxyCodeLine{00623\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>num\_filters;\ ++i)}
\DoxyCodeLine{00624\ \ \ \ \ \ \ \ \ powspec[i]\ =\ (powspec\_t)\ fr\_spec[i];}
\DoxyCodeLine{00625\ \ \ \ \ fe\_spec2cep(fe,\ powspec,\ fr\_cep);}
\DoxyCodeLine{00626\ \ \ \ \ ckd\_free(powspec);}
\DoxyCodeLine{00627\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00628\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00629\ \}}
\DoxyCodeLine{00630\ }
\DoxyCodeLine{00631\ int32}
\DoxyCodeLine{00632\ fe\_logspec\_dct2(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ mfcc\_t\ *\ fr\_spec,\ mfcc\_t\ *\ fr\_cep)}
\DoxyCodeLine{00633\ \{}
\DoxyCodeLine{00634\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00635\ \ \ \ \ fe\_dct2(fe,\ fr\_spec,\ fr\_cep,\ 0);}
\DoxyCodeLine{00636\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00637\ \ \ \ \ powspec\_t\ *powspec;}
\DoxyCodeLine{00638\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00639\ }
\DoxyCodeLine{00640\ \ \ \ \ powspec\ =\ ckd\_malloc(fe-\/>mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(powspec\_t));}
\DoxyCodeLine{00641\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>num\_filters;\ ++i)}
\DoxyCodeLine{00642\ \ \ \ \ \ \ \ \ powspec[i]\ =\ (powspec\_t)\ fr\_spec[i];}
\DoxyCodeLine{00643\ \ \ \ \ fe\_dct2(fe,\ powspec,\ fr\_cep,\ 0);}
\DoxyCodeLine{00644\ \ \ \ \ ckd\_free(powspec);}
\DoxyCodeLine{00645\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00646\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00647\ \}}
\DoxyCodeLine{00648\ }
\DoxyCodeLine{00649\ int32}
\DoxyCodeLine{00650\ fe\_mfcc\_dct3(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ mfcc\_t\ *\ fr\_cep,\ mfcc\_t\ *\ fr\_spec)}
\DoxyCodeLine{00651\ \{}
\DoxyCodeLine{00652\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00653\ \ \ \ \ fe\_dct3(fe,\ fr\_cep,\ fr\_spec);}
\DoxyCodeLine{00654\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00655\ \ \ \ \ powspec\_t\ *powspec;}
\DoxyCodeLine{00656\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00657\ }
\DoxyCodeLine{00658\ \ \ \ \ powspec\ =\ ckd\_malloc(fe-\/>mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(powspec\_t));}
\DoxyCodeLine{00659\ \ \ \ \ fe\_dct3(fe,\ fr\_cep,\ powspec);}
\DoxyCodeLine{00660\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>num\_filters;\ ++i)}
\DoxyCodeLine{00661\ \ \ \ \ \ \ \ \ fr\_spec[i]\ =\ (mfcc\_t)\ powspec[i];}
\DoxyCodeLine{00662\ \ \ \ \ ckd\_free(powspec);}
\DoxyCodeLine{00663\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00664\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00665\ \}}

\end{DoxyCode}
