\section{include/sphinxbase/cont\+\_\+ad.h File Reference}
\label{cont__ad_8h}\index{include/sphinxbase/cont\+\_\+ad.\+h@{include/sphinxbase/cont\+\_\+ad.\+h}}


Continuous A/D listening and silence filtering module.  


{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/ad.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ spseg\+\_\+s}
\item 
struct \textbf{ cont\+\_\+ad\+\_\+t}
\begin{DoxyCompactList}\small\item\em Continuous listening module or object Continuous listening module or object. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{cont__ad_8h_a2b7422b8273b64e5c9909f0d4ed2a109}} 
\#define {\bfseries C\+O\+N\+T\+\_\+\+A\+D\+\_\+\+S\+T\+A\+T\+E\+\_\+\+S\+IL}~0
\item 
\mbox{\label{cont__ad_8h_aa9664991fbf6001a8ee29e9be7dd667c}} 
\#define {\bfseries C\+O\+N\+T\+\_\+\+A\+D\+\_\+\+S\+T\+A\+T\+E\+\_\+\+S\+P\+E\+E\+CH}~1
\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{cont__ad_8h_a5153bcdd6b0bb75c8c37482a3c312c3d}} 
typedef struct \textbf{ spseg\+\_\+s} {\bfseries spseg\+\_\+t}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ cont\+\_\+ad\+\_\+t} $\ast$ \textbf{ cont\+\_\+ad\+\_\+init} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int32($\ast$adfunc)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int16 $\ast$buf, int32 max))
\begin{DoxyCompactList}\small\item\em Initialize a continuous listening/silence filtering object. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ cont\+\_\+ad\+\_\+t} $\ast$ \textbf{ cont\+\_\+ad\+\_\+init\+\_\+rawmode} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int32($\ast$adfunc)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int16 $\ast$buf, int32 max))
\begin{DoxyCompactList}\small\item\em Initializes a continuous listening object which simply passes data through (!) \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+read} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r, int16 $\ast$buf, int32 max)
\begin{DoxyCompactList}\small\item\em Read raw audio data into the silence filter. \end{DoxyCompactList}\item 
\mbox{\label{cont__ad_8h_a680721acc14ac191bbae3a4940ed357d}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+buffer\+\_\+space} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r)
\begin{DoxyCompactList}\small\item\em Get the maximum number of samples which can be passed into \doxyref{cont\+\_\+ad\+\_\+read()}{p.}{cont__ad_8h_ae664132adc514db01a1d5c1209ded4ba}. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+calib} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$cont)
\begin{DoxyCompactList}\small\item\em Calibrate the silence filter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+calib\+\_\+loop} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r, int16 $\ast$buf, int32 max)
\begin{DoxyCompactList}\small\item\em Calibrate the silence filter without an audio device. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+calib\+\_\+size} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r)
\begin{DoxyCompactList}\small\item\em Get the number of samples required to calibrate the silence filter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+set\+\_\+thresh} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$cont, int32 sil, int32 sp)
\begin{DoxyCompactList}\small\item\em Set silence and speech threshold parameters. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+set\+\_\+params} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r, int32 delta\+\_\+sil, int32 delta\+\_\+speech, int32 min\+\_\+noise, int32 max\+\_\+noise, int32 winsize, int32 speech\+\_\+onset, int32 sil\+\_\+onset, int32 leader, int32 trailer, float32 adapt\+\_\+rate)
\begin{DoxyCompactList}\small\item\em Set the changable parameters. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+get\+\_\+params} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r, int32 $\ast$delta\+\_\+sil, int32 $\ast$delta\+\_\+speech, int32 $\ast$min\+\_\+noise, int32 $\ast$max\+\_\+noise, int32 $\ast$winsize, int32 $\ast$speech\+\_\+onset, int32 $\ast$sil\+\_\+onset, int32 $\ast$leader, int32 $\ast$trailer, float32 $\ast$adapt\+\_\+rate)
\begin{DoxyCompactList}\small\item\em P\+WP 1/14/98 -- get the changable params. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+reset} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$cont)
\begin{DoxyCompactList}\small\item\em Reset, discarding any accumulated speech segments. \end{DoxyCompactList}\item 
\mbox{\label{cont__ad_8h_a381c3df971d43a20e8e8b8da43d2872d}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+close} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$cont)
\begin{DoxyCompactList}\small\item\em Close the continuous listening object. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ cont\+\_\+ad\+\_\+powhist\+\_\+dump} (F\+I\+LE $\ast$fp, \textbf{ cont\+\_\+ad\+\_\+t} $\ast$cont)
\begin{DoxyCompactList}\small\item\em Dump the power histogram. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+detach} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$c)
\begin{DoxyCompactList}\small\item\em Detach the given continuous listening module from the associated audio device. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+attach} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$c, \textbf{ ad\+\_\+rec\+\_\+t} $\ast$a, int32($\ast$func)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$, int16 $\ast$, int32))
\begin{DoxyCompactList}\small\item\em Attach the continuous listening module to the given audio device/function. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+set\+\_\+rawfp} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$c, F\+I\+LE $\ast$fp)
\begin{DoxyCompactList}\small\item\em Set a file for dumping raw audio input. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+ad\+\_\+set\+\_\+logfp} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$c, F\+I\+LE $\ast$fp)
\begin{DoxyCompactList}\small\item\em Set the file to which cont\+\_\+ad logs its progress. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ cont\+\_\+set\+\_\+thresh} (\textbf{ cont\+\_\+ad\+\_\+t} $\ast$r, int32 silence, int32 speech)
\begin{DoxyCompactList}\small\item\em Set the silence and speech thresholds. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Continuous A/D listening and silence filtering module. 

