\doxysection{fe\+\_\+sigproc.\+c}
\label{fe__sigproc_8c_source}\index{src/libsphinxbase/fe/fe\_sigproc.c@{src/libsphinxbase/fe/fe\_sigproc.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\ }
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ <math.h>}}
\DoxyCodeLine{00040\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#include\ <assert.h>}}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#include\ <config.h>}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \textcolor{preprocessor}{\#ifdef\ \_MSC\_VER}}
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#pragma\ warning\ (disable:\ 4244)}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00055\ \textcolor{preprocessor}{\#ifndef\ M\_PI}}
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#define\ M\_PI\ \ \ \ \ \ \ \ \ \ \ \ 3.14159265358979323846\ \ }\textcolor{comment}{/*\ pi\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00057\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ M\_PI}}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/prim\_type.h"{}}}
\DoxyCodeLine{00060\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/ckd\_alloc.h"{}}}
\DoxyCodeLine{00061\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/byteorder.h"{}}}
\DoxyCodeLine{00062\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/fixpoint.h"{}}}
\DoxyCodeLine{00063\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/fe.h"{}}}
\DoxyCodeLine{00064\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/genrand.h"{}}}
\DoxyCodeLine{00065\ \textcolor{preprocessor}{\#include\ "{}sphinxbase/err.h"{}}}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\#include\ "{}fe\_internal.h"{}}}
\DoxyCodeLine{00068\ \textcolor{preprocessor}{\#include\ "{}fe\_warp.h"{}}}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{comment}{/*\ Use\ extra\ precision\ for\ cosines,\ Hamming\ window,\ pre-\/emphasis}}
\DoxyCodeLine{00071\ \textcolor{comment}{\ *\ coefficient,\ twiddle\ factors.\ */}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\#define\ FLOAT2COS(x)\ FLOAT2FIX\_ANY(x,30)}}
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\#define\ COSMUL(x,y)\ FIXMUL\_ANY(x,y,30)}}
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00076\ \textcolor{preprocessor}{\#define\ FLOAT2COS(x)\ (x)}}
\DoxyCodeLine{00077\ \textcolor{preprocessor}{\#define\ COSMUL(x,y)\ ((x)*(y))}}
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00081\ \textcolor{comment}{/*\ Internal\ log-\/addition\ table\ for\ natural\ log\ with\ radix\ point\ at\ 8}}
\DoxyCodeLine{00082\ \textcolor{comment}{\ *\ bits.\ \ Each\ entry\ is\ 256\ *\ log(1\ +\ e\string^\{-\/n/256\}).\ \ This\ is\ used\ in\ the}}
\DoxyCodeLine{00083\ \textcolor{comment}{\ *\ log-\/add\ computation:}}
\DoxyCodeLine{00084\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00085\ \textcolor{comment}{\ *\ e\string^z\ =\ e\string^x\ +\ e\string^y}}
\DoxyCodeLine{00086\ \textcolor{comment}{\ *\ e\string^z\ =\ e\string^x(1\ +\ e\string^\{y-\/x\})\ \ \ \ \ =\ e\string^y(1\ +\ e\string^\{x-\/y\})}}
\DoxyCodeLine{00087\ \textcolor{comment}{\ *\ z\ \ \ =\ x\ +\ log(1\ +\ e\string^\{y-\/x\})\ =\ y\ +\ log(1\ +\ e\string^\{x-\/y\})}}
\DoxyCodeLine{00088\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00089\ \textcolor{comment}{\ *\ So\ when\ y\ >\ x,\ z\ =\ y\ +\ logadd\_table[-\/(x-\/y)]}}
\DoxyCodeLine{00090\ \textcolor{comment}{\ *\ \ \ \ when\ x\ >\ y,\ z\ =\ x\ +\ logadd\_table[-\/(y-\/x)]}}
\DoxyCodeLine{00091\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00092\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{char}\ fe\_logadd\_table[]\ =\ \{}
\DoxyCodeLine{00093\ 177,\ 177,\ 176,\ 176,\ 175,\ 175,\ 174,\ 174,\ 173,\ 173,}
\DoxyCodeLine{00094\ 172,\ 172,\ 172,\ 171,\ 171,\ 170,\ 170,\ 169,\ 169,\ 168,}
\DoxyCodeLine{00095\ 168,\ 167,\ 167,\ 166,\ 166,\ 165,\ 165,\ 164,\ 164,\ 163,}
\DoxyCodeLine{00096\ 163,\ 162,\ 162,\ 161,\ 161,\ 161,\ 160,\ 160,\ 159,\ 159,}
\DoxyCodeLine{00097\ 158,\ 158,\ 157,\ 157,\ 156,\ 156,\ 155,\ 155,\ 155,\ 154,}
\DoxyCodeLine{00098\ 154,\ 153,\ 153,\ 152,\ 152,\ 151,\ 151,\ 151,\ 150,\ 150,}
\DoxyCodeLine{00099\ 149,\ 149,\ 148,\ 148,\ 147,\ 147,\ 147,\ 146,\ 146,\ 145,}
\DoxyCodeLine{00100\ 145,\ 144,\ 144,\ 144,\ 143,\ 143,\ 142,\ 142,\ 141,\ 141,}
\DoxyCodeLine{00101\ 141,\ 140,\ 140,\ 139,\ 139,\ 138,\ 138,\ 138,\ 137,\ 137,}
\DoxyCodeLine{00102\ 136,\ 136,\ 136,\ 135,\ 135,\ 134,\ 134,\ 134,\ 133,\ 133,}
\DoxyCodeLine{00103\ 132,\ 132,\ 131,\ 131,\ 131,\ 130,\ 130,\ 129,\ 129,\ 129,}
\DoxyCodeLine{00104\ 128,\ 128,\ 128,\ 127,\ 127,\ 126,\ 126,\ 126,\ 125,\ 125,}
\DoxyCodeLine{00105\ 124,\ 124,\ 124,\ 123,\ 123,\ 123,\ 122,\ 122,\ 121,\ 121,}
\DoxyCodeLine{00106\ 121,\ 120,\ 120,\ 119,\ 119,\ 119,\ 118,\ 118,\ 118,\ 117,}
\DoxyCodeLine{00107\ 117,\ 117,\ 116,\ 116,\ 115,\ 115,\ 115,\ 114,\ 114,\ 114,}
\DoxyCodeLine{00108\ 113,\ 113,\ 113,\ 112,\ 112,\ 112,\ 111,\ 111,\ 110,\ 110,}
\DoxyCodeLine{00109\ 110,\ 109,\ 109,\ 109,\ 108,\ 108,\ 108,\ 107,\ 107,\ 107,}
\DoxyCodeLine{00110\ 106,\ 106,\ 106,\ 105,\ 105,\ 105,\ 104,\ 104,\ 104,\ 103,}
\DoxyCodeLine{00111\ 103,\ 103,\ 102,\ 102,\ 102,\ 101,\ 101,\ 101,\ 100,\ 100,}
\DoxyCodeLine{00112\ 100,\ 99,\ 99,\ 99,\ 98,\ 98,\ 98,\ 97,\ 97,\ 97,}
\DoxyCodeLine{00113\ 96,\ 96,\ 96,\ 96,\ 95,\ 95,\ 95,\ 94,\ 94,\ 94,}
\DoxyCodeLine{00114\ 93,\ 93,\ 93,\ 92,\ 92,\ 92,\ 92,\ 91,\ 91,\ 91,}
\DoxyCodeLine{00115\ 90,\ 90,\ 90,\ 89,\ 89,\ 89,\ 89,\ 88,\ 88,\ 88,}
\DoxyCodeLine{00116\ 87,\ 87,\ 87,\ 87,\ 86,\ 86,\ 86,\ 85,\ 85,\ 85,}
\DoxyCodeLine{00117\ 85,\ 84,\ 84,\ 84,\ 83,\ 83,\ 83,\ 83,\ 82,\ 82,}
\DoxyCodeLine{00118\ 82,\ 82,\ 81,\ 81,\ 81,\ 80,\ 80,\ 80,\ 80,\ 79,}
\DoxyCodeLine{00119\ 79,\ 79,\ 79,\ 78,\ 78,\ 78,\ 78,\ 77,\ 77,\ 77,}
\DoxyCodeLine{00120\ 77,\ 76,\ 76,\ 76,\ 75,\ 75,\ 75,\ 75,\ 74,\ 74,}
\DoxyCodeLine{00121\ 74,\ 74,\ 73,\ 73,\ 73,\ 73,\ 72,\ 72,\ 72,\ 72,}
\DoxyCodeLine{00122\ 71,\ 71,\ 71,\ 71,\ 71,\ 70,\ 70,\ 70,\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,\ 1,}
\DoxyCodeLine{00249\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,}
\DoxyCodeLine{00250\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,}
\DoxyCodeLine{00251\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,}
\DoxyCodeLine{00252\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 1,\ 0}
\DoxyCodeLine{00253\ \};}
\DoxyCodeLine{00254\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ fe\_logadd\_table\_size\ =\ \textcolor{keyword}{sizeof}(fe\_logadd\_table)\ /\ \textcolor{keyword}{sizeof}(fe\_logadd\_table[0]);}
\DoxyCodeLine{00255\ }
\DoxyCodeLine{00256\ \textcolor{keyword}{static}\ fixed32}
\DoxyCodeLine{00257\ fe\_log\_add(fixed32\ x,\ fixed32\ y)}
\DoxyCodeLine{00258\ \{}
\DoxyCodeLine{00259\ \ \ \ \ fixed32\ d,\ r;}
\DoxyCodeLine{00260\ }
\DoxyCodeLine{00261\ \ \ \ \ \textcolor{keywordflow}{if}\ (x\ >\ y)\ \{}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ d\ =\ (x\ -\/\ y)\ >>\ (DEFAULT\_RADIX\ -\/\ 8);}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ r\ =\ x;}
\DoxyCodeLine{00264\ \ \ \ \ \}}
\DoxyCodeLine{00265\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00266\ \ \ \ \ \ \ \ \ d\ =\ (y\ -\/\ x)\ >>\ (DEFAULT\_RADIX\ -\/\ 8);}
\DoxyCodeLine{00267\ \ \ \ \ \ \ \ \ r\ =\ y;}
\DoxyCodeLine{00268\ \ \ \ \ \}}
\DoxyCodeLine{00269\ \ \ \ \ \textcolor{keywordflow}{if}\ (d\ >\ fe\_logadd\_table\_size\ -\/\ 1)}
\DoxyCodeLine{00270\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ r;}
\DoxyCodeLine{00271\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00272\ \ \ \ \ \ \ \ \ r\ +=\ ((fixed32)fe\_logadd\_table[d]\ <<\ (DEFAULT\_RADIX\ -\/\ 8));}
\DoxyCodeLine{00273\ \textcolor{comment}{/*}}
\DoxyCodeLine{00274\ \textcolor{comment}{\ \ \ \ \ \ \ \ printf("{}\%d\ +\ \%d\ =\ \%d\ |\ \%f\ +\ \%f\ =\ \%f\ |\ \%f\ +\ \%f\ =\ \%f\(\backslash\)n"{},}}
\DoxyCodeLine{00275\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x,\ y,\ r,\ FIX2FLOAT(x),\ FIX2FLOAT(y),\ FIX2FLOAT(r),}}
\DoxyCodeLine{00276\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ exp(FIX2FLOAT(x)),\ exp(FIX2FLOAT(y)),\ exp(FIX2FLOAT(r)));}}
\DoxyCodeLine{00277\ \textcolor{comment}{*/}}
\DoxyCodeLine{00278\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ r;}
\DoxyCodeLine{00279\ \ \ \ \ \}}
\DoxyCodeLine{00280\ \}}
\DoxyCodeLine{00281\ }
\DoxyCodeLine{00282\ \textcolor{keyword}{static}\ fixed32}
\DoxyCodeLine{00283\ fe\_log(float32\ x)}
\DoxyCodeLine{00284\ \{}
\DoxyCodeLine{00285\ \ \ \ \ \textcolor{keywordflow}{if}\ (x\ <=\ 0)\ \{}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ MIN\_FIXLOG;}
\DoxyCodeLine{00287\ \ \ \ \ \}}
\DoxyCodeLine{00288\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ FLOAT2FIX(log(x));}
\DoxyCodeLine{00290\ \ \ \ \ \}}
\DoxyCodeLine{00291\ \}}
\DoxyCodeLine{00292\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00293\ }
\DoxyCodeLine{00294\ \textcolor{keyword}{static}\ float32}
\DoxyCodeLine{00295\ fe\_mel(melfb\_t\ *mel,\ float32\ x)}
\DoxyCodeLine{00296\ \{}
\DoxyCodeLine{00297\ \ \ \ \ float32\ warped\ =\ fe\_warp\_unwarped\_to\_warped(mel,\ x);}
\DoxyCodeLine{00298\ }
\DoxyCodeLine{00299\ \ \ \ \ \textcolor{keywordflow}{return}\ (float32)\ (2595.0\ *\ log10(1.0\ +\ warped\ /\ 700.0));}
\DoxyCodeLine{00300\ \}}
\DoxyCodeLine{00301\ }
\DoxyCodeLine{00302\ \textcolor{keyword}{static}\ float32}
\DoxyCodeLine{00303\ fe\_melinv(melfb\_t\ *mel,\ float32\ x)}
\DoxyCodeLine{00304\ \{}
\DoxyCodeLine{00305\ \ \ \ \ float32\ warped\ =\ (float32)\ (700.0\ *\ (pow(10.0,\ x\ /\ 2595.0)\ -\/\ 1.0));}
\DoxyCodeLine{00306\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_warp\_warped\_to\_unwarped(mel,\ warped);}
\DoxyCodeLine{00307\ \}}
\DoxyCodeLine{00308\ }
\DoxyCodeLine{00309\ int32}
\DoxyCodeLine{00310\ fe\_build\_melfilters(melfb\_t\ *mel\_fb)}
\DoxyCodeLine{00311\ \{}
\DoxyCodeLine{00312\ \ \ \ \ float32\ melmin,\ melmax,\ melbw,\ fftfreq;}
\DoxyCodeLine{00313\ \ \ \ \ \textcolor{keywordtype}{int}\ n\_coeffs,\ i,\ j;}
\DoxyCodeLine{00314\ }
\DoxyCodeLine{00315\ \ \ \ \ \textcolor{comment}{/*\ Filter\ coefficient\ matrix,\ in\ flattened\ form.\ */}}
\DoxyCodeLine{00316\ \ \ \ \ mel\_fb-\/>spec\_start\ =\ ckd\_malloc(mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(*mel\_fb-\/>spec\_start));}
\DoxyCodeLine{00317\ \ \ \ \ mel\_fb-\/>filt\_start\ =\ ckd\_malloc(mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(*mel\_fb-\/>filt\_start));}
\DoxyCodeLine{00318\ \ \ \ \ mel\_fb-\/>filt\_width\ =\ ckd\_malloc(mel\_fb-\/>num\_filters\ *\ \textcolor{keyword}{sizeof}(*mel\_fb-\/>filt\_width));}
\DoxyCodeLine{00319\ }
\DoxyCodeLine{00320\ \ \ \ \ \textcolor{comment}{/*\ First\ calculate\ the\ widths\ of\ each\ filter.\ */}}
\DoxyCodeLine{00321\ \ \ \ \ \textcolor{comment}{/*\ Minimum\ and\ maximum\ frequencies\ in\ mel\ scale.\ */}}
\DoxyCodeLine{00322\ \ \ \ \ melmin\ =\ fe\_mel(mel\_fb,\ mel\_fb-\/>lower\_filt\_freq);}
\DoxyCodeLine{00323\ \ \ \ \ melmax\ =\ fe\_mel(mel\_fb,\ mel\_fb-\/>upper\_filt\_freq);}
\DoxyCodeLine{00324\ }
\DoxyCodeLine{00325\ \ \ \ \ \textcolor{comment}{/*\ Width\ of\ filters\ in\ mel\ scale\ */}}
\DoxyCodeLine{00326\ \ \ \ \ melbw\ =\ (melmax\ -\/\ melmin)\ /\ (mel\_fb-\/>num\_filters\ +\ 1);}
\DoxyCodeLine{00327\ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>doublewide)\ \{}
\DoxyCodeLine{00328\ \ \ \ \ \ \ \ \ melmin\ -\/=\ melbw;}
\DoxyCodeLine{00329\ \ \ \ \ \ \ \ \ melmax\ +=\ melbw;}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((fe\_melinv(mel\_fb,\ melmin)\ <\ 0)\ ||}
\DoxyCodeLine{00331\ \ \ \ \ \ \ \ \ \ \ \ \ (fe\_melinv(mel\_fb,\ melmax)\ >\ mel\_fb-\/>sampling\_rate\ /\ 2))\ \{}
\DoxyCodeLine{00332\ \ \ \ \ \ \ \ \ \ \ \ \ E\_WARN}
\DoxyCodeLine{00333\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Out\ of\ Range:\ low\ \ filter\ edge\ =\ \%f\ (\%f)\(\backslash\)n"{}},}
\DoxyCodeLine{00334\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe\_melinv(mel\_fb,\ melmin),\ 0.0);}
\DoxyCodeLine{00335\ \ \ \ \ \ \ \ \ \ \ \ \ E\_WARN}
\DoxyCodeLine{00336\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ high\ filter\ edge\ =\ \%f\ (\%f)\(\backslash\)n"{}},}
\DoxyCodeLine{00337\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe\_melinv(mel\_fb,\ melmax),\ mel\_fb-\/>sampling\_rate\ /\ 2);}
\DoxyCodeLine{00338\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ FE\_INVALID\_PARAM\_ERROR;}
\DoxyCodeLine{00339\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00340\ \ \ \ \ \}}
\DoxyCodeLine{00341\ }
\DoxyCodeLine{00342\ \ \ \ \ \textcolor{comment}{/*\ DFT\ point\ spacing\ */}}
\DoxyCodeLine{00343\ \ \ \ \ fftfreq\ =\ mel\_fb-\/>sampling\_rate\ /\ (float32)\ mel\_fb-\/>fft\_size;}
\DoxyCodeLine{00344\ }
\DoxyCodeLine{00345\ \ \ \ \ \textcolor{comment}{/*\ Count\ and\ place\ filter\ coefficients.\ */}}
\DoxyCodeLine{00346\ \ \ \ \ n\_coeffs\ =\ 0;}
\DoxyCodeLine{00347\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ mel\_fb-\/>num\_filters;\ ++i)\ \{}
\DoxyCodeLine{00348\ \ \ \ \ \ \ \ \ float32\ freqs[3];}
\DoxyCodeLine{00349\ }
\DoxyCodeLine{00350\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Left,\ center,\ right\ frequencies\ in\ Hertz\ */}}
\DoxyCodeLine{00351\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ 3;\ ++j)\ \{}
\DoxyCodeLine{00352\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>doublewide)}
\DoxyCodeLine{00353\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ fe\_melinv(mel\_fb,\ (i\ +\ j\ *\ 2)\ *\ melbw\ +\ melmin);}
\DoxyCodeLine{00354\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00355\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ fe\_melinv(mel\_fb,\ (i\ +\ j)\ *\ melbw\ +\ melmin);}
\DoxyCodeLine{00356\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Round\ them\ to\ DFT\ points\ if\ requested\ */}}
\DoxyCodeLine{00357\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>round\_filters)}
\DoxyCodeLine{00358\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ ((int)(freqs[j]\ /\ fftfreq\ +\ 0.5))\ *\ fftfreq;}
\DoxyCodeLine{00359\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00360\ }
\DoxyCodeLine{00361\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ spec\_start\ is\ the\ start\ of\ this\ filter\ in\ the\ power\ spectrum.\ */}}
\DoxyCodeLine{00362\ \ \ \ \ \ \ \ \ mel\_fb-\/>spec\_start[i]\ =\ -\/1;}
\DoxyCodeLine{00363\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ There\ must\ be\ a\ better\ way...\ */}}
\DoxyCodeLine{00364\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ mel\_fb-\/>fft\_size/2+1;\ ++j)\ \{}
\DoxyCodeLine{00365\ \ \ \ \ \ \ \ \ \ \ \ \ float32\ hz\ =\ j\ *\ fftfreq;}
\DoxyCodeLine{00366\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (hz\ <\ freqs[0])}
\DoxyCodeLine{00367\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00368\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (hz\ >\ freqs[2]\ ||\ j\ ==\ mel\_fb-\/>fft\_size/2)\ \{}
\DoxyCodeLine{00369\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ filt\_width\ is\ the\ width\ in\ DFT\ points\ of\ this\ filter.\ */}}
\DoxyCodeLine{00370\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_width[i]\ =\ j\ -\/\ mel\_fb-\/>spec\_start[i];}
\DoxyCodeLine{00371\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ filt\_start\ is\ the\ start\ of\ this\ filter\ in\ the\ filt\_coeffs\ array.\ */}}
\DoxyCodeLine{00372\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_start[i]\ =\ n\_coeffs;}
\DoxyCodeLine{00373\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n\_coeffs\ +=\ mel\_fb-\/>filt\_width[i];}
\DoxyCodeLine{00374\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00375\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00376\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>spec\_start[i]\ ==\ -\/1)}
\DoxyCodeLine{00377\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>spec\_start[i]\ =\ j;}
\DoxyCodeLine{00378\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00379\ \ \ \ \ \}}
\DoxyCodeLine{00380\ }
\DoxyCodeLine{00381\ \ \ \ \ \textcolor{comment}{/*\ Now\ go\ back\ and\ allocate\ the\ coefficient\ array.\ */}}
\DoxyCodeLine{00382\ \ \ \ \ mel\_fb-\/>filt\_coeffs\ =\ ckd\_malloc(n\_coeffs\ *\ \textcolor{keyword}{sizeof}(*mel\_fb-\/>filt\_coeffs));}
\DoxyCodeLine{00383\ }
\DoxyCodeLine{00384\ \ \ \ \ \textcolor{comment}{/*\ And\ now\ generate\ the\ coefficients.\ */}}
\DoxyCodeLine{00385\ \ \ \ \ n\_coeffs\ =\ 0;}
\DoxyCodeLine{00386\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ mel\_fb-\/>num\_filters;\ ++i)\ \{}
\DoxyCodeLine{00387\ \ \ \ \ \ \ \ \ float32\ freqs[3];}
\DoxyCodeLine{00388\ }
\DoxyCodeLine{00389\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Left,\ center,\ right\ frequencies\ in\ Hertz\ */}}
\DoxyCodeLine{00390\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ 3;\ ++j)\ \{}
\DoxyCodeLine{00391\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>doublewide)}
\DoxyCodeLine{00392\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ fe\_melinv(mel\_fb,\ (i\ +\ j\ *\ 2)\ *\ melbw\ +\ melmin);}
\DoxyCodeLine{00393\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00394\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ fe\_melinv(mel\_fb,\ (i\ +\ j)\ *\ melbw\ +\ melmin);}
\DoxyCodeLine{00395\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Round\ them\ to\ DFT\ points\ if\ requested\ */}}
\DoxyCodeLine{00396\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>round\_filters)}
\DoxyCodeLine{00397\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ freqs[j]\ =\ ((int)(freqs[j]\ /\ fftfreq\ +\ 0.5))\ *\ fftfreq;}
\DoxyCodeLine{00398\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00399\ }
\DoxyCodeLine{00400\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ mel\_fb-\/>filt\_width[i];\ ++j)\ \{}
\DoxyCodeLine{00401\ \ \ \ \ \ \ \ \ \ \ \ \ float32\ hz,\ loslope,\ hislope;}
\DoxyCodeLine{00402\ }
\DoxyCodeLine{00403\ \ \ \ \ \ \ \ \ \ \ \ \ hz\ =\ (mel\_fb-\/>spec\_start[i]\ +\ j)\ *\ fftfreq;}
\DoxyCodeLine{00404\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (hz\ <\ freqs[0]\ ||\ hz\ >\ freqs[2])\ \{}
\DoxyCodeLine{00405\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_FATAL(\textcolor{stringliteral}{"{}Failed\ to\ create\ filterbank,\ frequency\ range\ does\ not\ match.\ "{}}}
\DoxyCodeLine{00406\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Sample\ rate\ \%f,\ FFT\ size\ \%d,\ lowerf\ \%f\ <\ freq\ \%f\ >\ upperf\ \%f.\(\backslash\)n"{}},\ mel\_fb-\/>sampling\_rate,\ mel\_fb-\/>fft\_size,\ freqs[2],\ hz,\ freqs[0]);}
\DoxyCodeLine{00407\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00408\ \ \ \ \ \ \ \ \ \ \ \ \ loslope\ =\ (hz\ -\/\ freqs[0])\ /\ (freqs[1]\ -\/\ freqs[0]);}
\DoxyCodeLine{00409\ \ \ \ \ \ \ \ \ \ \ \ \ hislope\ =\ (freqs[2]\ -\/\ hz)\ /\ (freqs[2]\ -\/\ freqs[1]);}
\DoxyCodeLine{00410\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>unit\_area)\ \{}
\DoxyCodeLine{00411\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ loslope\ *=\ 2\ /\ (freqs[2]\ -\/\ freqs[0]);}
\DoxyCodeLine{00412\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hislope\ *=\ 2\ /\ (freqs[2]\ -\/\ freqs[0]);}
\DoxyCodeLine{00413\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00414\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (loslope\ <\ hislope)\ \{}
\DoxyCodeLine{00415\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00416\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_coeffs[n\_coeffs]\ =\ fe\_log(loslope);}
\DoxyCodeLine{00417\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00418\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_coeffs[n\_coeffs]\ =\ loslope;}
\DoxyCodeLine{00419\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00420\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00421\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00422\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00423\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_coeffs[n\_coeffs]\ =\ fe\_log(hislope);}
\DoxyCodeLine{00424\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00425\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>filt\_coeffs[n\_coeffs]\ =\ hislope;}
\DoxyCodeLine{00426\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00427\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00428\ \ \ \ \ \ \ \ \ \ \ \ \ ++n\_coeffs;}
\DoxyCodeLine{00429\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00430\ \ \ \ \ \}}
\DoxyCodeLine{00431\ \ \ \ \ }
\DoxyCodeLine{00432\ }
\DoxyCodeLine{00433\ \ \ \ \ \textcolor{keywordflow}{return}\ FE\_SUCCESS;}
\DoxyCodeLine{00434\ \}}
\DoxyCodeLine{00435\ }
\DoxyCodeLine{00436\ int32}
\DoxyCodeLine{00437\ fe\_compute\_melcosine(melfb\_t\ *\ mel\_fb)}
\DoxyCodeLine{00438\ \{}
\DoxyCodeLine{00439\ }
\DoxyCodeLine{00440\ \ \ \ \ float64\ freqstep;}
\DoxyCodeLine{00441\ \ \ \ \ int32\ i,\ j;}
\DoxyCodeLine{00442\ }
\DoxyCodeLine{00443\ \ \ \ \ mel\_fb-\/>mel\_cosine\ =}
\DoxyCodeLine{00444\ \ \ \ \ \ \ \ \ (mfcc\_t\ **)\ ckd\_calloc\_2d(mel\_fb-\/>num\_cepstra,}
\DoxyCodeLine{00445\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>num\_filters,}
\DoxyCodeLine{00446\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{sizeof}(mfcc\_t));}
\DoxyCodeLine{00447\ }
\DoxyCodeLine{00448\ \ \ \ \ freqstep\ =\ M\_PI\ /\ mel\_fb-\/>num\_filters;}
\DoxyCodeLine{00449\ \ \ \ \ \textcolor{comment}{/*\ NOTE:\ The\ first\ row\ vector\ is\ actually\ unnecessary\ but\ we\ leave}}
\DoxyCodeLine{00450\ \textcolor{comment}{\ \ \ \ \ *\ it\ in\ to\ avoid\ confusion.\ */}}
\DoxyCodeLine{00451\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ mel\_fb-\/>num\_cepstra;\ i++)\ \{}
\DoxyCodeLine{00452\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ mel\_fb-\/>num\_filters;\ j++)\ \{}
\DoxyCodeLine{00453\ \ \ \ \ \ \ \ \ \ \ \ \ float64\ cosine;}
\DoxyCodeLine{00454\ }
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ \ \ \ \ cosine\ =\ cos(freqstep\ *\ i\ *\ (j\ +\ 0.5));}
\DoxyCodeLine{00456\ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>mel\_cosine[i][j]\ =\ FLOAT2COS(cosine);}
\DoxyCodeLine{00457\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00458\ \ \ \ \ \}}
\DoxyCodeLine{00459\ }
\DoxyCodeLine{00460\ \ \ \ \ \textcolor{comment}{/*\ Also\ precompute\ normalization\ constants\ for\ unitary\ DCT.\ */}}
\DoxyCodeLine{00461\ \ \ \ \ mel\_fb-\/>sqrt\_inv\_n\ =\ FLOAT2COS(sqrt(1.0\ /\ mel\_fb-\/>num\_filters));}
\DoxyCodeLine{00462\ \ \ \ \ mel\_fb-\/>sqrt\_inv\_2n\ =\ FLOAT2COS(sqrt(2.0\ /\ mel\_fb-\/>num\_filters));}
\DoxyCodeLine{00463\ }
\DoxyCodeLine{00464\ \ \ \ \ \textcolor{comment}{/*\ And\ liftering\ weights\ */}}
\DoxyCodeLine{00465\ \ \ \ \ \textcolor{keywordflow}{if}\ (mel\_fb-\/>lifter\_val)\ \{}
\DoxyCodeLine{00466\ \ \ \ \ \ \ \ \ mel\_fb-\/>lifter\ =\ calloc(mel\_fb-\/>num\_cepstra,\ \textcolor{keyword}{sizeof}(*mel\_fb-\/>lifter));}
\DoxyCodeLine{00467\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ mel\_fb-\/>num\_cepstra;\ ++i)\ \{}
\DoxyCodeLine{00468\ \ \ \ \ \ \ \ \ \ \ \ \ mel\_fb-\/>lifter[i]\ =\ FLOAT2MFCC(1\ +\ mel\_fb-\/>lifter\_val\ /\ 2}
\DoxyCodeLine{00469\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ sin(i\ *\ M\_PI\ /\ mel\_fb-\/>lifter\_val));}
\DoxyCodeLine{00470\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00471\ \ \ \ \ \}}
\DoxyCodeLine{00472\ }
\DoxyCodeLine{00473\ \ \ \ \ \textcolor{keywordflow}{return}\ (0);}
\DoxyCodeLine{00474\ \}}
\DoxyCodeLine{00475\ }
\DoxyCodeLine{00476\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00477\ fe\_pre\_emphasis(int16\ \textcolor{keyword}{const}\ *in,\ frame\_t\ *\ out,\ int32\ len,}
\DoxyCodeLine{00478\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ float32\ factor,\ int16\ prior)}
\DoxyCodeLine{00479\ \{}
\DoxyCodeLine{00480\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00481\ }
\DoxyCodeLine{00482\ \textcolor{preprocessor}{\#if\ defined(FIXED16)}}
\DoxyCodeLine{00483\ \ \ \ \ int16\ fxd\_alpha\ =\ (int16)(factor\ *\ 0x8000);}
\DoxyCodeLine{00484\ \ \ \ \ int32\ tmp1,\ tmp2;}
\DoxyCodeLine{00485\ }
\DoxyCodeLine{00486\ \ \ \ \ tmp1\ =\ (int32)in[0]\ <<\ 15;}
\DoxyCodeLine{00487\ \ \ \ \ tmp2\ =\ (int32)prior\ *\ fxd\_alpha;}
\DoxyCodeLine{00488\ \ \ \ \ out[0]\ =\ (int16)((tmp1\ -\/\ tmp2)\ >>\ 15);}
\DoxyCodeLine{00489\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ len;\ ++i)\ \{}
\DoxyCodeLine{00490\ \ \ \ \ \ \ \ \ tmp1\ =\ (int32)in[i]\ <<\ 15;}
\DoxyCodeLine{00491\ \ \ \ \ \ \ \ \ tmp2\ =\ (int32)in[i-\/1]\ *\ fxd\_alpha;}
\DoxyCodeLine{00492\ \ \ \ \ \ \ \ \ out[i]\ =\ (int16)((tmp1\ -\/\ tmp2)\ >>\ 15);}
\DoxyCodeLine{00493\ \ \ \ \ \}}
\DoxyCodeLine{00494\ \textcolor{preprocessor}{\#elif\ defined(FIXED\_POINT)}}
\DoxyCodeLine{00495\ \ \ \ \ fixed32\ fxd\_alpha\ =\ FLOAT2FIX(factor);}
\DoxyCodeLine{00496\ \ \ \ \ out[0]\ =\ ((fixed32)in[0]\ <<\ DEFAULT\_RADIX)\ -\/\ (prior\ *\ fxd\_alpha);}
\DoxyCodeLine{00497\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ len;\ ++i)}
\DoxyCodeLine{00498\ \ \ \ \ \ \ \ \ out[i]\ =\ ((fixed32)in[i]\ <<\ DEFAULT\_RADIX)}
\DoxyCodeLine{00499\ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ (fixed32)in[i-\/1]\ *\ fxd\_alpha;}
\DoxyCodeLine{00500\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00501\ \ \ \ \ out[0]\ =\ (frame\_t)\ in[0]\ -\/\ (frame\_t)\ prior\ *\ factor;}
\DoxyCodeLine{00502\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ len;\ i++)}
\DoxyCodeLine{00503\ \ \ \ \ \ \ \ \ out[i]\ =\ (frame\_t)\ in[i]\ -\/\ (frame\_t)\ in[i-\/1]\ *\ factor;}
\DoxyCodeLine{00504\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00505\ \}}
\DoxyCodeLine{00506\ }
\DoxyCodeLine{00507\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00508\ fe\_short\_to\_frame(int16\ \textcolor{keyword}{const}\ *in,\ frame\_t\ *\ out,\ int32\ len)}
\DoxyCodeLine{00509\ \{}
\DoxyCodeLine{00510\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00511\ }
\DoxyCodeLine{00512\ \textcolor{preprocessor}{\#if\ defined(FIXED16)}}
\DoxyCodeLine{00513\ \ \ \ \ memcpy(out,\ in,\ len\ *\ \textcolor{keyword}{sizeof}(*out));}
\DoxyCodeLine{00514\ \textcolor{preprocessor}{\#elif\ defined(FIXED\_POINT)}}
\DoxyCodeLine{00515\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ i++)}
\DoxyCodeLine{00516\ \ \ \ \ \ \ \ \ out[i]\ =\ (int32)\ in[i]\ <<\ DEFAULT\_RADIX;}
\DoxyCodeLine{00517\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00518\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ i++)}
\DoxyCodeLine{00519\ \ \ \ \ \ \ \ \ out[i]\ =\ (frame\_t)\ in[i];}
\DoxyCodeLine{00520\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00521\ \}}
\DoxyCodeLine{00522\ }
\DoxyCodeLine{00523\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00524\ fe\_create\_hamming(window\_t\ *\ in,\ int32\ in\_len)}
\DoxyCodeLine{00525\ \{}
\DoxyCodeLine{00526\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00527\ }
\DoxyCodeLine{00528\ \ \ \ \ \textcolor{comment}{/*\ Symmetric,\ so\ we\ only\ create\ the\ first\ half\ of\ it.\ */}}
\DoxyCodeLine{00529\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ in\_len\ /\ 2;\ i++)\ \{}
\DoxyCodeLine{00530\ \ \ \ \ \ \ \ \ float64\ hamm;}
\DoxyCodeLine{00531\ \ \ \ \ \ \ \ \ hamm\ \ =\ (0.54\ -\/\ 0.46\ *\ cos(2\ *\ M\_PI\ *\ i\ /}
\DoxyCodeLine{00532\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((float64)\ in\_len\ -\/\ 1.0)));}
\DoxyCodeLine{00533\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00534\ \ \ \ \ \ \ \ \ in[i]\ =\ (int16)(hamm\ *\ 0x8000);}
\DoxyCodeLine{00535\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00536\ \ \ \ \ \ \ \ \ in[i]\ =\ FLOAT2COS(hamm);}
\DoxyCodeLine{00537\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00538\ \ \ \ \ \}}
\DoxyCodeLine{00539\ \}}
\DoxyCodeLine{00540\ }
\DoxyCodeLine{00541\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00542\ fe\_hamming\_window(frame\_t\ *\ in,\ window\_t\ *\ window,\ int32\ in\_len,\ int32\ remove\_dc)}
\DoxyCodeLine{00543\ \{}
\DoxyCodeLine{00544\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00545\ }
\DoxyCodeLine{00546\ \ \ \ \ \textcolor{keywordflow}{if}\ (remove\_dc)\ \{}
\DoxyCodeLine{00547\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00548\ \ \ \ \ \ \ \ \ int32\ mean\ =\ 0;\ \textcolor{comment}{/*\ Use\ int32\ to\ avoid\ possibility\ of\ overflow\ */}}
\DoxyCodeLine{00549\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00550\ \ \ \ \ \ \ \ \ frame\_t\ mean\ =\ 0;}
\DoxyCodeLine{00551\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00552\ }
\DoxyCodeLine{00553\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ in\_len;\ i++)}
\DoxyCodeLine{00554\ \ \ \ \ \ \ \ \ \ \ \ \ mean\ +=\ in[i];}
\DoxyCodeLine{00555\ \ \ \ \ \ \ \ \ mean\ /=\ in\_len;}
\DoxyCodeLine{00556\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ in\_len;\ i++)}
\DoxyCodeLine{00557\ \ \ \ \ \ \ \ \ \ \ \ \ in[i]\ -\/=\ (frame\_t)mean;}
\DoxyCodeLine{00558\ \ \ \ \ \}}
\DoxyCodeLine{00559\ }
\DoxyCodeLine{00560\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00561\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ in\_len/2;\ i++)\ \{}
\DoxyCodeLine{00562\ \ \ \ \ \ \ \ \ int32\ tmp1,\ tmp2;}
\DoxyCodeLine{00563\ }
\DoxyCodeLine{00564\ \ \ \ \ \ \ \ \ tmp1\ =\ (int32)in[i]\ *\ window[i];}
\DoxyCodeLine{00565\ \ \ \ \ \ \ \ \ tmp2\ =\ (int32)in[in\_len-\/1-\/i]\ *\ window[i];}
\DoxyCodeLine{00566\ \ \ \ \ \ \ \ \ in[i]\ =\ (int16)(tmp1\ >>\ 15);}
\DoxyCodeLine{00567\ \ \ \ \ \ \ \ \ in[in\_len-\/1-\/i]\ =\ (int16)(tmp2\ >>\ 15);}
\DoxyCodeLine{00568\ \ \ \ \ \}}
\DoxyCodeLine{00569\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00570\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ in\_len/2;\ i++)\ \{}
\DoxyCodeLine{00571\ \ \ \ \ \ \ \ \ in[i]\ =\ COSMUL(in[i],\ window[i]);}
\DoxyCodeLine{00572\ \ \ \ \ \ \ \ \ in[in\_len-\/1-\/i]\ =\ COSMUL(in[in\_len-\/1-\/i],\ window[i]);}
\DoxyCodeLine{00573\ \ \ \ \ \}}
\DoxyCodeLine{00574\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00575\ \}}
\DoxyCodeLine{00576\ }
\DoxyCodeLine{00577\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00578\ fe\_spch\_to\_frame(fe\_t\ *fe,\ \textcolor{keywordtype}{int}\ len)}
\DoxyCodeLine{00579\ \{}
\DoxyCodeLine{00580\ \ \ \ \ \textcolor{comment}{/*\ Copy\ to\ the\ frame\ buffer.\ */}}
\DoxyCodeLine{00581\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>pre\_emphasis\_alpha\ !=\ 0.0)\ \{}
\DoxyCodeLine{00582\ \ \ \ \ \ \ \ \ fe\_pre\_emphasis(fe-\/>spch,\ fe-\/>frame,\ len,}
\DoxyCodeLine{00583\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>pre\_emphasis\_alpha,\ fe-\/>prior);}
\DoxyCodeLine{00584\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ >=\ fe-\/>frame\_shift)}
\DoxyCodeLine{00585\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>prior\ =\ fe-\/>spch[fe-\/>frame\_shift\ -\/\ 1];}
\DoxyCodeLine{00586\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00587\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>prior\ =\ fe-\/>spch[len\ -\/\ 1];}
\DoxyCodeLine{00588\ \ \ \ \ \}}
\DoxyCodeLine{00589\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00590\ \ \ \ \ \ \ \ \ fe\_short\_to\_frame(fe-\/>spch,\ fe-\/>frame,\ len);}
\DoxyCodeLine{00591\ }
\DoxyCodeLine{00592\ \ \ \ \ \textcolor{comment}{/*\ Zero\ pad\ up\ to\ FFT\ size.\ */}}
\DoxyCodeLine{00593\ \ \ \ \ memset(fe-\/>frame\ +\ len,\ 0,}
\DoxyCodeLine{00594\ \ \ \ \ \ \ \ \ \ \ \ (fe-\/>fft\_size\ -\/\ len)\ *\ \textcolor{keyword}{sizeof}(*fe-\/>frame));}
\DoxyCodeLine{00595\ }
\DoxyCodeLine{00596\ \ \ \ \ \textcolor{comment}{/*\ Window.\ */}}
\DoxyCodeLine{00597\ \ \ \ \ fe\_hamming\_window(fe-\/>frame,\ fe-\/>hamming\_window,\ fe-\/>frame\_size,}
\DoxyCodeLine{00598\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>remove\_dc);}
\DoxyCodeLine{00599\ }
\DoxyCodeLine{00600\ \ \ \ \ \textcolor{keywordflow}{return}\ len;}
\DoxyCodeLine{00601\ \}}
\DoxyCodeLine{00602\ }
\DoxyCodeLine{00603\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00604\ fe\_read\_frame(fe\_t\ *fe,\ int16\ \textcolor{keyword}{const}\ *in,\ int32\ len)}
\DoxyCodeLine{00605\ \{}
\DoxyCodeLine{00606\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00607\ }
\DoxyCodeLine{00608\ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ >\ fe-\/>frame\_size)}
\DoxyCodeLine{00609\ \ \ \ \ \ \ \ \ len\ =\ fe-\/>frame\_size;}
\DoxyCodeLine{00610\ }
\DoxyCodeLine{00611\ \ \ \ \ \textcolor{comment}{/*\ Read\ it\ into\ the\ raw\ speech\ buffer.\ */}}
\DoxyCodeLine{00612\ \ \ \ \ memcpy(fe-\/>spch,\ in,\ len\ *\ \textcolor{keyword}{sizeof}(*in));}
\DoxyCodeLine{00613\ \ \ \ \ \textcolor{comment}{/*\ Swap\ and\ dither\ if\ necessary.\ */}}
\DoxyCodeLine{00614\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>swap)}
\DoxyCodeLine{00615\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ ++i)}
\DoxyCodeLine{00616\ \ \ \ \ \ \ \ \ \ \ \ \ SWAP\_INT16(\&fe-\/>spch[i]);}
\DoxyCodeLine{00617\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>dither)}
\DoxyCodeLine{00618\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ ++i)}
\DoxyCodeLine{00619\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>spch[i]\ +=\ (int16)\ ((!(s3\_rand\_int31()\ \%\ 4))\ ?\ 1\ :\ 0);}
\DoxyCodeLine{00620\ }
\DoxyCodeLine{00621\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_spch\_to\_frame(fe,\ len);}
\DoxyCodeLine{00622\ \}}
\DoxyCodeLine{00623\ }
\DoxyCodeLine{00624\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00625\ fe\_shift\_frame(fe\_t\ *fe,\ int16\ \textcolor{keyword}{const}\ *in,\ int32\ len)}
\DoxyCodeLine{00626\ \{}
\DoxyCodeLine{00627\ \ \ \ \ \textcolor{keywordtype}{int}\ offset,\ i;}
\DoxyCodeLine{00628\ }
\DoxyCodeLine{00629\ \ \ \ \ \textcolor{keywordflow}{if}\ (len\ >\ fe-\/>frame\_shift)}
\DoxyCodeLine{00630\ \ \ \ \ \ \ \ \ len\ =\ fe-\/>frame\_shift;}
\DoxyCodeLine{00631\ \ \ \ \ offset\ =\ fe-\/>frame\_size\ -\/\ fe-\/>frame\_shift;}
\DoxyCodeLine{00632\ }
\DoxyCodeLine{00633\ \ \ \ \ \textcolor{comment}{/*\ Shift\ data\ into\ the\ raw\ speech\ buffer.\ */}}
\DoxyCodeLine{00634\ \ \ \ \ memmove(fe-\/>spch,\ fe-\/>spch\ +\ fe-\/>frame\_shift,}
\DoxyCodeLine{00635\ \ \ \ \ \ \ \ \ \ \ \ \ offset\ *\ \textcolor{keyword}{sizeof}(*fe-\/>spch));}
\DoxyCodeLine{00636\ \ \ \ \ memcpy(fe-\/>spch\ +\ offset,\ in,\ len\ *\ \textcolor{keyword}{sizeof}(*fe-\/>spch));}
\DoxyCodeLine{00637\ \ \ \ \ \textcolor{comment}{/*\ Swap\ and\ dither\ if\ necessary.\ */}}
\DoxyCodeLine{00638\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>swap)}
\DoxyCodeLine{00639\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ ++i)}
\DoxyCodeLine{00640\ \ \ \ \ \ \ \ \ \ \ \ \ SWAP\_INT16(\&fe-\/>spch[offset\ +\ i]);}
\DoxyCodeLine{00641\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>dither)}
\DoxyCodeLine{00642\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ len;\ ++i)}
\DoxyCodeLine{00643\ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>spch[offset\ +\ i]}
\DoxyCodeLine{00644\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +=\ (int16)\ ((!(s3\_rand\_int31()\ \%\ 4))\ ?\ 1\ :\ 0);}
\DoxyCodeLine{00645\ \ \ \ \ }
\DoxyCodeLine{00646\ \ \ \ \ \textcolor{keywordflow}{return}\ fe\_spch\_to\_frame(fe,\ offset\ +\ len);}
\DoxyCodeLine{00647\ \}}
\DoxyCodeLine{00648\ }
\DoxyCodeLine{00652\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00653\ fe\_create\_twiddle(fe\_t\ *fe)}
\DoxyCodeLine{00654\ \{}
\DoxyCodeLine{00655\ \ \ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{00656\ }
\DoxyCodeLine{00657\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>fft\_size\ /\ 4;\ ++i)\ \{}
\DoxyCodeLine{00658\ \ \ \ \ \ \ \ \ float64\ a\ =\ 2\ *\ M\_PI\ *\ i\ /\ fe-\/>fft\_size;}
\DoxyCodeLine{00659\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00660\ \ \ \ \ \ \ \ \ fe-\/>ccc[i]\ =\ (int16)(cos(a)\ *\ 0x8000);}
\DoxyCodeLine{00661\ \ \ \ \ \ \ \ \ fe-\/>sss[i]\ =\ (int16)(sin(a)\ *\ 0x8000);}
\DoxyCodeLine{00662\ \textcolor{preprocessor}{\#elif\ defined(FIXED\_POINT)}}
\DoxyCodeLine{00663\ \ \ \ \ \ \ \ \ fe-\/>ccc[i]\ =\ FLOAT2COS(cos(a));}
\DoxyCodeLine{00664\ \ \ \ \ \ \ \ \ fe-\/>sss[i]\ =\ FLOAT2COS(sin(a));}
\DoxyCodeLine{00665\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00666\ \ \ \ \ \ \ \ \ fe-\/>ccc[i]\ =\ cos(a);}
\DoxyCodeLine{00667\ \ \ \ \ \ \ \ \ fe-\/>sss[i]\ =\ sin(a);}
\DoxyCodeLine{00668\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00669\ \ \ \ \ \}}
\DoxyCodeLine{00670\ \}}
\DoxyCodeLine{00671\ }
\DoxyCodeLine{00672\ \textcolor{comment}{/*\ Translated\ from\ the\ FORTRAN\ (obviously)\ from\ "{}Real-\/Valued\ Fast}}
\DoxyCodeLine{00673\ \textcolor{comment}{\ *\ Fourier\ Transform\ Algorithms"{}\ by\ Henrik\ V.\ Sorensen\ et\ al.,\ IEEE}}
\DoxyCodeLine{00674\ \textcolor{comment}{\ *\ Transactions\ on\ Acoustics,\ Speech,\ and\ Signal\ Processing,\ vol.\ 35,}}
\DoxyCodeLine{00675\ \textcolor{comment}{\ *\ no.6.\ \ The\ 16-\/bit\ version\ does\ a\ version\ of\ "{}block\ floating}}
\DoxyCodeLine{00676\ \textcolor{comment}{\ *\ point"{}\ in\ order\ to\ avoid\ rounding\ errors.}}
\DoxyCodeLine{00677\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00678\ \textcolor{preprocessor}{\#if\ defined(FIXED16)}}
\DoxyCodeLine{00679\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00680\ fe\_fft\_real(fe\_t\ *fe)}
\DoxyCodeLine{00681\ \{}
\DoxyCodeLine{00682\ \ \ \ \ \textcolor{keywordtype}{int}\ i,\ j,\ k,\ m,\ n,\ lz;}
\DoxyCodeLine{00683\ \ \ \ \ frame\_t\ *x,\ xt,\ max;}
\DoxyCodeLine{00684\ }
\DoxyCodeLine{00685\ \ \ \ \ x\ =\ fe-\/>frame;}
\DoxyCodeLine{00686\ \ \ \ \ m\ =\ fe-\/>fft\_order;}
\DoxyCodeLine{00687\ \ \ \ \ n\ =\ fe-\/>fft\_size;}
\DoxyCodeLine{00688\ }
\DoxyCodeLine{00689\ \ \ \ \ \textcolor{comment}{/*\ Bit-\/reverse\ the\ input.\ */}}
\DoxyCodeLine{00690\ \ \ \ \ j\ =\ 0;}
\DoxyCodeLine{00691\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n\ -\/\ 1;\ ++i)\ \{}
\DoxyCodeLine{00692\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (i\ <\ j)\ \{}
\DoxyCodeLine{00693\ \ \ \ \ \ \ \ \ \ \ \ \ xt\ =\ x[j];}
\DoxyCodeLine{00694\ \ \ \ \ \ \ \ \ \ \ \ \ x[j]\ =\ x[i];}
\DoxyCodeLine{00695\ \ \ \ \ \ \ \ \ \ \ \ \ x[i]\ =\ xt;}
\DoxyCodeLine{00696\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00697\ \ \ \ \ \ \ \ \ k\ =\ n\ /\ 2;}
\DoxyCodeLine{00698\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{while}\ (k\ <=\ j)\ \{}
\DoxyCodeLine{00699\ \ \ \ \ \ \ \ \ \ \ \ \ j\ -\/=\ k;}
\DoxyCodeLine{00700\ \ \ \ \ \ \ \ \ \ \ \ \ k\ /=\ 2;}
\DoxyCodeLine{00701\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00702\ \ \ \ \ \ \ \ \ j\ +=\ k;}
\DoxyCodeLine{00703\ \ \ \ \ \}}
\DoxyCodeLine{00704\ \ \ \ \ \textcolor{comment}{/*\ Determine\ how\ many\ bits\ of\ dynamic\ range\ are\ in\ the\ input.\ */}}
\DoxyCodeLine{00705\ \ \ \ \ max\ =\ 0;}
\DoxyCodeLine{00706\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ ++i)}
\DoxyCodeLine{00707\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (abs(x[i])\ >\ max)}
\DoxyCodeLine{00708\ \ \ \ \ \ \ \ \ \ \ \ \ max\ =\ abs(x[i]);}
\DoxyCodeLine{00709\ \ \ \ \ \textcolor{comment}{/*\ The\ FFT\ has\ a\ gain\ of\ M\ bits,\ so\ we\ need\ to\ attenuate\ the\ input}}
\DoxyCodeLine{00710\ \textcolor{comment}{\ \ \ \ \ *\ by\ M\ bits\ minus\ the\ number\ of\ leading\ zeroes\ in\ the\ input's}}
\DoxyCodeLine{00711\ \textcolor{comment}{\ \ \ \ \ *\ range\ in\ order\ to\ avoid\ overflows.\ \ */}}
\DoxyCodeLine{00712\ \ \ \ \ \textcolor{keywordflow}{for}\ (lz\ =\ 0;\ lz\ <\ m;\ ++lz)}
\DoxyCodeLine{00713\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (max\ \&\ (1\ <<\ (15-\/lz)))}
\DoxyCodeLine{00714\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00715\ }
\DoxyCodeLine{00716\ \ \ \ \ \textcolor{comment}{/*\ Basic\ butterflies\ (2-\/point\ FFT,\ real\ twiddle\ factors):}}
\DoxyCodeLine{00717\ \textcolor{comment}{\ \ \ \ \ *\ x[i]\ \ \ =\ x[i]\ +\ \ 1\ *\ x[i+1]}}
\DoxyCodeLine{00718\ \textcolor{comment}{\ \ \ \ \ *\ x[i+1]\ =\ x[i]\ +\ -\/1\ *\ x[i+1]}}
\DoxyCodeLine{00719\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00720\ \ \ \ \ \textcolor{comment}{/*\ The\ quantization\ error\ introduced\ by\ attenuating\ the\ input\ at}}
\DoxyCodeLine{00721\ \textcolor{comment}{\ \ \ \ \ *\ any\ given\ stage\ of\ the\ FFT\ has\ a\ cascading\ effect,\ so\ we\ hold}}
\DoxyCodeLine{00722\ \textcolor{comment}{\ \ \ \ \ *\ off\ on\ it\ until\ it's\ absolutely\ necessary.\ */}}
\DoxyCodeLine{00723\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i\ +=\ 2)\ \{}
\DoxyCodeLine{00724\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ atten\ =\ (lz\ ==\ 0);}
\DoxyCodeLine{00725\ \ \ \ \ \ \ \ \ xt\ =\ x[i]\ >>\ atten;}
\DoxyCodeLine{00726\ \ \ \ \ \ \ \ \ x[i]\ \ \ \ \ =\ xt\ +\ (x[i\ +\ 1]\ >>\ atten);}
\DoxyCodeLine{00727\ \ \ \ \ \ \ \ \ x[i\ +\ 1]\ =\ xt\ -\/\ (x[i\ +\ 1]\ >>\ atten);}
\DoxyCodeLine{00728\ \ \ \ \ \}}
\DoxyCodeLine{00729\ }
\DoxyCodeLine{00730\ \ \ \ \ \textcolor{comment}{/*\ The\ rest\ of\ the\ butterflies,\ in\ stages\ from\ 1..m\ */}}
\DoxyCodeLine{00731\ \ \ \ \ \textcolor{keywordflow}{for}\ (k\ =\ 1;\ k\ <\ m;\ ++k)\ \{}
\DoxyCodeLine{00732\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ n1,\ n2,\ n4;}
\DoxyCodeLine{00733\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Start\ attenuating\ once\ we\ hit\ the\ number\ of\ leading\ zeros.\ */}}
\DoxyCodeLine{00734\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ atten\ =\ (k\ >=\ lz);}
\DoxyCodeLine{00735\ }
\DoxyCodeLine{00736\ \ \ \ \ \ \ \ \ n4\ =\ k\ -\/\ 1;}
\DoxyCodeLine{00737\ \ \ \ \ \ \ \ \ n2\ =\ k;}
\DoxyCodeLine{00738\ \ \ \ \ \ \ \ \ n1\ =\ k\ +\ 1;}
\DoxyCodeLine{00739\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Stride\ over\ each\ (1\ <<\ (k+1))\ points\ */}}
\DoxyCodeLine{00740\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i\ +=\ (1\ <<\ n1))\ \{}
\DoxyCodeLine{00741\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Basic\ butterfly\ with\ real\ twiddle\ factors:}}
\DoxyCodeLine{00742\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i]\ \ \ \ \ \ \ \ \ \ =\ x[i]\ +\ \ 1\ *\ x[i\ +\ (1<<k)]}}
\DoxyCodeLine{00743\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<k)]\ =\ x[i]\ +\ -\/1\ *\ x[i\ +\ (1<<k)]}}
\DoxyCodeLine{00744\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00745\ \ \ \ \ \ \ \ \ \ \ \ \ xt\ =\ x[i]\ >>\ atten;}
\DoxyCodeLine{00746\ \ \ \ \ \ \ \ \ \ \ \ \ x[i]\ \ \ \ \ \ \ \ \ \ \ \ \ =\ xt\ +\ (x[i\ +\ (1\ <<\ n2)]\ >>\ atten);}
\DoxyCodeLine{00747\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n2)]\ =\ xt\ -\/\ (x[i\ +\ (1\ <<\ n2)]\ >>\ atten);}
\DoxyCodeLine{00748\ }
\DoxyCodeLine{00749\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ The\ other\ ones\ with\ real\ twiddle\ factors:}}
\DoxyCodeLine{00750\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<k)\ +\ (1<<(k-\/1))]}}
\DoxyCodeLine{00751\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ \ \ =\ 0\ *\ x[i\ +\ (1<<k-\/1)]\ +\ -\/1\ *\ x[i\ +\ (1<<k)\ +\ (1<<k-\/1)]}}
\DoxyCodeLine{00752\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<(k-\/1))]}}
\DoxyCodeLine{00753\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ \ \ =\ 1\ *\ x[i\ +\ (1<<k-\/1)]\ +\ \ 0\ *\ x[i\ +\ (1<<k)\ +\ (1<<k-\/1)]}}
\DoxyCodeLine{00754\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00755\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n4)]\ =\ -\/x[i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n4)]\ >>\ atten;}
\DoxyCodeLine{00756\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n4)]\ \ \ \ \ \ \ \ \ \ \ \ \ =\ \ x[i\ +\ (1\ <<\ n4)]\ >>\ atten;}
\DoxyCodeLine{00757\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00758\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Butterflies\ with\ complex\ twiddle\ factors.}}
\DoxyCodeLine{00759\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ There\ are\ (1<<k-\/1)\ of\ them.}}
\DoxyCodeLine{00760\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00761\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <\ (1\ <<\ n4);\ ++j)\ \{}
\DoxyCodeLine{00762\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ frame\_t\ cc,\ ss,\ t1,\ t2;}
\DoxyCodeLine{00763\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ i1,\ i2,\ i3,\ i4;}
\DoxyCodeLine{00764\ }
\DoxyCodeLine{00765\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i1\ =\ i\ +\ j;}
\DoxyCodeLine{00766\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i2\ =\ i\ +\ (1\ <<\ n2)\ -\/\ j;}
\DoxyCodeLine{00767\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i3\ =\ i\ +\ (1\ <<\ n2)\ +\ j;}
\DoxyCodeLine{00768\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i4\ =\ i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n2)\ -\/\ j;}
\DoxyCodeLine{00769\ }
\DoxyCodeLine{00770\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{00771\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ cc\ =\ real(W[j\ *\ n\ /\ (1<<(k+1))])}}
\DoxyCodeLine{00772\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ ss\ =\ imag(W[j\ *\ n\ /\ (1<<(k+1))])}}
\DoxyCodeLine{00773\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00774\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cc\ =\ fe-\/>ccc[j\ <<\ (m\ -\/\ n1)];}
\DoxyCodeLine{00775\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ss\ =\ fe-\/>sss[j\ <<\ (m\ -\/\ n1)];}
\DoxyCodeLine{00776\ }
\DoxyCodeLine{00777\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ There\ are\ some\ symmetry\ properties\ which\ allow\ us}}
\DoxyCodeLine{00778\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ to\ get\ away\ with\ only\ four\ multiplications\ here.\ */}}
\DoxyCodeLine{00779\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00780\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ int32\ tmp1,\ tmp2;}
\DoxyCodeLine{00781\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tmp1\ =\ (int32)x[i3]\ *\ cc\ +\ (int32)x[i4]\ *\ ss;}
\DoxyCodeLine{00782\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tmp2\ =\ (int32)x[i3]\ *\ ss\ -\/\ (int32)x[i4]\ *\ cc;}
\DoxyCodeLine{00783\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t1\ =\ (int16)(tmp1\ >>\ 15)\ >>\ atten;}
\DoxyCodeLine{00784\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t2\ =\ (int16)(tmp2\ >>\ 15)\ >>\ atten;}
\DoxyCodeLine{00785\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00786\ }
\DoxyCodeLine{00787\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i4]\ =\ (x[i2]\ >>\ atten)\ -\/\ t2;}
\DoxyCodeLine{00788\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i3]\ =\ (-\/x[i2]\ >>\ atten)\ -\/\ t2;}
\DoxyCodeLine{00789\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i2]\ =\ (x[i1]\ >>\ atten)\ -\/\ t1;}
\DoxyCodeLine{00790\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i1]\ =\ (x[i1]\ >>\ atten)\ +\ t1;}
\DoxyCodeLine{00791\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00792\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00793\ \ \ \ \ \}}
\DoxyCodeLine{00794\ }
\DoxyCodeLine{00795\ \ \ \ \ \textcolor{comment}{/*\ Return\ the\ residual\ scaling\ factor.\ */}}
\DoxyCodeLine{00796\ \ \ \ \ \textcolor{keywordflow}{return}\ lz;}
\DoxyCodeLine{00797\ \}}
\DoxyCodeLine{00798\ \textcolor{preprocessor}{\#else\ }\textcolor{comment}{/*\ !FIXED16\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00799\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00800\ fe\_fft\_real(fe\_t\ *fe)}
\DoxyCodeLine{00801\ \{}
\DoxyCodeLine{00802\ \ \ \ \ \textcolor{keywordtype}{int}\ i,\ j,\ k,\ m,\ n;}
\DoxyCodeLine{00803\ \ \ \ \ frame\_t\ *x,\ xt;}
\DoxyCodeLine{00804\ }
\DoxyCodeLine{00805\ \ \ \ \ x\ =\ fe-\/>frame;}
\DoxyCodeLine{00806\ \ \ \ \ m\ =\ fe-\/>fft\_order;}
\DoxyCodeLine{00807\ \ \ \ \ n\ =\ fe-\/>fft\_size;}
\DoxyCodeLine{00808\ }
\DoxyCodeLine{00809\ \ \ \ \ \textcolor{comment}{/*\ Bit-\/reverse\ the\ input.\ */}}
\DoxyCodeLine{00810\ \ \ \ \ j\ =\ 0;}
\DoxyCodeLine{00811\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n\ -\/\ 1;\ ++i)\ \{}
\DoxyCodeLine{00812\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (i\ <\ j)\ \{}
\DoxyCodeLine{00813\ \ \ \ \ \ \ \ \ \ \ \ \ xt\ =\ x[j];}
\DoxyCodeLine{00814\ \ \ \ \ \ \ \ \ \ \ \ \ x[j]\ =\ x[i];}
\DoxyCodeLine{00815\ \ \ \ \ \ \ \ \ \ \ \ \ x[i]\ =\ xt;}
\DoxyCodeLine{00816\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00817\ \ \ \ \ \ \ \ \ k\ =\ n\ /\ 2;}
\DoxyCodeLine{00818\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{while}\ (k\ <=\ j)\ \{}
\DoxyCodeLine{00819\ \ \ \ \ \ \ \ \ \ \ \ \ j\ -\/=\ k;}
\DoxyCodeLine{00820\ \ \ \ \ \ \ \ \ \ \ \ \ k\ /=\ 2;}
\DoxyCodeLine{00821\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00822\ \ \ \ \ \ \ \ \ j\ +=\ k;}
\DoxyCodeLine{00823\ \ \ \ \ \}}
\DoxyCodeLine{00824\ }
\DoxyCodeLine{00825\ \ \ \ \ \textcolor{comment}{/*\ Basic\ butterflies\ (2-\/point\ FFT,\ real\ twiddle\ factors):}}
\DoxyCodeLine{00826\ \textcolor{comment}{\ \ \ \ \ *\ x[i]\ \ \ =\ x[i]\ +\ \ 1\ *\ x[i+1]}}
\DoxyCodeLine{00827\ \textcolor{comment}{\ \ \ \ \ *\ x[i+1]\ =\ x[i]\ +\ -\/1\ *\ x[i+1]}}
\DoxyCodeLine{00828\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00829\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i\ +=\ 2)\ \{}
\DoxyCodeLine{00830\ \ \ \ \ \ \ \ \ xt\ =\ x[i];}
\DoxyCodeLine{00831\ \ \ \ \ \ \ \ \ x[i]\ \ \ \ \ =\ (xt\ +\ x[i\ +\ 1]);}
\DoxyCodeLine{00832\ \ \ \ \ \ \ \ \ x[i\ +\ 1]\ =\ (xt\ -\/\ x[i\ +\ 1]);}
\DoxyCodeLine{00833\ \ \ \ \ \}}
\DoxyCodeLine{00834\ }
\DoxyCodeLine{00835\ \ \ \ \ \textcolor{comment}{/*\ The\ rest\ of\ the\ butterflies,\ in\ stages\ from\ 1..m\ */}}
\DoxyCodeLine{00836\ \ \ \ \ \textcolor{keywordflow}{for}\ (k\ =\ 1;\ k\ <\ m;\ ++k)\ \{}
\DoxyCodeLine{00837\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ n1,\ n2,\ n4;}
\DoxyCodeLine{00838\ }
\DoxyCodeLine{00839\ \ \ \ \ \ \ \ \ n4\ =\ k\ -\/\ 1;}
\DoxyCodeLine{00840\ \ \ \ \ \ \ \ \ n2\ =\ k;}
\DoxyCodeLine{00841\ \ \ \ \ \ \ \ \ n1\ =\ k\ +\ 1;}
\DoxyCodeLine{00842\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Stride\ over\ each\ (1\ <<\ (k+1))\ points\ */}}
\DoxyCodeLine{00843\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ n;\ i\ +=\ (1\ <<\ n1))\ \{}
\DoxyCodeLine{00844\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Basic\ butterfly\ with\ real\ twiddle\ factors:}}
\DoxyCodeLine{00845\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i]\ \ \ \ \ \ \ \ \ \ =\ x[i]\ +\ \ 1\ *\ x[i\ +\ (1<<k)]}}
\DoxyCodeLine{00846\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<k)]\ =\ x[i]\ +\ -\/1\ *\ x[i\ +\ (1<<k)]}}
\DoxyCodeLine{00847\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00848\ \ \ \ \ \ \ \ \ \ \ \ \ xt\ =\ x[i];}
\DoxyCodeLine{00849\ \ \ \ \ \ \ \ \ \ \ \ \ x[i]\ \ \ \ \ \ \ \ \ \ \ \ \ =\ (xt\ +\ x[i\ +\ (1\ <<\ n2)]);}
\DoxyCodeLine{00850\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n2)]\ =\ (xt\ -\/\ x[i\ +\ (1\ <<\ n2)]);}
\DoxyCodeLine{00851\ }
\DoxyCodeLine{00852\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ The\ other\ ones\ with\ real\ twiddle\ factors:}}
\DoxyCodeLine{00853\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<k)\ +\ (1<<(k-\/1))]}}
\DoxyCodeLine{00854\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ \ \ =\ 0\ *\ x[i\ +\ (1<<k-\/1)]\ +\ -\/1\ *\ x[i\ +\ (1<<k)\ +\ (1<<k-\/1)]}}
\DoxyCodeLine{00855\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ x[i\ +\ (1<<(k-\/1))]}}
\DoxyCodeLine{00856\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ \ \ =\ 1\ *\ x[i\ +\ (1<<k-\/1)]\ +\ \ 0\ *\ x[i\ +\ (1<<k)\ +\ (1<<k-\/1)]}}
\DoxyCodeLine{00857\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00858\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n4)]\ =\ -\/x[i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n4)];}
\DoxyCodeLine{00859\ \ \ \ \ \ \ \ \ \ \ \ \ x[i\ +\ (1\ <<\ n4)]\ \ \ \ \ \ \ \ \ \ \ \ \ =\ \ x[i\ +\ (1\ <<\ n4)];}
\DoxyCodeLine{00860\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00861\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Butterflies\ with\ complex\ twiddle\ factors.}}
\DoxyCodeLine{00862\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ *\ There\ are\ (1<<k-\/1)\ of\ them.}}
\DoxyCodeLine{00863\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00864\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <\ (1\ <<\ n4);\ ++j)\ \{}
\DoxyCodeLine{00865\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ frame\_t\ cc,\ ss,\ t1,\ t2;}
\DoxyCodeLine{00866\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ i1,\ i2,\ i3,\ i4;}
\DoxyCodeLine{00867\ }
\DoxyCodeLine{00868\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i1\ =\ i\ +\ j;}
\DoxyCodeLine{00869\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i2\ =\ i\ +\ (1\ <<\ n2)\ -\/\ j;}
\DoxyCodeLine{00870\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i3\ =\ i\ +\ (1\ <<\ n2)\ +\ j;}
\DoxyCodeLine{00871\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i4\ =\ i\ +\ (1\ <<\ n2)\ +\ (1\ <<\ n2)\ -\/\ j;}
\DoxyCodeLine{00872\ }
\DoxyCodeLine{00873\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{00874\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ cc\ =\ real(W[j\ *\ n\ /\ (1<<(k+1))])}}
\DoxyCodeLine{00875\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ ss\ =\ imag(W[j\ *\ n\ /\ (1<<(k+1))])}}
\DoxyCodeLine{00876\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00877\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cc\ =\ fe-\/>ccc[j\ <<\ (m\ -\/\ n1)];}
\DoxyCodeLine{00878\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ss\ =\ fe-\/>sss[j\ <<\ (m\ -\/\ n1)];}
\DoxyCodeLine{00879\ }
\DoxyCodeLine{00880\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ There\ are\ some\ symmetry\ properties\ which\ allow\ us}}
\DoxyCodeLine{00881\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ to\ get\ away\ with\ only\ four\ multiplications\ here.\ */}}
\DoxyCodeLine{00882\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t1\ =\ COSMUL(x[i3],\ cc)\ +\ COSMUL(x[i4],\ ss);}
\DoxyCodeLine{00883\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ t2\ =\ COSMUL(x[i3],\ ss)\ -\/\ COSMUL(x[i4],\ cc);}
\DoxyCodeLine{00884\ }
\DoxyCodeLine{00885\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i4]\ =\ (x[i2]\ -\/\ t2);}
\DoxyCodeLine{00886\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i3]\ =\ (-\/x[i2]\ -\/\ t2);}
\DoxyCodeLine{00887\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i2]\ =\ (x[i1]\ -\/\ t1);}
\DoxyCodeLine{00888\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ x[i1]\ =\ (x[i1]\ +\ t1);}
\DoxyCodeLine{00889\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00890\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00891\ \ \ \ \ \}}
\DoxyCodeLine{00892\ }
\DoxyCodeLine{00893\ \ \ \ \ \textcolor{comment}{/*\ This\ isn't\ used,\ but\ return\ it\ for\ completeness.\ */}}
\DoxyCodeLine{00894\ \ \ \ \ \textcolor{keywordflow}{return}\ m;}
\DoxyCodeLine{00895\ \}}
\DoxyCodeLine{00896\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{/*\ !FIXED16\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00897\ }
\DoxyCodeLine{00898\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00899\ fe\_spec\_magnitude(fe\_t\ *fe)}
\DoxyCodeLine{00900\ \{}
\DoxyCodeLine{00901\ \ \ \ \ frame\_t\ *fft;}
\DoxyCodeLine{00902\ \ \ \ \ powspec\_t\ *spec;}
\DoxyCodeLine{00903\ \ \ \ \ int32\ j,\ scale,\ fftsize;}
\DoxyCodeLine{00904\ }
\DoxyCodeLine{00905\ \ \ \ \ \textcolor{comment}{/*\ Do\ FFT\ and\ get\ the\ scaling\ factor\ back\ (only\ actually\ used\ in}}
\DoxyCodeLine{00906\ \textcolor{comment}{\ \ \ \ \ *\ fixed-\/point).\ \ Note\ the\ scaling\ factor\ is\ expressed\ in\ bits.\ */}}
\DoxyCodeLine{00907\ \ \ \ \ scale\ =\ fe\_fft\_real(fe);}
\DoxyCodeLine{00908\ }
\DoxyCodeLine{00909\ \ \ \ \ \textcolor{comment}{/*\ Convenience\ pointers\ to\ make\ things\ less\ awkward\ below.\ */}}
\DoxyCodeLine{00910\ \ \ \ \ fft\ =\ fe-\/>frame;}
\DoxyCodeLine{00911\ \ \ \ \ spec\ =\ fe-\/>spec;}
\DoxyCodeLine{00912\ \ \ \ \ fftsize\ =\ fe-\/>fft\_size;}
\DoxyCodeLine{00913\ }
\DoxyCodeLine{00914\ \ \ \ \ \textcolor{comment}{/*\ We\ need\ to\ scale\ things\ up\ the\ rest\ of\ the\ way\ to\ N.\ */}}
\DoxyCodeLine{00915\ \ \ \ \ scale\ =\ fe-\/>fft\_order\ -\/\ scale;}
\DoxyCodeLine{00916\ }
\DoxyCodeLine{00917\ \ \ \ \ \textcolor{comment}{/*\ The\ first\ point\ (DC\ coefficient)\ has\ no\ imaginary\ part\ */}}
\DoxyCodeLine{00918\ \ \ \ \ \{}
\DoxyCodeLine{00919\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00920\ \ \ \ \ \ \ \ \ spec[0]\ =\ fixlog(abs(fft[0])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00921\ \textcolor{preprocessor}{\#elif\ defined(FIXED\_POINT)}}
\DoxyCodeLine{00922\ \ \ \ \ \ \ \ \ spec[0]\ =\ FIXLN(abs(fft[0])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00923\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00924\ \ \ \ \ \ \ \ \ spec[0]\ =\ fft[0]\ *\ fft[0];}
\DoxyCodeLine{00925\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00926\ \ \ \ \ \}}
\DoxyCodeLine{00927\ }
\DoxyCodeLine{00928\ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <=\ fftsize\ /\ 2;\ j++)\ \{}
\DoxyCodeLine{00929\ \textcolor{preprocessor}{\#ifdef\ FIXED16}}
\DoxyCodeLine{00930\ \ \ \ \ \ \ \ \ int32\ rr\ =\ fixlog(abs(fft[j])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00931\ \ \ \ \ \ \ \ \ int32\ ii\ =\ fixlog(abs(fft[fftsize\ -\/\ j])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00932\ \ \ \ \ \ \ \ \ spec[j]\ =\ fe\_log\_add(rr,\ ii);}
\DoxyCodeLine{00933\ \textcolor{preprocessor}{\#elif\ defined(FIXED\_POINT)}}
\DoxyCodeLine{00934\ \ \ \ \ \ \ \ \ int32\ rr\ =\ FIXLN(abs(fft[j])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00935\ \ \ \ \ \ \ \ \ int32\ ii\ =\ FIXLN(abs(fft[fftsize\ -\/\ j])\ <<\ scale)\ *\ 2;}
\DoxyCodeLine{00936\ \ \ \ \ \ \ \ \ spec[j]\ =\ fe\_log\_add(rr,\ ii);}
\DoxyCodeLine{00937\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00938\ \ \ \ \ \ \ \ \ spec[j]\ =\ fft[j]\ *\ fft[j]\ +\ fft[fftsize\ -\/\ j]\ *\ fft[fftsize\ -\/\ j];}
\DoxyCodeLine{00939\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00940\ \ \ \ \ \}}
\DoxyCodeLine{00941\ \}}
\DoxyCodeLine{00942\ }
\DoxyCodeLine{00943\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00944\ fe\_mel\_spec(fe\_t\ *\ fe)}
\DoxyCodeLine{00945\ \{}
\DoxyCodeLine{00946\ \ \ \ \ \textcolor{keywordtype}{int}\ whichfilt;}
\DoxyCodeLine{00947\ \ \ \ \ powspec\_t\ *spec,\ *mfspec;}
\DoxyCodeLine{00948\ }
\DoxyCodeLine{00949\ \ \ \ \ \textcolor{comment}{/*\ Convenience\ poitners.\ */}}
\DoxyCodeLine{00950\ \ \ \ \ spec\ =\ fe-\/>spec;}
\DoxyCodeLine{00951\ \ \ \ \ mfspec\ =\ fe-\/>mfspec;}
\DoxyCodeLine{00952\ }
\DoxyCodeLine{00953\ \ \ \ \ \textcolor{keywordflow}{for}\ (whichfilt\ =\ 0;\ whichfilt\ <\ fe-\/>mel\_fb-\/>num\_filters;\ whichfilt++)\ \{}
\DoxyCodeLine{00954\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ spec\_start,\ filt\_start,\ i;}
\DoxyCodeLine{00955\ }
\DoxyCodeLine{00956\ \ \ \ \ \ \ \ \ spec\_start\ =\ fe-\/>mel\_fb-\/>spec\_start[whichfilt];}
\DoxyCodeLine{00957\ \ \ \ \ \ \ \ \ filt\_start\ =\ fe-\/>mel\_fb-\/>filt\_start[whichfilt];}
\DoxyCodeLine{00958\ }
\DoxyCodeLine{00959\ \textcolor{preprocessor}{\#ifdef\ FIXED\_POINT}}
\DoxyCodeLine{00960\ \ \ \ \ \ \ \ \ mfspec[whichfilt]\ =\ spec[spec\_start]\ +\ fe-\/>mel\_fb-\/>filt\_coeffs[filt\_start];}
\DoxyCodeLine{00961\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ fe-\/>mel\_fb-\/>filt\_width[whichfilt];\ i++)\ \{}
\DoxyCodeLine{00962\ \ \ \ \ \ \ \ \ \ \ \ \ mfspec[whichfilt]\ =\ fe\_log\_add(mfspec[whichfilt],}
\DoxyCodeLine{00963\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spec[spec\_start\ +\ i]\ +}
\DoxyCodeLine{00964\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>filt\_coeffs[filt\_start\ +\ i]);}
\DoxyCodeLine{00965\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00966\ \textcolor{preprocessor}{\#else\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00967\ \ \ \ \ \ \ \ \ mfspec[whichfilt]\ =\ 0;}
\DoxyCodeLine{00968\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>filt\_width[whichfilt];\ i++)}
\DoxyCodeLine{00969\ \ \ \ \ \ \ \ \ \ \ \ \ mfspec[whichfilt]\ +=}
\DoxyCodeLine{00970\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spec[spec\_start\ +\ i]\ *\ fe-\/>mel\_fb-\/>filt\_coeffs[filt\_start\ +\ i];}
\DoxyCodeLine{00971\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00972\ \ \ \ \ \}}
\DoxyCodeLine{00973\ \}}
\DoxyCodeLine{00974\ }
\DoxyCodeLine{00975\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00976\ fe\_mel\_cep(fe\_t\ *\ fe,\ mfcc\_t\ *mfcep)}
\DoxyCodeLine{00977\ \{}
\DoxyCodeLine{00978\ \ \ \ \ int32\ i;}
\DoxyCodeLine{00979\ \ \ \ \ powspec\_t\ *mfspec;}
\DoxyCodeLine{00980\ }
\DoxyCodeLine{00981\ \ \ \ \ \textcolor{comment}{/*\ Convenience\ pointer.\ */}}
\DoxyCodeLine{00982\ \ \ \ \ mfspec\ =\ fe-\/>mfspec;}
\DoxyCodeLine{00983\ }
\DoxyCodeLine{00984\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>num\_filters;\ ++i)\ \{}
\DoxyCodeLine{00985\ \textcolor{preprocessor}{\#ifndef\ FIXED\_POINT\ }\textcolor{comment}{/*\ It's\ already\ in\ log\ domain\ for\ fixed\ point\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00986\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (mfspec[i]\ >\ 0)}
\DoxyCodeLine{00987\ \ \ \ \ \ \ \ \ \ \ \ \ mfspec[i]\ =\ log(mfspec[i]);}
\DoxyCodeLine{00988\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ This\ number\ should\ be\ smaller\ than\ anything}}
\DoxyCodeLine{00989\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ else,\ but\ not\ too\ small,\ so\ as\ to\ avoid}}
\DoxyCodeLine{00990\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ infinities\ in\ the\ inverse\ transform\ (this\ is}}
\DoxyCodeLine{00991\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ the\ frequency-\/domain\ equivalent\ of}}
\DoxyCodeLine{00992\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ dithering)\ */}}
\DoxyCodeLine{00993\ \ \ \ \ \ \ \ \ \ \ \ \ mfspec[i]\ =\ -\/10.0;}
\DoxyCodeLine{00994\ \textcolor{preprocessor}{\#endif\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\textcolor{comment}{/*\ !FIXED\_POINT\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00995\ \ \ \ \ \}}
\DoxyCodeLine{00996\ }
\DoxyCodeLine{00997\ \ \ \ \ \textcolor{comment}{/*\ If\ we\ are\ doing\ LOG\_SPEC,\ then\ do\ nothing.\ */}}
\DoxyCodeLine{00998\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>log\_spec\ ==\ RAW\_LOG\_SPEC)\ \{}
\DoxyCodeLine{00999\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>feature\_dimension;\ i++)\ \{}
\DoxyCodeLine{01000\ \ \ \ \ \ \ \ \ \ \ \ \ mfcep[i]\ =\ (mfcc\_t)\ mfspec[i];}
\DoxyCodeLine{01001\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01002\ \ \ \ \ \}}
\DoxyCodeLine{01003\ \ \ \ \ \textcolor{comment}{/*\ For\ smoothed\ spectrum,\ do\ DCT-\/II\ followed\ by\ (its\ inverse)\ DCT-\/III\ */}}
\DoxyCodeLine{01004\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (fe-\/>log\_spec\ ==\ SMOOTH\_LOG\_SPEC)\ \{}
\DoxyCodeLine{01005\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ FIXME:\ This\ is\ probably\ broken\ for\ fixed-\/point.\ */}}
\DoxyCodeLine{01006\ \ \ \ \ \ \ \ \ fe\_dct2(fe,\ mfspec,\ mfcep,\ 0);}
\DoxyCodeLine{01007\ \ \ \ \ \ \ \ \ fe\_dct3(fe,\ mfcep,\ mfspec);}
\DoxyCodeLine{01008\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>feature\_dimension;\ i++)\ \{}
\DoxyCodeLine{01009\ \ \ \ \ \ \ \ \ \ \ \ \ mfcep[i]\ =\ (mfcc\_t)\ mfspec[i];}
\DoxyCodeLine{01010\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01011\ \ \ \ \ \}}
\DoxyCodeLine{01012\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (fe-\/>transform\ ==\ DCT\_II)}
\DoxyCodeLine{01013\ \ \ \ \ \ \ \ \ fe\_dct2(fe,\ mfspec,\ mfcep,\ FALSE);}
\DoxyCodeLine{01014\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (fe-\/>transform\ ==\ DCT\_HTK)}
\DoxyCodeLine{01015\ \ \ \ \ \ \ \ \ fe\_dct2(fe,\ mfspec,\ mfcep,\ TRUE);}
\DoxyCodeLine{01016\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{01017\ \ \ \ \ \ \ \ \ fe\_spec2cep(fe,\ mfspec,\ mfcep);}
\DoxyCodeLine{01018\ }
\DoxyCodeLine{01019\ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{01020\ \}}
\DoxyCodeLine{01021\ }
\DoxyCodeLine{01022\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01023\ fe\_spec2cep(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ powspec\_t\ *\ mflogspec,\ mfcc\_t\ *\ mfcep)}
\DoxyCodeLine{01024\ \{}
\DoxyCodeLine{01025\ \ \ \ \ int32\ i,\ j,\ beta;}
\DoxyCodeLine{01026\ }
\DoxyCodeLine{01027\ \ \ \ \ \textcolor{comment}{/*\ Compute\ C0\ separately\ (its\ basis\ vector\ is\ 1)\ to\ avoid}}
\DoxyCodeLine{01028\ \textcolor{comment}{\ \ \ \ \ *\ costly\ multiplications.\ */}}
\DoxyCodeLine{01029\ \ \ \ \ mfcep[0]\ =\ mflogspec[0]\ /\ 2;\ \textcolor{comment}{/*\ beta\ =\ 0.5\ */}}
\DoxyCodeLine{01030\ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <\ fe-\/>mel\_fb-\/>num\_filters;\ j++)}
\DoxyCodeLine{01031\ \ \ \ \ \ \ \ \ mfcep[0]\ +=\ mflogspec[j];\ \textcolor{comment}{/*\ beta\ =\ 1.0\ */}}
\DoxyCodeLine{01032\ \ \ \ \ mfcep[0]\ /=\ (frame\_t)\ fe-\/>mel\_fb-\/>num\_filters;}
\DoxyCodeLine{01033\ }
\DoxyCodeLine{01034\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ fe-\/>num\_cepstra;\ ++i)\ \{}
\DoxyCodeLine{01035\ \ \ \ \ \ \ \ \ mfcep[i]\ =\ 0;}
\DoxyCodeLine{01036\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ fe-\/>mel\_fb-\/>num\_filters;\ j++)\ \{}
\DoxyCodeLine{01037\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (j\ ==\ 0)}
\DoxyCodeLine{01038\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ beta\ =\ 1;\ \ \ \ \ \ \ \textcolor{comment}{/*\ 0.5\ */}}
\DoxyCodeLine{01039\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{01040\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ beta\ =\ 2;\ \ \ \ \ \ \ \textcolor{comment}{/*\ 1.0\ */}}
\DoxyCodeLine{01041\ \ \ \ \ \ \ \ \ \ \ \ \ mfcep[i]\ +=\ COSMUL(mflogspec[j],}
\DoxyCodeLine{01042\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>mel\_cosine[i][j])\ *\ beta;}
\DoxyCodeLine{01043\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01044\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Note\ that\ this\ actually\ normalizes\ by\ num\_filters,\ like\ the}}
\DoxyCodeLine{01045\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ *\ original\ Sphinx\ front-\/end,\ due\ to\ the\ doubled\ 'beta'\ factor}}
\DoxyCodeLine{01046\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ *\ above.\ \ */}}
\DoxyCodeLine{01047\ \ \ \ \ \ \ \ \ mfcep[i]\ /=\ (frame\_t)\ fe-\/>mel\_fb-\/>num\_filters\ *\ 2;}
\DoxyCodeLine{01048\ \ \ \ \ \}}
\DoxyCodeLine{01049\ \}}
\DoxyCodeLine{01050\ }
\DoxyCodeLine{01051\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01052\ fe\_dct2(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ powspec\_t\ *\ mflogspec,\ mfcc\_t\ *\ mfcep,\ \textcolor{keywordtype}{int}\ htk)}
\DoxyCodeLine{01053\ \{}
\DoxyCodeLine{01054\ \ \ \ \ int32\ i,\ j;}
\DoxyCodeLine{01055\ }
\DoxyCodeLine{01056\ \ \ \ \ \textcolor{comment}{/*\ Compute\ C0\ separately\ (its\ basis\ vector\ is\ 1)\ to\ avoid}}
\DoxyCodeLine{01057\ \textcolor{comment}{\ \ \ \ \ *\ costly\ multiplications.\ */}}
\DoxyCodeLine{01058\ \ \ \ \ mfcep[0]\ =\ mflogspec[0];}
\DoxyCodeLine{01059\ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <\ fe-\/>mel\_fb-\/>num\_filters;\ j++)}
\DoxyCodeLine{01060\ \ \ \ \ \ \ \ \ mfcep[0]\ +=\ mflogspec[j];}
\DoxyCodeLine{01061\ \ \ \ \ \textcolor{keywordflow}{if}\ (htk)}
\DoxyCodeLine{01062\ \ \ \ \ \ \ \ \ mfcep[0]\ =\ COSMUL(mfcep[0],\ fe-\/>mel\_fb-\/>sqrt\_inv\_2n);}
\DoxyCodeLine{01063\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{comment}{/*\ sqrt(1/N)\ =\ sqrt(2/N)\ *\ 1/sqrt(2)\ */}}
\DoxyCodeLine{01064\ \ \ \ \ \ \ \ \ mfcep[0]\ =\ COSMUL(mfcep[0],\ fe-\/>mel\_fb-\/>sqrt\_inv\_n);}
\DoxyCodeLine{01065\ }
\DoxyCodeLine{01066\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ fe-\/>num\_cepstra;\ ++i)\ \{}
\DoxyCodeLine{01067\ \ \ \ \ \ \ \ \ mfcep[i]\ =\ 0;}
\DoxyCodeLine{01068\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 0;\ j\ <\ fe-\/>mel\_fb-\/>num\_filters;\ j++)\ \{}
\DoxyCodeLine{01069\ \ \ \ \ \ \ \ \ \ \ \ \ mfcep[i]\ +=\ COSMUL(mflogspec[j],}
\DoxyCodeLine{01070\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>mel\_cosine[i][j]);}
\DoxyCodeLine{01071\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01072\ \ \ \ \ \ \ \ \ mfcep[i]\ =\ COSMUL(mfcep[i],\ fe-\/>mel\_fb-\/>sqrt\_inv\_2n);}
\DoxyCodeLine{01073\ \ \ \ \ \}}
\DoxyCodeLine{01074\ \}}
\DoxyCodeLine{01075\ }
\DoxyCodeLine{01076\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01077\ fe\_lifter(fe\_t\ *fe,\ mfcc\_t\ *mfcep)}
\DoxyCodeLine{01078\ \{}
\DoxyCodeLine{01079\ \ \ \ \ int32\ i;}
\DoxyCodeLine{01080\ }
\DoxyCodeLine{01081\ \ \ \ \ \textcolor{keywordflow}{if}\ (fe-\/>mel\_fb-\/>lifter\_val\ ==\ 0)}
\DoxyCodeLine{01082\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{01083\ }
\DoxyCodeLine{01084\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>num\_cepstra;\ ++i)\ \{}
\DoxyCodeLine{01085\ \ \ \ \ \ \ \ \ mfcep[i]\ =\ MFCCMUL(mfcep[i],\ fe-\/>mel\_fb-\/>lifter[i]);}
\DoxyCodeLine{01086\ \ \ \ \ \}}
\DoxyCodeLine{01087\ \}}
\DoxyCodeLine{01088\ }
\DoxyCodeLine{01089\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01090\ fe\_dct3(fe\_t\ *\ fe,\ \textcolor{keyword}{const}\ mfcc\_t\ *\ mfcep,\ powspec\_t\ *\ mflogspec)}
\DoxyCodeLine{01091\ \{}
\DoxyCodeLine{01092\ \ \ \ \ int32\ i,\ j;}
\DoxyCodeLine{01093\ }
\DoxyCodeLine{01094\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ fe-\/>mel\_fb-\/>num\_filters;\ ++i)\ \{}
\DoxyCodeLine{01095\ \ \ \ \ \ \ \ \ mflogspec[i]\ =\ COSMUL(mfcep[0],\ SQRT\_HALF);}
\DoxyCodeLine{01096\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (j\ =\ 1;\ j\ <\ fe-\/>num\_cepstra;\ j++)\ \{}
\DoxyCodeLine{01097\ \ \ \ \ \ \ \ \ \ \ \ \ mflogspec[i]\ +=\ COSMUL(mfcep[j],}
\DoxyCodeLine{01098\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fe-\/>mel\_fb-\/>mel\_cosine[j][i]);}
\DoxyCodeLine{01099\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{01100\ \ \ \ \ \ \ \ \ mflogspec[i]\ =\ COSMUL(mflogspec[i],\ fe-\/>mel\_fb-\/>sqrt\_inv\_2n);}
\DoxyCodeLine{01101\ \ \ \ \ \}}
\DoxyCodeLine{01102\ \}}
\DoxyCodeLine{01103\ }
\DoxyCodeLine{01104\ int32}
\DoxyCodeLine{01105\ fe\_write\_frame(fe\_t\ *\ fe,\ mfcc\_t\ *\ fea)}
\DoxyCodeLine{01106\ \{}
\DoxyCodeLine{01107\ \ \ \ \ fe\_spec\_magnitude(fe);}
\DoxyCodeLine{01108\ \ \ \ \ fe\_mel\_spec(fe);}
\DoxyCodeLine{01109\ \ \ \ \ fe\_mel\_cep(fe,\ fea);}
\DoxyCodeLine{01110\ \ \ \ \ fe\_lifter(fe,\ fea);}
\DoxyCodeLine{01111\ }
\DoxyCodeLine{01112\ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{01113\ \}}
\DoxyCodeLine{01114\ }
\DoxyCodeLine{01115\ \textcolor{keywordtype}{void}\ *}
\DoxyCodeLine{01116\ fe\_create\_2d(int32\ d1,\ int32\ d2,\ int32\ elem\_size)}
\DoxyCodeLine{01117\ \{}
\DoxyCodeLine{01118\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{void}\ *)ckd\_calloc\_2d(d1,\ d2,\ elem\_size);}
\DoxyCodeLine{01119\ \}}
\DoxyCodeLine{01120\ }
\DoxyCodeLine{01121\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{01122\ fe\_free\_2d(\textcolor{keywordtype}{void}\ *arr)}
\DoxyCodeLine{01123\ \{}
\DoxyCodeLine{01124\ \ \ \ \ ckd\_free\_2d((\textcolor{keywordtype}{void}\ **)arr);}
\DoxyCodeLine{01125\ \}}

\end{DoxyCode}
