\section{include/sphinxbase/yin.h File Reference}
\label{yin_8h}\index{include/sphinxbase/yin.\+h@{include/sphinxbase/yin.\+h}}


Implementation of pitch estimation.  


{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\\*
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct {\bf yin\+\_\+s} {\bf yin\+\_\+t}\label{yin_8h_a69a22f00f601c099b232e01b94704c2c}

\begin{DoxyCompactList}\small\item\em Frame-\/based moving-\/window pitch estimator. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf yin\+\_\+t} $\ast$ {\bf yin\+\_\+init} (int frame\+\_\+size, float search\+\_\+threshold, float search\+\_\+range, int smooth\+\_\+window)\label{yin_8h_afc3a955f8d2215ed3d660737643c4f32}

\begin{DoxyCompactList}\small\item\em Initialize moving-\/window pitch estimation. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf yin\+\_\+free} ({\bf yin\+\_\+t} $\ast$pe)\label{yin_8h_ae587e0d984966c482f21ee4cb0952dd0}

\begin{DoxyCompactList}\small\item\em Free a moving-\/window pitch estimator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf yin\+\_\+start} ({\bf yin\+\_\+t} $\ast$pe)\label{yin_8h_a9a93d7c0fd3eb97d8ea735a76683ff4d}

\begin{DoxyCompactList}\small\item\em Start processing an utterance. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf yin\+\_\+end} ({\bf yin\+\_\+t} $\ast$pe)\label{yin_8h_a9182cabf44e517c2db3b67edacebece9}

\begin{DoxyCompactList}\small\item\em Mark the end of an utterance. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf yin\+\_\+write} ({\bf yin\+\_\+t} $\ast$pe, int16 const $\ast$frame)
\begin{DoxyCompactList}\small\item\em Feed a frame of data to the pitch estimator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int {\bf yin\+\_\+read} ({\bf yin\+\_\+t} $\ast$pe, uint16 $\ast$out\+\_\+period, uint16 $\ast$out\+\_\+bestdiff)
\begin{DoxyCompactList}\small\item\em Read a raw estimated pitch value from the pitch estimator. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Implementation of pitch estimation. 

\begin{DoxyAuthor}{Author}
David Huggins-\/\+Daines {\tt dhuggins@cs.\+cmu.\+edu}
\end{DoxyAuthor}
This implements part of the Y\+I\+N algorithm\+:

\char`\"{}\+Y\+I\+N, a fundamental frequency estimator for speech and music\char`\"{}. Alain de Cheveigné and Hideki Kawahara. Journal of the Acoustical Society of America, 111 (4), April 2002. 

Definition in file {\bf yin.\+h}.



\subsection{Function Documentation}
\index{yin.\+h@{yin.\+h}!yin\+\_\+read@{yin\+\_\+read}}
\index{yin\+\_\+read@{yin\+\_\+read}!yin.\+h@{yin.\+h}}
\subsubsection[{yin\+\_\+read}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int yin\+\_\+read (
\begin{DoxyParamCaption}
\item[{{\bf yin\+\_\+t} $\ast$}]{pe, }
\item[{uint16 $\ast$}]{out\+\_\+period, }
\item[{uint16 $\ast$}]{out\+\_\+bestdiff}
\end{DoxyParamCaption}
)}\label{yin_8h_a3a0ae5d5a543b9e71b34c9b4a285bdbf}


Read a raw estimated pitch value from the pitch estimator. 


\begin{DoxyParams}{Parameters}
{\em pe} & Pitch estimator. \\
\hline
{\em out\+\_\+period} & Output\+: an estimate of the period ({\itshape not} the pitch) of the signal in samples. \\
\hline
{\em out\+\_\+bestdiff} & Output\+: the minimum normalized difference value associated with {\ttfamily $\ast$out\+\_\+pitch}, in Q15 format (i.\+e. scaled by 32768). This can be interpreted as one minus the probability of voicing. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Non-\/zero if enough data was avaliable to return a pitch estimate, zero otherwise. 
\end{DoxyReturn}


Definition at line 221 of file yin.\+c.



References yin\+\_\+s\+::diff\+\_\+window, yin\+\_\+s\+::endut, yin\+\_\+s\+::nfr, yin\+\_\+s\+::period\+\_\+window, yin\+\_\+s\+::search\+\_\+range, yin\+\_\+s\+::search\+\_\+threshold, yin\+\_\+s\+::wcur, yin\+\_\+s\+::wsize, and yin\+\_\+s\+::wstart.

\index{yin.\+h@{yin.\+h}!yin\+\_\+write@{yin\+\_\+write}}
\index{yin\+\_\+write@{yin\+\_\+write}!yin.\+h@{yin.\+h}}
\subsubsection[{yin\+\_\+write}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void yin\+\_\+write (
\begin{DoxyParamCaption}
\item[{{\bf yin\+\_\+t} $\ast$}]{pe, }
\item[{int16 const $\ast$}]{frame}
\end{DoxyParamCaption}
)}\label{yin_8h_ac316a9b80593ad996df71b0f6df54d6c}


Feed a frame of data to the pitch estimator. 


\begin{DoxyParams}{Parameters}
{\em pe} & Pitch estimator. \\
\hline
{\em frame} & Frame of {\ttfamily frame\+\_\+size} (see \doxyref{yin\+\_\+init()}{p.}{yin_8h_afc3a955f8d2215ed3d660737643c4f32}) samples of audio data. \\
\hline
\end{DoxyParams}


Definition at line 194 of file yin.\+c.



References yin\+\_\+s\+::diff\+\_\+window, yin\+\_\+s\+::nfr, yin\+\_\+s\+::period\+\_\+window, yin\+\_\+s\+::search\+\_\+threshold, yin\+\_\+s\+::wsize, and yin\+\_\+s\+::wstart.