This module is intended to be interposed as a filter between any raw A/D source and the application to remove silence regions. Its main purpose is to remove regions of silence from the raw input speech. It is initialized with a raw A/D source function (during the cont\+\_\+ad\+\_\+init call). The application is responsible for setting up the A/D source, turning recording on and off as it desires. Filtered A/D data can be read by the application using the cont\+\_\+ad\+\_\+read function.

In other words, the application calls cont\+\_\+ad\+\_\+read instead of the raw A/D source function (e.\+g., ad\+\_\+read in libad) to obtain filtered A/D data with silence regions removed. This module itself does not enforce any other structural changes to the application.

The cont\+\_\+ad\+\_\+read function also updates an \char`\"{}absolute\char`\"{} timestamp (see \doxyref{cont\+\_\+ad\+\_\+t.\+read\+\_\+ts}{p.}{structcont__ad__t_a7b71e87abfcb3ca4ae73af34c86f955e}) at the end of each invocation. The timestamp indicates the total number of samples of A/D data read until this point, including data discarded as silence frames. The application is responsible for using this timestamp to make any policy decisions regarding utterance boundaries or whatever. 

\subsection{Function Documentation}
\mbox{\label{cont__ad_8h_a41e7f8c5925dba26dd51e8f7a3d16404}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+attach@{cont\+\_\+ad\+\_\+attach}}
\index{cont\+\_\+ad\+\_\+attach@{cont\+\_\+ad\+\_\+attach}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+attach()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+attach (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{c,  }\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{a,  }\item[{int32($\ast$)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$, int16 $\ast$, int32)}]{func }\end{DoxyParamCaption})}



Attach the continuous listening module to the given audio device/function. 

(Like cont\+\_\+ad\+\_\+init, but without the calibration.) \begin{DoxyReturn}{Returns}
0 if successful, -\/1 otherwise. 
\end{DoxyReturn}


Definition at line 1293 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_a7a1d0eaf8292a4549b00a97163999321}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+calib@{cont\+\_\+ad\+\_\+calib}}
\index{cont\+\_\+ad\+\_\+calib@{cont\+\_\+ad\+\_\+calib}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+calib()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+calib (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{cont }\end{DoxyParamCaption})}



Calibrate the silence filter. 

Calibration to determine an initial silence threshold. This function can be called any number of times. It should be called at least once immediately after cont\+\_\+ad\+\_\+init. The silence threshold is also updated internally once in a while, so this function only needs to be called in the middle if there is a definite change in the recording environment. The application is responsible for making sure that the raw audio source is turned on before the calibration. Return value\+: 0 if successful, $<$0 otherwise. 
\begin{DoxyParams}{Parameters}
{\em cont} & In\+: object pointer returned by cont\+\_\+ad\+\_\+init \\
\hline
\end{DoxyParams}


Definition at line 1022 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_a8a575044cf22d96a5ec8fb20410b0065}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+calib\+\_\+loop@{cont\+\_\+ad\+\_\+calib\+\_\+loop}}
\index{cont\+\_\+ad\+\_\+calib\+\_\+loop@{cont\+\_\+ad\+\_\+calib\+\_\+loop}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+calib\+\_\+loop()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+calib\+\_\+loop (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r,  }\item[{int16 $\ast$}]{buf,  }\item[{int32}]{max }\end{DoxyParamCaption})}



