\doxysection{sphinx\+\_\+pitch.\+c}
\label{sphinx__pitch_8c_source}\index{src/sphinx\_adtools/sphinx\_pitch.c@{src/sphinx\_adtools/sphinx\_pitch.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)\ 2008\ 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\ <string.h>}}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ <sphinxbase/cmd\_ln.h>}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#include\ <sphinxbase/yin.h>}}
\DoxyCodeLine{00043\ \textcolor{preprocessor}{\#include\ <sphinxbase/ckd\_alloc.h>}}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#include\ <sphinxbase/byteorder.h>}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#include\ <sphinxbase/strfuncs.h>}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#include\ <sphinxbase/err.h>}}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#include\ <sphinxbase/pio.h>}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#ifndef\ WORDS\_BIGENDIAN}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#define\ WORDS\_BIGENDIAN\ 0}}
\DoxyCodeLine{00051\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ \textcolor{keyword}{static}\ arg\_t\ defn[]\ =\ \{}
\DoxyCodeLine{00054\ \ \ \{\ \textcolor{stringliteral}{"{}-\/i"{}},}
\DoxyCodeLine{00055\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00056\ \ \ \ \ NULL,}
\DoxyCodeLine{00057\ \ \ \ \ \textcolor{stringliteral}{"{}Single\ audio\ input\ file"{}}\ \},}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \ \ \{\ \textcolor{stringliteral}{"{}-\/o"{}},}
\DoxyCodeLine{00060\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00061\ \ \ \ \ NULL,}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{stringliteral}{"{}Single\ text\ output\ file\ (standard\ output\ will\ be\ used\ if\ not\ given)"{}}\ \},}
\DoxyCodeLine{00063\ \ \ }
\DoxyCodeLine{00064\ \ \ \{\ \textcolor{stringliteral}{"{}-\/c"{}},}
\DoxyCodeLine{00065\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00066\ \ \ \ \ NULL,}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{stringliteral}{"{}Control\ file\ for\ batch\ processing"{}}\ \},}
\DoxyCodeLine{00068\ \ \ }
\DoxyCodeLine{00069\ \ \ \{\ \textcolor{stringliteral}{"{}-\/nskip"{}},}
\DoxyCodeLine{00070\ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{stringliteral}{"{}0"{}},}
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{stringliteral}{"{}If\ a\ control\ file\ was\ specified,\ the\ number\ of\ utterances\ to\ skip\ at\ the\ head\ of\ the\ file"{}}\ \},}
\DoxyCodeLine{00073\ \ \ }
\DoxyCodeLine{00074\ \ \ \{\ \textcolor{stringliteral}{"{}-\/runlen"{}},}
\DoxyCodeLine{00075\ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00076\ \ \ \ \ \textcolor{stringliteral}{"{}-\/1"{}},}
\DoxyCodeLine{00077\ \ \ \ \ \textcolor{stringliteral}{"{}If\ a\ control\ file\ was\ specified,\ the\ number\ of\ utterances\ to\ process\ (see\ -\/nskip\ too)"{}}\ \},}
\DoxyCodeLine{00078\ \ \ }
\DoxyCodeLine{00079\ \ \ \{\ \textcolor{stringliteral}{"{}-\/di"{}},}
\DoxyCodeLine{00080\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00081\ \ \ \ \ NULL,}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{stringliteral}{"{}Input\ directory,\ input\ file\ names\ are\ relative\ to\ this,\ if\ defined"{}}\ \},}
\DoxyCodeLine{00083\ \ \ }
\DoxyCodeLine{00084\ \ \ \{\ \textcolor{stringliteral}{"{}-\/ei"{}},}
\DoxyCodeLine{00085\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00086\ \ \ \ \ NULL,}
\DoxyCodeLine{00087\ \ \ \ \ \textcolor{stringliteral}{"{}Input\ extension\ to\ be\ applied\ to\ all\ input\ files"{}}\ \},}
\DoxyCodeLine{00088\ \ \ }
\DoxyCodeLine{00089\ \ \ \{\ \textcolor{stringliteral}{"{}-\/do"{}},}
\DoxyCodeLine{00090\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00091\ \ \ \ \ NULL,}
\DoxyCodeLine{00092\ \ \ \ \ \textcolor{stringliteral}{"{}Output\ directory,\ output\ files\ are\ relative\ to\ this"{}}\ \},}
\DoxyCodeLine{00093\ \ \ }
\DoxyCodeLine{00094\ \ \ \{\ \textcolor{stringliteral}{"{}-\/eo"{}},}
\DoxyCodeLine{00095\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00096\ \ \ \ \ NULL,}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{stringliteral}{"{}Output\ extension\ to\ be\ applied\ to\ all\ output\ files"{}}\ \},}
\DoxyCodeLine{00098\ \ \ }
\DoxyCodeLine{00099\ \ \ \{\ \textcolor{stringliteral}{"{}-\/nist"{}},}
\DoxyCodeLine{00100\ \ \ \ \ ARG\_BOOLEAN,}
\DoxyCodeLine{00101\ \ \ \ \ \textcolor{stringliteral}{"{}no"{}},}
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{stringliteral}{"{}Defines\ input\ format\ as\ NIST\ sphere"{}}\ \},}
\DoxyCodeLine{00103\ \ \ }
\DoxyCodeLine{00104\ \ \ \{\ \textcolor{stringliteral}{"{}-\/raw"{}},}
\DoxyCodeLine{00105\ \ \ \ \ ARG\_BOOLEAN,}
\DoxyCodeLine{00106\ \ \ \ \ \textcolor{stringliteral}{"{}no"{}},}
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{stringliteral}{"{}Defines\ input\ format\ as\ raw\ binary\ data"{}}\ \},}
\DoxyCodeLine{00108\ \ \ }
\DoxyCodeLine{00109\ \ \ \{\ \textcolor{stringliteral}{"{}-\/mswav"{}},}
\DoxyCodeLine{00110\ \ \ \ \ ARG\_BOOLEAN,}
\DoxyCodeLine{00111\ \ \ \ \ \textcolor{stringliteral}{"{}no"{}},}
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{stringliteral}{"{}Defines\ input\ format\ as\ Microsoft\ Wav\ (RIFF)"{}}\ \},}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00114\ \ \ \{\ \textcolor{stringliteral}{"{}-\/samprate"{}},}
\DoxyCodeLine{00115\ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{stringliteral}{"{}0"{}},}
\DoxyCodeLine{00117\ \ \ \ \ \textcolor{stringliteral}{"{}Sampling\ rate\ of\ audio\ data\ (will\ be\ determined\ automatically\ if\ 0)"{}}\ \},}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00119\ \ \ \{\ \textcolor{stringliteral}{"{}-\/input\_endian"{}},}
\DoxyCodeLine{00120\ \ \ \ \ ARG\_STRING,}
\DoxyCodeLine{00121\ \ \ \ \ NULL,}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{stringliteral}{"{}Endianness\ of\ audio\ data\ (will\ be\ determined\ automatically\ if\ not\ given)"{}}\ \},}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \ \ \{\ \textcolor{stringliteral}{"{}-\/fshift"{}},}
\DoxyCodeLine{00125\ \ \ \ \ ARG\_FLOAT32,}
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{stringliteral}{"{}0.01"{}},}
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{stringliteral}{"{}Frame\ shift:\ number\ of\ seconds\ between\ each\ analysis\ frame."{}}\ \},}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \ \ \{\ \textcolor{stringliteral}{"{}-\/flen"{}},}
\DoxyCodeLine{00130\ \ \ \ \ ARG\_FLOAT32,}
\DoxyCodeLine{00131\ \ \ \ \ \textcolor{stringliteral}{"{}0.025"{}},}
\DoxyCodeLine{00132\ \ \ \ \ \textcolor{stringliteral}{"{}Number\ of\ seconds\ in\ each\ analysis\ frame\ (needs\ to\ be\ greater\ than\ twice\ the\ longest\ period\ you\ wish\ to\ detect\ -\/\ to\ detect\ down\ to\ 80Hz\ you\ need\ a\ frame\ length\ of\ 2.0/80\ =\ 0.025)."{}}\ \},}
\DoxyCodeLine{00133\ }
\DoxyCodeLine{00134\ \ \ \{\ \textcolor{stringliteral}{"{}-\/smooth\_window"{}},}
\DoxyCodeLine{00135\ \ \ \ \ ARG\_INT32,}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{stringliteral}{"{}2"{}},}
\DoxyCodeLine{00137\ \ \ \ \ \textcolor{stringliteral}{"{}Number\ of\ frames\ on\ either\ side\ of\ the\ current\ frame\ to\ use\ for\ smoothing."{}}\ \},}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ \ \ \{\ \textcolor{stringliteral}{"{}-\/voice\_thresh"{}},}
\DoxyCodeLine{00140\ \ \ \ \ ARG\_FLOAT32,}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{stringliteral}{"{}0.1"{}},}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{stringliteral}{"{}Threshold\ of\ normalized\ difference\ under\ which\ to\ search\ for\ the\ fundamental\ period."{}}\ \},}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ \ \ \{\ \textcolor{stringliteral}{"{}-\/search\_range"{}},}
\DoxyCodeLine{00145\ \ \ \ \ ARG\_FLOAT32,}
\DoxyCodeLine{00146\ \ \ \ \ \textcolor{stringliteral}{"{}0.2"{}},}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{stringliteral}{"{}Fraction\ of\ the\ best\ local\ estimate\ to\ use\ as\ a\ search\ range\ for\ smoothing."{}}\ \},}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00149\ \ \ \{\ NULL,\ 0,\ NULL,\ NULL\ \}}
\DoxyCodeLine{00150\ \};}
\DoxyCodeLine{00151\ }
\DoxyCodeLine{00152\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ extract\_pitch(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *in,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *out);}
\DoxyCodeLine{00153\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ run\_control\_file(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *ctl);}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00156\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00157\ \{}
\DoxyCodeLine{00158\ \ \ \ \ cmd\_ln\_parse(defn,\ argc,\ argv,\ TRUE);}
\DoxyCodeLine{00159\ }
\DoxyCodeLine{00160\ \ \ \ \ \textcolor{comment}{/*\ Run\ a\ control\ file\ if\ requested.\ */}}
\DoxyCodeLine{00161\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/c"{}}))\ \{}
\DoxyCodeLine{00162\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (run\_control\_file(cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/c"{}}))\ <\ 0)}
\DoxyCodeLine{00163\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{00164\ \ \ \ \ \}}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00166\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (extract\_pitch(cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/i"{}}),\ cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/o"{}}))\ <\ 0)}
\DoxyCodeLine{00167\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{00168\ \ \ \ \ \}}
\DoxyCodeLine{00169\ }
\DoxyCodeLine{00170\ \ \ \ \ cmd\_ln\_free();}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00172\ \}}
\DoxyCodeLine{00173\ }
\DoxyCodeLine{00174\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00175\ guess\_file\_type(\textcolor{keywordtype}{char}\ \textcolor{keyword}{const}\ *file,\ FILE\ *infh)}
\DoxyCodeLine{00176\ \{}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{keywordtype}{char}\ header[4];}
\DoxyCodeLine{00178\ }
\DoxyCodeLine{00179\ \ \ \ \ fseek(infh,\ 0,\ SEEK\_SET);}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keywordflow}{if}\ (fread(header,\ 1,\ 4,\ infh)\ !=\ 4)\ \{}
\DoxyCodeLine{00181\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ read\ 4\ byte\ header"{}});}
\DoxyCodeLine{00182\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00183\ \ \ \ \ \}}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ ==\ memcmp(header,\ \textcolor{stringliteral}{"{}RIFF"{}},\ 4))\ \{}
\DoxyCodeLine{00185\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\%s\ appears\ to\ be\ a\ WAV\ file\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{00186\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}},\ TRUE);}
\DoxyCodeLine{00187\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}},\ FALSE);}
\DoxyCodeLine{00188\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}},\ FALSE);}
\DoxyCodeLine{00189\ \ \ \ \ \}}
\DoxyCodeLine{00190\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (0\ ==\ memcmp(header,\ \textcolor{stringliteral}{"{}NIST"{}},\ 4))\ \{}
\DoxyCodeLine{00191\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\%s\ appears\ to\ be\ a\ NIST\ SPHERE\ file\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{00192\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}},\ FALSE);}
\DoxyCodeLine{00193\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}},\ TRUE);}
\DoxyCodeLine{00194\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}},\ FALSE);}
\DoxyCodeLine{00195\ \ \ \ \ \}}
\DoxyCodeLine{00196\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}\%s\ appears\ to\ be\ raw\ data\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{00198\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}},\ FALSE);}
\DoxyCodeLine{00199\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}},\ FALSE);}
\DoxyCodeLine{00200\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}},\ TRUE);}
\DoxyCodeLine{00201\ \ \ \ \ \}}
\DoxyCodeLine{00202\ \ \ \ \ fseek(infh,\ 0,\ SEEK\_SET);}
\DoxyCodeLine{00203\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00204\ \}}
\DoxyCodeLine{00205\ }
\DoxyCodeLine{00206\ \textcolor{preprocessor}{\#define\ TRY\_FREAD(ptr,\ size,\ nmemb,\ stream)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00207\ \textcolor{preprocessor}{\ \ \ \ if\ (fread(ptr,\ size,\ nmemb,\ stream)\ !=\ (nmemb))\ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00208\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM("{}Failed\ to\ read\ \%d\ bytes"{},\ size\ *\ nmemb);\ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00209\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ goto\ error\_out;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00210\ \textcolor{preprocessor}{\ \ \ \ \}}}
\DoxyCodeLine{00211\ }
\DoxyCodeLine{00212\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00213\ read\_riff\_header(FILE\ *infh)}
\DoxyCodeLine{00214\ \{}
\DoxyCodeLine{00215\ \ \ \ \ \textcolor{keywordtype}{char}\ \textcolor{keywordtype}{id}[4];}
\DoxyCodeLine{00216\ \ \ \ \ int32\ intval,\ header\_len;}
\DoxyCodeLine{00217\ \ \ \ \ int16\ shortval;}
\DoxyCodeLine{00218\ }
\DoxyCodeLine{00219\ \ \ \ \ \textcolor{comment}{/*\ RIFF\ files\ are\ little-\/endian\ by\ definition.\ */}}
\DoxyCodeLine{00220\ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ \textcolor{stringliteral}{"{}little"{}});}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{comment}{/*\ Read\ in\ all\ the\ header\ chunks\ and\ etcetera.\ */}}
\DoxyCodeLine{00223\ \ \ \ \ TRY\_FREAD(\textcolor{keywordtype}{id},\ 1,\ 4,\ infh);}
\DoxyCodeLine{00224\ \ \ \ \ \textcolor{comment}{/*\ Total\ file\ length\ (we\ don't\ care)\ */}}
\DoxyCodeLine{00225\ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00226\ \ \ \ \ \textcolor{comment}{/*\ 'WAVE'\ */}}
\DoxyCodeLine{00227\ \ \ \ \ TRY\_FREAD(\textcolor{keywordtype}{id},\ 1,\ 4,\ infh);}
\DoxyCodeLine{00228\ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ !=\ memcmp(\textcolor{keywordtype}{id},\ \textcolor{stringliteral}{"{}WAVE"{}},\ 4))\ \{}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}This\ is\ not\ a\ WAVE\ file\(\backslash\)n"{}});}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00231\ \ \ \ \ \}}
\DoxyCodeLine{00232\ \ \ \ \ \textcolor{comment}{/*\ 'fmt\ '\ */}}
\DoxyCodeLine{00233\ \ \ \ \ TRY\_FREAD(\textcolor{keywordtype}{id},\ 1,\ 4,\ infh);}
\DoxyCodeLine{00234\ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ !=\ memcmp(\textcolor{keywordtype}{id},\ \textcolor{stringliteral}{"{}fmt\ "{}},\ 4))\ \{}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Format\ chunk\ missing\(\backslash\)n"{}});}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00237\ \ \ \ \ \}}
\DoxyCodeLine{00238\ \ \ \ \ \textcolor{comment}{/*\ Length\ of\ 'fmt\ '\ chunk\ */}}
\DoxyCodeLine{00239\ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00240\ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT32(\&intval);}
\DoxyCodeLine{00241\ \ \ \ \ header\_len\ =\ intval;}
\DoxyCodeLine{00242\ }
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{comment}{/*\ Data\ format.\ */}}
\DoxyCodeLine{00244\ \ \ \ \ TRY\_FREAD(\&shortval,\ 2,\ 1,\ infh);}
\DoxyCodeLine{00245\ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT16(\&shortval);}
\DoxyCodeLine{00246\ \ \ \ \ \textcolor{keywordflow}{if}\ (shortval\ !=\ 1)\ \{\ \textcolor{comment}{/*\ PCM\ */}}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}WAVE\ file\ is\ not\ in\ PCM\ format\(\backslash\)n"{}});}
\DoxyCodeLine{00248\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00249\ \ \ \ \ \}}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \ \ \ \ \textcolor{comment}{/*\ Number\ of\ channels.\ */}}
\DoxyCodeLine{00252\ \ \ \ \ TRY\_FREAD(\&shortval,\ 2,\ 1,\ infh);}
\DoxyCodeLine{00253\ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT16(\&shortval);}
\DoxyCodeLine{00254\ \ \ \ \ \textcolor{keywordflow}{if}\ (shortval\ !=\ 1)\ \{\ \textcolor{comment}{/*\ PCM\ */}}
\DoxyCodeLine{00255\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}WAVE\ file\ is\ not\ single\ channel\(\backslash\)n"{}});}
\DoxyCodeLine{00256\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00257\ \ \ \ \ \}}
\DoxyCodeLine{00258\ }
\DoxyCodeLine{00259\ \ \ \ \ \textcolor{comment}{/*\ Sampling\ rate\ (finally!)\ */}}
\DoxyCodeLine{00260\ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00261\ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT32(\&intval);}
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ ==\ 0)}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}},\ intval);}
\DoxyCodeLine{00264\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ !=\ intval)\ \{}
\DoxyCodeLine{00265\ \ \ \ \ \ \ \ \ E\_WARN(\textcolor{stringliteral}{"{}WAVE\ file\ sampling\ rate\ \%d\ !=\ -\/samprate\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00266\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ intval,\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}}));}
\DoxyCodeLine{00267\ \ \ \ \ \}}
\DoxyCodeLine{00268\ }
\DoxyCodeLine{00269\ \ \ \ \ \textcolor{comment}{/*\ Average\ bytes\ per\ second\ (we\ don't\ care)\ */}}
\DoxyCodeLine{00270\ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00271\ }
\DoxyCodeLine{00272\ \ \ \ \ \textcolor{comment}{/*\ Block\ alignment\ (we\ don't\ care)\ */}}
\DoxyCodeLine{00273\ \ \ \ \ TRY\_FREAD(\&shortval,\ 2,\ 1,\ infh);}
\DoxyCodeLine{00274\ }
\DoxyCodeLine{00275\ \ \ \ \ \textcolor{comment}{/*\ Bits\ per\ sample\ (must\ be\ 16)\ */}}
\DoxyCodeLine{00276\ \ \ \ \ TRY\_FREAD(\&shortval,\ 2,\ 1,\ infh);}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT16(\&shortval);}
\DoxyCodeLine{00278\ \ \ \ \ \textcolor{keywordflow}{if}\ (shortval\ !=\ 16)\ \{}
\DoxyCodeLine{00279\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}WAVE\ file\ is\ not\ 16-\/bit\(\backslash\)n"{}});}
\DoxyCodeLine{00280\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00281\ \ \ \ \ \}}
\DoxyCodeLine{00282\ }
\DoxyCodeLine{00283\ \ \ \ \ \textcolor{comment}{/*\ Any\ extra\ parameters.\ */}}
\DoxyCodeLine{00284\ \ \ \ \ \textcolor{keywordflow}{if}\ (header\_len\ >\ 16)}
\DoxyCodeLine{00285\ \ \ \ \ \ \ \ \ fseek(infh,\ header\_len\ -\/\ 16,\ SEEK\_CUR);}
\DoxyCodeLine{00286\ }
\DoxyCodeLine{00287\ \ \ \ \ \textcolor{comment}{/*\ Now\ skip\ to\ the\ 'data'\ chunk.\ */}}
\DoxyCodeLine{00288\ \ \ \ \ \textcolor{keywordflow}{while}\ (1)\ \{}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ TRY\_FREAD(\textcolor{keywordtype}{id},\ 1,\ 4,\ infh);}
\DoxyCodeLine{00290\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ ==\ memcmp(\textcolor{keywordtype}{id},\ \textcolor{stringliteral}{"{}data"{}},\ 4))\ \{}
\DoxyCodeLine{00291\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Total\ number\ of\ bytes\ of\ data\ (we\ don't\ care).\ */}}
\DoxyCodeLine{00292\ \ \ \ \ \ \ \ \ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00293\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00294\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00295\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00296\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Some\ other\ stuff...\ */}}
\DoxyCodeLine{00297\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Number\ of\ bytes\ of\ ...\ whatever\ */}}
\DoxyCodeLine{00298\ \ \ \ \ \ \ \ \ \ \ \ \ TRY\_FREAD(\&intval,\ 4,\ 1,\ infh);}
\DoxyCodeLine{00299\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)\ SWAP\_INT32(\&intval);}
\DoxyCodeLine{00300\ \ \ \ \ \ \ \ \ \ \ \ \ fseek(infh,\ intval,\ SEEK\_CUR);}
\DoxyCodeLine{00301\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00302\ \ \ \ \ \}}
\DoxyCodeLine{00303\ }
\DoxyCodeLine{00304\ \ \ \ \ \textcolor{comment}{/*\ We\ are\ ready\ to\ rumble.\ */}}
\DoxyCodeLine{00305\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00306\ error\_out:}
\DoxyCodeLine{00307\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00308\ \}}
\DoxyCodeLine{00309\ }
\DoxyCodeLine{00310\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00311\ read\_nist\_header(FILE\ *infh)}
\DoxyCodeLine{00312\ \{}
\DoxyCodeLine{00313\ \ \ \ \ \textcolor{keywordtype}{char}\ hdr[1024];}
\DoxyCodeLine{00314\ \ \ \ \ \textcolor{keywordtype}{char}\ *line,\ *c;}
\DoxyCodeLine{00315\ }
\DoxyCodeLine{00316\ \ \ \ \ TRY\_FREAD(hdr,\ 1,\ 1024,\ infh);}
\DoxyCodeLine{00317\ \ \ \ \ hdr[1023]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00318\ }
\DoxyCodeLine{00319\ \ \ \ \ \textcolor{comment}{/*\ Roughly\ parse\ it\ to\ find\ the\ sampling\ rate\ and\ byte\ order}}
\DoxyCodeLine{00320\ \textcolor{comment}{\ \ \ \ \ *\ (don't\ bother\ with\ other\ stuff)\ */}}
\DoxyCodeLine{00321\ \ \ \ \ \textcolor{keywordflow}{if}\ ((line\ =\ strstr(hdr,\ \textcolor{stringliteral}{"{}sample\_rate"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}No\ sampling\ rate\ in\ NIST\ header!\(\backslash\)n"{}});}
\DoxyCodeLine{00323\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00324\ \ \ \ \ \}}
\DoxyCodeLine{00325\ \ \ \ \ c\ =\ strchr(line,\ \textcolor{charliteral}{'\(\backslash\)n'});}
\DoxyCodeLine{00326\ \ \ \ \ \textcolor{keywordflow}{if}\ (c)\ *c\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00327\ \ \ \ \ c\ =\ strrchr(line,\ \textcolor{charliteral}{'\ '});}
\DoxyCodeLine{00328\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ ==\ NULL)\ \{}
\DoxyCodeLine{00329\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Could\ not\ find\ sampling\ rate!\(\backslash\)n"{}});}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00331\ \ \ \ \ \}}
\DoxyCodeLine{00332\ \ \ \ \ ++c;}
\DoxyCodeLine{00333\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ ==\ 0)}
\DoxyCodeLine{00334\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}},\ atoi(c));}
\DoxyCodeLine{00335\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ !=\ atoi(c))\ \{}
\DoxyCodeLine{00336\ \ \ \ \ \ \ \ \ E\_WARN(\textcolor{stringliteral}{"{}NIST\ file\ sampling\ rate\ \%d\ !=\ -\/samprate\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00337\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ atoi(c),\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}}));}
\DoxyCodeLine{00338\ \ \ \ \ \}}
\DoxyCodeLine{00339\ }
\DoxyCodeLine{00340\ \ \ \ \ \textcolor{keywordflow}{if}\ (line\ +\ strlen(line)\ <\ hdr\ +\ 1023)}
\DoxyCodeLine{00341\ \ \ \ \ \ \ \ \ line[strlen(line)]\ =\ \textcolor{charliteral}{'\ '};}
\DoxyCodeLine{00342\ \ \ \ \ \textcolor{keywordflow}{if}\ ((line\ =\ strstr(hdr,\ \textcolor{stringliteral}{"{}sample\_byte\_format"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00343\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}No\ sample\ byte\ format\ in\ NIST\ header!\(\backslash\)n"{}});}
\DoxyCodeLine{00344\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00345\ \ \ \ \ \}}
\DoxyCodeLine{00346\ \ \ \ \ c\ =\ strchr(line,\ \textcolor{charliteral}{'\(\backslash\)n'});}
\DoxyCodeLine{00347\ \ \ \ \ \textcolor{keywordflow}{if}\ (c)\ *c\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00348\ \ \ \ \ c\ =\ strrchr(line,\ \textcolor{charliteral}{'\ '});}
\DoxyCodeLine{00349\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ ==\ NULL)\ \{}
\DoxyCodeLine{00350\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Could\ not\ find\ sample\ byte\ order!\(\backslash\)n"{}});}
\DoxyCodeLine{00351\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00352\ \ \ \ \ \}}
\DoxyCodeLine{00353\ \ \ \ \ ++c;}
\DoxyCodeLine{00354\ \ \ \ \ \textcolor{keywordflow}{if}\ (0\ ==\ memcmp(c,\ \textcolor{stringliteral}{"{}01"{}},\ 2))\ \{}
\DoxyCodeLine{00355\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ \textcolor{stringliteral}{"{}little"{}});}
\DoxyCodeLine{00356\ \ \ \ \ \}}
\DoxyCodeLine{00357\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (0\ ==\ memcmp(c,\ \textcolor{stringliteral}{"{}10"{}},\ 2))\ \{}
\DoxyCodeLine{00358\ \ \ \ \ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ \textcolor{stringliteral}{"{}big"{}});}
\DoxyCodeLine{00359\ \ \ \ \ \}}
\DoxyCodeLine{00360\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00361\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Unknown\ byte\ order\ \%s\(\backslash\)n"{}},\ c);}
\DoxyCodeLine{00362\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00363\ \ \ \ \ \}}
\DoxyCodeLine{00364\ }
\DoxyCodeLine{00365\ \ \ \ \ \textcolor{comment}{/*\ We\ are\ ready\ to\ rumble.\ */}}
\DoxyCodeLine{00366\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00367\ error\_out:}
\DoxyCodeLine{00368\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00369\ \}}
\DoxyCodeLine{00370\ }
\DoxyCodeLine{00371\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00372\ extract\_pitch(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *in,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *out)}
\DoxyCodeLine{00373\ \{}
\DoxyCodeLine{00374\ \ \ \ \ FILE\ *infh\ =\ NULL,\ *outfh\ =\ NULL;}
\DoxyCodeLine{00375\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ flen,\ fshift,\ nsamps;}
\DoxyCodeLine{00376\ \ \ \ \ int16\ *buf\ =\ NULL;}
\DoxyCodeLine{00377\ \ \ \ \ yin\_t\ *yin\ =\ NULL;}
\DoxyCodeLine{00378\ \ \ \ \ uint16\ period,\ bestdiff;}
\DoxyCodeLine{00379\ \ \ \ \ int32\ sps;}
\DoxyCodeLine{00380\ }
\DoxyCodeLine{00381\ \ \ \ \ \textcolor{keywordflow}{if}\ (out)\ \{}
\DoxyCodeLine{00382\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((outfh\ =\ fopen(out,\ \textcolor{stringliteral}{"{}w"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00383\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ \%s\ for\ writing"{}},\ out);}
\DoxyCodeLine{00384\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00385\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00386\ \ \ \ \ \}}
\DoxyCodeLine{00387\ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00388\ \ \ \ \ \ \ \ \ outfh\ =\ stdout;}
\DoxyCodeLine{00389\ \ \ \ \ \}}
\DoxyCodeLine{00390\ \ \ \ \ \textcolor{keywordflow}{if}\ ((infh\ =\ fopen(in,\ \textcolor{stringliteral}{"{}rb"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00391\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ \%s\ for\ reading"{}},\ in);}
\DoxyCodeLine{00392\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00393\ \ \ \ \ \}}
\DoxyCodeLine{00394\ }
\DoxyCodeLine{00395\ \ \ \ \ \textcolor{comment}{/*\ If\ we\ weren't\ told\ what\ the\ file\ type\ is,\ weakly\ try\ to}}
\DoxyCodeLine{00396\ \textcolor{comment}{\ \ \ \ \ *\ determine\ it\ (actually\ it's\ pretty\ obvious)\ */}}
\DoxyCodeLine{00397\ \ \ \ \ \textcolor{keywordflow}{if}\ (!(cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}})}
\DoxyCodeLine{00398\ \ \ \ \ \ \ \ \ \ \ ||\ cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}})}
\DoxyCodeLine{00399\ \ \ \ \ \ \ \ \ \ \ ||\ cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}})))\ \{}
\DoxyCodeLine{00400\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (guess\_file\_type(in,\ infh)\ <\ 0)}
\DoxyCodeLine{00401\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00402\ \ \ \ \ \}}
\DoxyCodeLine{00403\ \ \ \ \ }
\DoxyCodeLine{00404\ \ \ \ \ \textcolor{comment}{/*\ Grab\ the\ sampling\ rate\ and\ byte\ order\ from\ the\ header\ and\ also}}
\DoxyCodeLine{00405\ \textcolor{comment}{\ \ \ \ \ *\ make\ sure\ this\ is\ 16-\/bit\ linear\ PCM.\ */}}
\DoxyCodeLine{00406\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}}))\ \{}
\DoxyCodeLine{00407\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (read\_riff\_header(infh)\ <\ 0)}
\DoxyCodeLine{00408\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00409\ \ \ \ \ \}}
\DoxyCodeLine{00410\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}}))\ \{}
\DoxyCodeLine{00411\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (read\_nist\_header(infh)\ <\ 0)}
\DoxyCodeLine{00412\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00413\ \ \ \ \ \}}
\DoxyCodeLine{00414\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}}))\ \{}
\DoxyCodeLine{00415\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Just\ use\ some\ defaults\ for\ sampling\ rate\ and\ endian.\ */}}
\DoxyCodeLine{00416\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}})\ ==\ NULL)\ \{}
\DoxyCodeLine{00417\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (WORDS\_BIGENDIAN)}
\DoxyCodeLine{00418\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ \textcolor{stringliteral}{"{}big"{}});}
\DoxyCodeLine{00419\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00420\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ \textcolor{stringliteral}{"{}little"{}});}
\DoxyCodeLine{00421\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00422\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ ==\ 0)}
\DoxyCodeLine{00423\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}},\ 16000);}
\DoxyCodeLine{00424\ \ \ \ \ \}}
\DoxyCodeLine{00425\ }
\DoxyCodeLine{00426\ \ \ \ \ \textcolor{comment}{/*\ Now\ read\ frames\ and\ write\ pitch\ estimates.\ */}}
\DoxyCodeLine{00427\ \ \ \ \ sps\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}});}
\DoxyCodeLine{00428\ \ \ \ \ flen\ =\ (size\_t)(0.5\ +\ sps\ *\ cmd\_ln\_float32(\textcolor{stringliteral}{"{}-\/flen"{}}));}
\DoxyCodeLine{00429\ \ \ \ \ fshift\ =\ (size\_t)(0.5\ +\ sps\ *\ cmd\_ln\_float32(\textcolor{stringliteral}{"{}-\/fshift"{}}));}
\DoxyCodeLine{00430\ \ \ \ \ yin\ =\ yin\_init(flen,\ cmd\_ln\_float32(\textcolor{stringliteral}{"{}-\/voice\_thresh"{}}),}
\DoxyCodeLine{00431\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_float32(\textcolor{stringliteral}{"{}-\/search\_range"{}}),}
\DoxyCodeLine{00432\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/smooth\_window"{}}));}
\DoxyCodeLine{00433\ \ \ \ \ \textcolor{keywordflow}{if}\ (yin\ ==\ NULL)\ \{}
\DoxyCodeLine{00434\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Failed\ to\ initialize\ YIN\(\backslash\)n"{}});}
\DoxyCodeLine{00435\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ error\_out;}
\DoxyCodeLine{00436\ \ \ \ \ \}}
\DoxyCodeLine{00437\ \ \ \ \ buf\ =\ ckd\_calloc(flen,\ \textcolor{keyword}{sizeof}(*buf));}
\DoxyCodeLine{00438\ \ \ \ \ \textcolor{comment}{/*\ Read\ the\ first\ full\ frame\ of\ data.\ */}}
\DoxyCodeLine{00439\ \ \ \ \ \textcolor{keywordflow}{if}\ (fread(buf,\ \textcolor{keyword}{sizeof}(*buf),\ flen,\ infh)\ !=\ flen)\ \{}
\DoxyCodeLine{00440\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Fail\ silently,\ which\ is\ probably\ okay.\ */}}
\DoxyCodeLine{00441\ \ \ \ \ \}}
\DoxyCodeLine{00442\ \ \ \ \ yin\_start(yin);}
\DoxyCodeLine{00443\ \ \ \ \ nsamps\ =\ 0;}
\DoxyCodeLine{00444\ \ \ \ \ \textcolor{keywordflow}{while}\ (!feof(infh))\ \{}
\DoxyCodeLine{00445\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Process\ a\ frame\ of\ data.\ */}}
\DoxyCodeLine{00446\ \ \ \ \ \ \ \ \ yin\_write(yin,\ buf);}
\DoxyCodeLine{00447\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (yin\_read(yin,\ \&period,\ \&bestdiff))\ \{}
\DoxyCodeLine{00448\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(outfh,\ \textcolor{stringliteral}{"{}\%.3f\ \%.2f\ \%.2f\(\backslash\)n"{}},}
\DoxyCodeLine{00449\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Time\ point.\ */}}
\DoxyCodeLine{00450\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})nsamps/sps,}
\DoxyCodeLine{00451\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ "{}Probability"{}\ of\ voicing.\ */}}
\DoxyCodeLine{00452\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ bestdiff\ >\ 32768\ ?\ 0.0\ :\ 1.0\ -\/\ (double)bestdiff\ /\ 32768,}
\DoxyCodeLine{00453\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Pitch\ (possibly\ bogus)\ */}}
\DoxyCodeLine{00454\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ period\ ==\ 0\ ?\ sps\ :\ (double)sps\ /\ period);}
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ \ \ \ \ nsamps\ +=\ fshift;}
\DoxyCodeLine{00456\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00457\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Shift\ it\ back\ and\ get\ the\ next\ frame's\ overlap.\ */}}
\DoxyCodeLine{00458\ \ \ \ \ \ \ \ \ memmove(buf,\ buf\ +\ fshift,\ (flen\ -\/\ fshift)\ *\ \textcolor{keyword}{sizeof}(*buf));}
\DoxyCodeLine{00459\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fread(buf\ +\ flen\ -\/\ fshift,\ \textcolor{keyword}{sizeof}(*buf),\ fshift,\ infh)\ !=\ fshift)\ \{}
\DoxyCodeLine{00460\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Fail\ silently\ (FIXME:\ really?)\ */}}
\DoxyCodeLine{00461\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00462\ \ \ \ \ \}}
\DoxyCodeLine{00463\ \ \ \ \ yin\_end(yin);}
\DoxyCodeLine{00464\ \ \ \ \ \textcolor{comment}{/*\ Process\ trailing\ frames\ of\ data.\ */}}
\DoxyCodeLine{00465\ \ \ \ \ \textcolor{keywordflow}{while}\ (yin\_read(yin,\ \&period,\ \&bestdiff))\ \{}
\DoxyCodeLine{00466\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(outfh,\ \textcolor{stringliteral}{"{}\%.3f\ \%.2f\ \%.2f\(\backslash\)n"{}},}
\DoxyCodeLine{00467\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Time\ point.\ */}}
\DoxyCodeLine{00468\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})nsamps/sps,}
\DoxyCodeLine{00469\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ "{}Probability"{}\ of\ voicing.\ */}}
\DoxyCodeLine{00470\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ bestdiff\ >\ 32768\ ?\ 0.0\ :\ 1.0\ -\/\ (double)bestdiff\ /\ 32768,}
\DoxyCodeLine{00471\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Pitch\ (possibly\ bogus)\ */}}
\DoxyCodeLine{00472\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ period\ ==\ 0\ ?\ sps\ :\ (double)sps\ /\ period);}
\DoxyCodeLine{00473\ \ \ \ \ \}}
\DoxyCodeLine{00474\ }
\DoxyCodeLine{00475\ \ \ \ \ \textcolor{keywordflow}{if}\ (yin)}
\DoxyCodeLine{00476\ \ \ \ \ \ \ \ \ yin\_free(yin);}
\DoxyCodeLine{00477\ \ \ \ \ ckd\_free(buf);}
\DoxyCodeLine{00478\ \ \ \ \ fclose(infh);}
\DoxyCodeLine{00479\ \ \ \ \ \textcolor{keywordflow}{if}\ (outfh\ !=\ stdout)}
\DoxyCodeLine{00480\ \ \ \ \ \ \ \ \ fclose(outfh);}
\DoxyCodeLine{00481\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00482\ }
\DoxyCodeLine{00483\ error\_out:}
\DoxyCodeLine{00484\ \ \ \ \ yin\_free(yin);}
\DoxyCodeLine{00485\ \ \ \ \ ckd\_free(buf);}
\DoxyCodeLine{00486\ \ \ \ \ \textcolor{keywordflow}{if}\ (infh)\ fclose(infh);}
\DoxyCodeLine{00487\ \ \ \ \ \textcolor{keywordflow}{if}\ (outfh\ \&\&\ outfh\ !=\ stdout)\ fclose(outfh);}
\DoxyCodeLine{00488\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00489\ \}}
\DoxyCodeLine{00490\ }
\DoxyCodeLine{00491\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00492\ run\_control\_file(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *ctl)}
\DoxyCodeLine{00493\ \{}
\DoxyCodeLine{00494\ \ \ \ \ FILE\ *ctlfh;}
\DoxyCodeLine{00495\ \ \ \ \ \textcolor{keywordtype}{char}\ *line;}
\DoxyCodeLine{00496\ \ \ \ \ \textcolor{keywordtype}{char}\ *di,\ *dout,\ *ei,\ *eio;}
\DoxyCodeLine{00497\ \ \ \ \ \textcolor{keywordtype}{size\_t}\ len;}
\DoxyCodeLine{00498\ \ \ \ \ \textcolor{keywordtype}{int}\ rv,\ guess\_type,\ guess\_sps,\ guess\_endian;}
\DoxyCodeLine{00499\ \ \ \ \ int32\ skip,\ runlen;}
\DoxyCodeLine{00500\ }
\DoxyCodeLine{00501\ \ \ \ \ skip\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/nskip"{}});}
\DoxyCodeLine{00502\ \ \ \ \ runlen\ =\ cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/runlen"{}});}
\DoxyCodeLine{00503\ }
\DoxyCodeLine{00504\ \ \ \ \ \textcolor{comment}{/*\ Whether\ to\ guess\ file\ types\ */}}
\DoxyCodeLine{00505\ \ \ \ \ guess\_type\ =\ !(cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}})}
\DoxyCodeLine{00506\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}})}
\DoxyCodeLine{00507\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ cmd\_ln\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}}));}
\DoxyCodeLine{00508\ \ \ \ \ \textcolor{comment}{/*\ Whether\ to\ guess\ sampling\ rate\ */}}
\DoxyCodeLine{00509\ \ \ \ \ guess\_sps\ =\ (cmd\_ln\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}})\ ==\ 0);}
\DoxyCodeLine{00510\ \ \ \ \ \textcolor{comment}{/*\ Whether\ to\ guess\ endian\ */}}
\DoxyCodeLine{00511\ \ \ \ \ guess\_endian\ =\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}})\ ==\ NULL);}
\DoxyCodeLine{00512\ }
\DoxyCodeLine{00513\ \ \ \ \ \textcolor{keywordflow}{if}\ ((ctlfh\ =\ fopen(ctl,\ \textcolor{stringliteral}{"{}r"{}}))\ ==\ NULL)\ \{}
\DoxyCodeLine{00514\ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ control\ file\ \%s"{}},\ ctl);}
\DoxyCodeLine{00515\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00516\ \ \ \ \ \}}
\DoxyCodeLine{00517\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/di"{}}))}
\DoxyCodeLine{00518\ \ \ \ \ \ \ \ \ di\ =\ string\_join(cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/di"{}}),\ \textcolor{stringliteral}{"{}/"{}},\ NULL);}
\DoxyCodeLine{00519\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00520\ \ \ \ \ \ \ \ \ di\ =\ ckd\_salloc(\textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00521\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/do"{}}))}
\DoxyCodeLine{00522\ \ \ \ \ \ \ \ \ dout\ =\ string\_join(cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/do"{}}),\ \textcolor{stringliteral}{"{}/"{}},\ NULL);}
\DoxyCodeLine{00523\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00524\ \ \ \ \ \ \ \ \ dout\ =\ ckd\_salloc(\textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00525\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/ei"{}}))}
\DoxyCodeLine{00526\ \ \ \ \ \ \ \ \ ei\ =\ string\_join(\textcolor{stringliteral}{"{}."{}},\ cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/ei"{}}),\ NULL);}
\DoxyCodeLine{00527\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00528\ \ \ \ \ \ \ \ \ ei\ =\ ckd\_salloc(\textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00529\ \ \ \ \ \textcolor{keywordflow}{if}\ (cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/eo"{}}))}
\DoxyCodeLine{00530\ \ \ \ \ \ \ \ \ eio\ =\ string\_join(\textcolor{stringliteral}{"{}."{}},\ cmd\_ln\_str(\textcolor{stringliteral}{"{}-\/eo"{}}),\ NULL);}
\DoxyCodeLine{00531\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00532\ \ \ \ \ \ \ \ \ eio\ =\ ckd\_salloc(\textcolor{stringliteral}{"{}"{}});}
\DoxyCodeLine{00533\ \ \ \ \ rv\ =\ 0;}
\DoxyCodeLine{00534\ \ \ \ \ \textcolor{keywordflow}{while}\ ((line\ =\ fread\_line(ctlfh,\ \&len))\ !=\ NULL)\ \{}
\DoxyCodeLine{00535\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ *infile,\ *outfile;}
\DoxyCodeLine{00536\ }
\DoxyCodeLine{00537\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (skip-\/-\/\ >\ 0)\ \{}
\DoxyCodeLine{00538\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(line);}
\DoxyCodeLine{00539\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00540\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00541\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (runlen\ ==\ 0)\ \{}
\DoxyCodeLine{00542\ \ \ \ \ \ \ \ \ \ \ \ \ ckd\_free(line);}
\DoxyCodeLine{00543\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00544\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00545\ \ \ \ \ \ \ \ \ -\/-\/runlen;}
\DoxyCodeLine{00546\ }
\DoxyCodeLine{00547\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (line[len-\/1]\ ==\ \textcolor{charliteral}{'\(\backslash\)n'})}
\DoxyCodeLine{00548\ \ \ \ \ \ \ \ \ \ \ \ \ line[len-\/1]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{00549\ }
\DoxyCodeLine{00550\ \ \ \ \ \ \ \ \ infile\ =\ string\_join(di,\ line,\ ei,\ NULL);}
\DoxyCodeLine{00551\ \ \ \ \ \ \ \ \ outfile\ =\ string\_join(dout,\ line,\ eio,\ NULL);}
\DoxyCodeLine{00552\ }
\DoxyCodeLine{00553\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Reset\ various\ guessed\ information\ */}}
\DoxyCodeLine{00554\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (guess\_type)\ \{}
\DoxyCodeLine{00555\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/nist"{}},\ FALSE);}
\DoxyCodeLine{00556\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/mswav"{}},\ FALSE);}
\DoxyCodeLine{00557\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_boolean(\textcolor{stringliteral}{"{}-\/raw"{}},\ FALSE);}
\DoxyCodeLine{00558\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00559\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (guess\_sps)}
\DoxyCodeLine{00560\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_int32(\textcolor{stringliteral}{"{}-\/samprate"{}},\ 0);}
\DoxyCodeLine{00561\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (guess\_endian)}
\DoxyCodeLine{00562\ \ \ \ \ \ \ \ \ \ \ \ \ cmd\_ln\_set\_str(\textcolor{stringliteral}{"{}-\/input\_endian"{}},\ NULL);}
\DoxyCodeLine{00563\ }
\DoxyCodeLine{00564\ \ \ \ \ \ \ \ \ rv\ =\ extract\_pitch(infile,\ outfile);}
\DoxyCodeLine{00565\ }
\DoxyCodeLine{00566\ \ \ \ \ \ \ \ \ ckd\_free(infile);}
\DoxyCodeLine{00567\ \ \ \ \ \ \ \ \ ckd\_free(outfile);}
\DoxyCodeLine{00568\ \ \ \ \ \ \ \ \ ckd\_free(line);}
\DoxyCodeLine{00569\ }
\DoxyCodeLine{00570\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (rv\ !=\ 0)}
\DoxyCodeLine{00571\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00572\ \ \ \ \ \}}
\DoxyCodeLine{00573\ \ \ \ \ ckd\_free(di);}
\DoxyCodeLine{00574\ \ \ \ \ ckd\_free(dout);}
\DoxyCodeLine{00575\ \ \ \ \ ckd\_free(ei);}
\DoxyCodeLine{00576\ \ \ \ \ ckd\_free(eio);}
\DoxyCodeLine{00577\ \ \ \ \ fclose(ctlfh);}
\DoxyCodeLine{00578\ \ \ \ \ \textcolor{keywordflow}{return}\ rv;}
\DoxyCodeLine{00579\ \}}

\end{DoxyCode}