Calibrate the silence filter without an audio device. 

If the application has not passed an audio device into the silence filter at initialisation, this routine can be used to calibrate the filter. The buf (of length max samples) should contain audio data for calibration. This data is assumed to be completely consumed. More than one call may be necessary to fully calibrate. Return value\+: 0 if successful, $<$0 on failure, $>$0 if calibration not complete. 

Definition at line 1064 of file cont\+\_\+ad\+\_\+base.\+c.



References cont\+\_\+ad\+\_\+t\+::adbuf, cont\+\_\+ad\+\_\+t\+::headfrm, cont\+\_\+ad\+\_\+t\+::n\+\_\+calib\+\_\+frame, cont\+\_\+ad\+\_\+t\+::n\+\_\+frm, cont\+\_\+ad\+\_\+t\+::pow\+\_\+hist, cont\+\_\+ad\+\_\+t\+::spf, and cont\+\_\+ad\+\_\+t\+::thresh\+\_\+update.

\mbox{\label{cont__ad_8h_a6a86e16fb673748be753e2a281ce837a}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+calib\+\_\+size@{cont\+\_\+ad\+\_\+calib\+\_\+size}}
\index{cont\+\_\+ad\+\_\+calib\+\_\+size@{cont\+\_\+ad\+\_\+calib\+\_\+size}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+calib\+\_\+size()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+calib\+\_\+size (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r }\end{DoxyParamCaption})}



Get the number of samples required to calibrate the silence filter. 

Since, as mentioned above, the calibration data is assumed to be fully consumed, it may be desirable to \char`\"{}hold onto\char`\"{} this data in case it contains useful speech. This function returns the number of samples required to calibrate the silence filter, which is useful in allocating a buffer to store this data.

\begin{DoxyReturn}{Returns}
Number of samples required for successful calibration. 
\end{DoxyReturn}


Definition at line 1058 of file cont\+\_\+ad\+\_\+base.\+c.



References cont\+\_\+ad\+\_\+t\+::spf.

\mbox{\label{cont__ad_8h_a8f8284f329d1c0e04856ec9d13020dc4}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+detach@{cont\+\_\+ad\+\_\+detach}}
\index{cont\+\_\+ad\+\_\+detach@{cont\+\_\+ad\+\_\+detach}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+detach()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+detach (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{c }\end{DoxyParamCaption})}



Detach the given continuous listening module from the associated audio device. 

\begin{DoxyReturn}{Returns}
0 if successful, -\/1 otherwise. 
\end{DoxyReturn}


Definition at line 1281 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_aedd013bc2c6aca14fba02049ed7645d7}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+get\+\_\+params@{cont\+\_\+ad\+\_\+get\+\_\+params}}
\index{cont\+\_\+ad\+\_\+get\+\_\+params@{cont\+\_\+ad\+\_\+get\+\_\+params}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+get\+\_\+params()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+get\+\_\+params (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r,  }\item[{int32 $\ast$}]{delta\+\_\+sil,  }\item[{int32 $\ast$}]{delta\+\_\+speech,  }\item[{int32 $\ast$}]{min\+\_\+noise,  }\item[{int32 $\ast$}]{max\+\_\+noise,  }\item[{int32 $\ast$}]{winsize,  }\item[{int32 $\ast$}]{speech\+\_\+onset,  }\item[{int32 $\ast$}]{sil\+\_\+onset,  }\item[{int32 $\ast$}]{leader,  }\item[{int32 $\ast$}]{trailer,  }\item[{float32 $\ast$}]{adapt\+\_\+rate }\end{DoxyParamCaption})}



P\+WP 1/14/98 -- get the changable params. 

delta\+\_\+sil, delta\+\_\+speech, min\+\_\+noise, and max\+\_\+noise are in dB, winsize, speech\+\_\+onset, sil\+\_\+onset, leader and trailer are in frames of 16 ms length (256 samples @ 16k\+Hz sampling). 

Definition at line 1199 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_af28bf56f17d5cfebf4d960ebed44ca64}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+init@{cont\+\_\+ad\+\_\+init}}
\index{cont\+\_\+ad\+\_\+init@{cont\+\_\+ad\+\_\+init}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+init()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ cont\+\_\+ad\+\_\+t}$\ast$ cont\+\_\+ad\+\_\+init (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{ad,  }\item[{int32($\ast$)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int16 $\ast$buf, int32 max)}]{adfunc }\end{DoxyParamCaption})}



Initialize a continuous listening/silence filtering object. 

One time initialization of a continuous listening/silence filtering object/module. This can work in either \char`\"{}stream mode\char`\"{}, where it reads data from an audio device represented by {\ttfamily \doxyref{ad\+\_\+rec\+\_\+t}{p.}{structad__rec__t}}, or in \char`\"{}block mode\char`\"{}, where it filters out silence regions from blocks of data passed into it.


\begin{DoxyParams}{Parameters}
{\em ad} & An audio device to read from, or N\+U\+LL to operate in block mode. \\
\hline
{\em adfunc} & The function used to read audio from {\ttfamily ad}, or N\+U\+LL to operate in block mode. This is usually ad\+\_\+read(). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to a R\+E\+A\+D-\/\+O\+N\+LY structure used in other calls to the object. If any error occurs, the return value is N\+U\+LL. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em ad} & In\+: The A/D source object to be filtered \\
\hline
{\em adfunc} & In\+: adfunc = source function to be invoked to obtain raw A/D data. See \doxyref{ad.\+h}{p.}{ad_8h} for the required prototype definition. \\
\hline
\end{DoxyParams}
\mbox{\label{cont__ad_8h_a1a9bbf961917827f5d03adcd409dda35}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+init\+\_\+rawmode@{cont\+\_\+ad\+\_\+init\+\_\+rawmode}}
\index{cont\+\_\+ad\+\_\+init\+\_\+rawmode@{cont\+\_\+ad\+\_\+init\+\_\+rawmode}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+init\+\_\+rawmode()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ cont\+\_\+ad\+\_\+t}$\ast$ cont\+\_\+ad\+\_\+init\+\_\+rawmode (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{ad,  }\item[{int32($\ast$)(\textbf{ ad\+\_\+rec\+\_\+t} $\ast$ad, int16 $\ast$buf, int32 max)}]{adfunc }\end{DoxyParamCaption})}



Initializes a continuous listening object which simply passes data through (!) 

Like cont\+\_\+ad\+\_\+init, but put the module in raw mode; i.\+e., all data is passed through, unfiltered. (By special request.) \mbox{\label{cont__ad_8h_a288394cd94a4992bec9d3911cc875767}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+powhist\+\_\+dump@{cont\+\_\+ad\+\_\+powhist\+\_\+dump}}
\index{cont\+\_\+ad\+\_\+powhist\+\_\+dump@{cont\+\_\+ad\+\_\+powhist\+\_\+dump}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+powhist\+\_\+dump()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void cont\+\_\+ad\+\_\+powhist\+\_\+dump (\begin{DoxyParamCaption}\item[{F\+I\+LE $\ast$}]{fp,  }\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{cont }\end{DoxyParamCaption})}



Dump the power histogram. 

For debugging... 

Definition at line 231 of file cont\+\_\+ad\+\_\+base.\+c.



References cont\+\_\+ad\+\_\+t\+::pow\+\_\+hist, cont\+\_\+ad\+\_\+t\+::spf, cont\+\_\+ad\+\_\+t\+::sps, and cont\+\_\+ad\+\_\+t\+::tot\+\_\+frm.

\mbox{\label{cont__ad_8h_ae664132adc514db01a1d5c1209ded4ba}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+read@{cont\+\_\+ad\+\_\+read}}
\index{cont\+\_\+ad\+\_\+read@{cont\+\_\+ad\+\_\+read}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+read()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+read (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r,  }\item[{int16 $\ast$}]{buf,  }\item[{int32}]{max }\end{DoxyParamCaption})}



Read raw audio data into the silence filter. 

The main read routine for reading speech/silence segmented audio data. Audio data is copied into the caller provided buffer, much like a file read routine.

In \char`\"{}block mode\char`\"{}, i.\+e. if N\+U\+LL was passed as a read function to {\ttfamily cont\+\_\+ad\+\_\+init}, the data in {\ttfamily buf} is taken as input, and any non-\/silence data is written back to {\ttfamily buf} on exit. In this case, you must take care that {\ttfamily max} does not overflow the internal buffer of the silence filter. The available number of samples can be obtained by calling \doxyref{cont\+\_\+ad\+\_\+buffer\+\_\+space()}{p.}{cont__ad_8h_a680721acc14ac191bbae3a4940ed357d}. Any excess data will be discarded.

In normal mode, only speech segments are copied; silence segments are dropped. In rawmode (cont\+\_\+ad module initialized using \doxyref{cont\+\_\+ad\+\_\+init\+\_\+rawmode()}{p.}{cont__ad_8h_a1a9bbf961917827f5d03adcd409dda35}), all data are passed through to the caller. But, in either case, any single call to cont\+\_\+ad\+\_\+read will never return data that crosses a speech/silence segment boundary.

The following variables are updated for use by the caller (see \doxyref{cont\+\_\+ad\+\_\+t}{p.}{structcont__ad__t} above)\+: \doxyref{cont\+\_\+ad\+\_\+t.\+state}{p.}{structcont__ad__t_a5d9420ea711733d1eea9b8f29a638fdb}, \doxyref{cont\+\_\+ad\+\_\+t.\+read\+\_\+ts}{p.}{structcont__ad__t_a7b71e87abfcb3ca4ae73af34c86f955e}, \doxyref{cont\+\_\+ad\+\_\+t.\+seglen}{p.}{structcont__ad__t_a478939247e09a8ae142c8996ec17d8c8}, \doxyref{cont\+\_\+ad\+\_\+t.\+siglvl}{p.}{structcont__ad__t_a5524c052dcd0a3d1a1c3b1fc2134b62e}.

Return value\+: Number of samples actually read, possibly 0; $<$0 if E\+OF on A/D source. 
\begin{DoxyParams}{Parameters}
{\em r} & In\+: Object pointer returned by cont\+\_\+ad\+\_\+init \\
\hline
{\em buf} & In/\+Out\+: In block mode, contains input data. On return, buf contains A/D data returned by this function, if any. \\
\hline
{\em max} & In\+: Maximum number of samples to be filled into buf. N\+O\+TE\+: max must be at least 256; otherwise the functions returns -\/1. \\
\hline
\end{DoxyParams}


Definition at line 863 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_a12a017ea8a96dc54445e937bb9de24ae}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+reset@{cont\+\_\+ad\+\_\+reset}}
\index{cont\+\_\+ad\+\_\+reset@{cont\+\_\+ad\+\_\+reset}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+reset()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+reset (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{cont }\end{DoxyParamCaption})}



Reset, discarding any accumulated speech segments. 

\begin{DoxyReturn}{Returns}
0 if successful, $<$0 otherwise. 
\end{DoxyReturn}


Definition at line 1236 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_a16c5810eb19ed89522ef4c3394bbfe83}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+set\+\_\+logfp@{cont\+\_\+ad\+\_\+set\+\_\+logfp}}
\index{cont\+\_\+ad\+\_\+set\+\_\+logfp@{cont\+\_\+ad\+\_\+set\+\_\+logfp}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+set\+\_\+logfp()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+set\+\_\+logfp (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{c,  }\item[{F\+I\+LE $\ast$}]{fp }\end{DoxyParamCaption})}



Set the file to which cont\+\_\+ad logs its progress. 

Mainly for debugging. If {\ttfamily fp} is N\+U\+LL, logging is turned off.

\begin{DoxyReturn}{Returns}
0 if successful, -\/1 otherwise. 
\end{DoxyReturn}


Definition at line 1360 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_aa402397c575922ea352afe5e66c02a34}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+set\+\_\+params@{cont\+\_\+ad\+\_\+set\+\_\+params}}
\index{cont\+\_\+ad\+\_\+set\+\_\+params@{cont\+\_\+ad\+\_\+set\+\_\+params}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+set\+\_\+params()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+set\+\_\+params (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r,  }\item[{int32}]{delta\+\_\+sil,  }\item[{int32}]{delta\+\_\+speech,  }\item[{int32}]{min\+\_\+noise,  }\item[{int32}]{max\+\_\+noise,  }\item[{int32}]{winsize,  }\item[{int32}]{speech\+\_\+onset,  }\item[{int32}]{sil\+\_\+onset,  }\item[{int32}]{leader,  }\item[{int32}]{trailer,  }\item[{float32}]{adapt\+\_\+rate }\end{DoxyParamCaption})}



Set the changable parameters. 

delta\+\_\+sil, delta\+\_\+speech, min\+\_\+noise, and max\+\_\+noise are in dB, winsize, speech\+\_\+onset, sil\+\_\+onset, leader and trailer are in frames of 16 ms length (256 samples @ 16k\+Hz sampling). 

Definition at line 1126 of file cont\+\_\+ad\+\_\+base.\+c.



References E\+\_\+\+E\+R\+R\+OR.

\mbox{\label{cont__ad_8h_a662ed7c409479060e3b5ac8eb7bd1865}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+set\+\_\+rawfp@{cont\+\_\+ad\+\_\+set\+\_\+rawfp}}
\index{cont\+\_\+ad\+\_\+set\+\_\+rawfp@{cont\+\_\+ad\+\_\+set\+\_\+rawfp}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+set\+\_\+rawfp()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+set\+\_\+rawfp (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{c,  }\item[{F\+I\+LE $\ast$}]{fp }\end{DoxyParamCaption})}



Set a file for dumping raw audio input. 

The application can ask cont\+\_\+ad to dump the raw audio input that cont\+\_\+ad processes to a file. Use this function to give the F\+I\+L\+E$\ast$ to the cont\+\_\+ad object. If invoked with fp == N\+U\+LL, dumping is turned off. The application is responsible for opening and closing the file. If fp is non-\/\+N\+U\+LL, cont\+\_\+ad assumes the file pointer is valid and opened for writing.

\begin{DoxyReturn}{Returns}
0 if successful, -\/1 otherwise. 
\end{DoxyReturn}


Definition at line 1346 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_af9a8f9f66bbfd1ce48fe9366fafcc40d}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+ad\+\_\+set\+\_\+thresh@{cont\+\_\+ad\+\_\+set\+\_\+thresh}}
\index{cont\+\_\+ad\+\_\+set\+\_\+thresh@{cont\+\_\+ad\+\_\+set\+\_\+thresh}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+ad\+\_\+set\+\_\+thresh()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+ad\+\_\+set\+\_\+thresh (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{cont,  }\item[{int32}]{sil,  }\item[{int32}]{sp }\end{DoxyParamCaption})}



Set silence and speech threshold parameters. 

The silence threshold is the max power level, R\+E\+L\+A\+T\+I\+VE to the peak background noise level, in any silence frame. Similarly, the speech threshold is the min power level, R\+E\+L\+A\+T\+I\+VE to the peak background noise level, in any speech frame. In general, silence threshold $<$= speech threshold. Increasing the thresholds (say, from the default value of 2 to 3 or 4) reduces the sensitivity to background noise, but may also increase the chances of clipping actual speech. \begin{DoxyReturn}{Returns}
\+: 0 if successful, $<$0 otherwise. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em cont} & In\+: Object ptr from cont\+\_\+ad\+\_\+init \\
\hline
{\em sil} & In\+: silence threshold (default 2) \\
\hline
{\em sp} & In\+: speech threshold (default 2) \\
\hline
\end{DoxyParams}


Definition at line 1100 of file cont\+\_\+ad\+\_\+base.\+c.

\mbox{\label{cont__ad_8h_a382fe6375eae57a532c524d68bc3dd24}} 
\index{cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}!cont\+\_\+set\+\_\+thresh@{cont\+\_\+set\+\_\+thresh}}
\index{cont\+\_\+set\+\_\+thresh@{cont\+\_\+set\+\_\+thresh}!cont\+\_\+ad.\+h@{cont\+\_\+ad.\+h}}
\subsubsection{cont\+\_\+set\+\_\+thresh()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 cont\+\_\+set\+\_\+thresh (\begin{DoxyParamCaption}\item[{\textbf{ cont\+\_\+ad\+\_\+t} $\ast$}]{r,  }\item[{int32}]{silence,  }\item[{int32}]{speech }\end{DoxyParamCaption})}



Set the silence and speech thresholds. 

For this to remain permanently in effect, the auto\+\_\+thresh field of the continuous listening module should be set to F\+A\+L\+SE or 0. Otherwise the thresholds may be modified by the noise-\/ level adaptation. 

Definition at line 1308 of file cont\+\_\+ad\+\_\+base.\+c.



References cont\+\_\+ad\+\_\+t\+::n\+\_\+other, cont\+\_\+ad\+\_\+t\+::tail\+\_\+state, cont\+\_\+ad\+\_\+t\+::thresh\+\_\+sil, and cont\+\_\+ad\+\_\+t\+::thresh\+\_\+speech.

