\doxysection{include/sphinxbase/ad.h File Reference}
\label{ad_8h}\index{include/sphinxbase/ad.h@{include/sphinxbase/ad.h}}


generic live audio interface for recording and playback  


{\ttfamily \#include $<$sphinx\+\_\+config.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ ad\+\_\+rec\+\_\+t}
\item 
struct \textbf{ ad\+\_\+play\+\_\+t}
\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ AD\+\_\+\+SAMPLE\+\_\+\+SIZE}~(sizeof(int16))
\item 
\#define \textbf{ DEFAULT\+\_\+\+SAMPLES\+\_\+\+PER\+\_\+\+SEC}~16000
\item 
\#define \textbf{ AD\+\_\+\+OK}~0
\item 
\#define \textbf{ AD\+\_\+\+EOF}~-\/1
\item 
\#define \textbf{ AD\+\_\+\+ERR\+\_\+\+GEN}~-\/1
\item 
\#define \textbf{ AD\+\_\+\+ERR\+\_\+\+NOT\+\_\+\+OPEN}~-\/2
\item 
\#define \textbf{ AD\+\_\+\+ERR\+\_\+\+WAVE}~-\/3
\item 
\#define \textbf{ DEFAULT\+\_\+\+DEVICE}~NULL
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ \textbf{ ad\+\_\+open\+\_\+dev} (const char $\ast$dev, int32 samples\+\_\+per\+\_\+sec)
\begin{DoxyCompactList}\small\item\em Open a specific audio device for recording. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ \textbf{ ad\+\_\+open\+\_\+sps} (int32 samples\+\_\+per\+\_\+sec)
\begin{DoxyCompactList}\small\item\em Open the default audio device with a given sampling rate. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ \textbf{ ad\+\_\+open} (void)
\begin{DoxyCompactList}\small\item\em Open the default audio device. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+start\+\_\+rec} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+stop\+\_\+rec} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+close} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+read} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$, int16 $\ast$buf, int32 max)
\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ \textbf{ ad\+\_\+open\+\_\+play\+\_\+sps} (int32 samples\+\_\+per\+\_\+sec)
\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ \textbf{ ad\+\_\+open\+\_\+play} (void)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+start\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+stop\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+close\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ ad\+\_\+write} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$, int16 $\ast$buf, int32 len)
\begin{DoxyCompactList}\small\item\em Queue a block of audio samples for playback. \end{DoxyCompactList}\item 
\label{ad_8h_a7eab4d2f35d221c569b85d4240b83600} 
SPHINXBASE\+\_\+\+EXPORT void {\bfseries ad\+\_\+mu2li} (int16 $\ast$outbuf, unsigned char $\ast$inbuf, int32 n\+\_\+samp)
\begin{DoxyCompactList}\small\item\em Convert mu-\/law data to int16 linear PCM format. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
generic live audio interface for recording and playback 



Definition in file \textbf{ ad.\+h}.



\doxysubsection{Macro Definition Documentation}
\label{ad_8h_a8aa969c2d485c3c17cf9abfd1bb88bdd} 
\index{ad.h@{ad.h}!AD\_EOF@{AD\_EOF}}
\index{AD\_EOF@{AD\_EOF}!ad.h@{ad.h}}
\doxysubsubsection{AD\_EOF}
{\footnotesize\ttfamily \#define AD\+\_\+\+EOF~-\/1}



Definition at line \textbf{ 145} of file \textbf{ ad.\+h}.

\label{ad_8h_ad75f71249c0e72e6867599af315fe27d} 
\index{ad.h@{ad.h}!AD\_ERR\_GEN@{AD\_ERR\_GEN}}
\index{AD\_ERR\_GEN@{AD\_ERR\_GEN}!ad.h@{ad.h}}
\doxysubsubsection{AD\_ERR\_GEN}
{\footnotesize\ttfamily \#define AD\+\_\+\+ERR\+\_\+\+GEN~-\/1}



Definition at line \textbf{ 146} of file \textbf{ ad.\+h}.

\label{ad_8h_a7ac31adbbd108d40792fc6ba3d14929f} 
\index{ad.h@{ad.h}!AD\_ERR\_NOT\_OPEN@{AD\_ERR\_NOT\_OPEN}}
\index{AD\_ERR\_NOT\_OPEN@{AD\_ERR\_NOT\_OPEN}!ad.h@{ad.h}}
\doxysubsubsection{AD\_ERR\_NOT\_OPEN}
{\footnotesize\ttfamily \#define AD\+\_\+\+ERR\+\_\+\+NOT\+\_\+\+OPEN~-\/2}



Definition at line \textbf{ 147} of file \textbf{ ad.\+h}.

\label{ad_8h_abdeca1c656c9ed4699402adb3556ae39} 
\index{ad.h@{ad.h}!AD\_ERR\_WAVE@{AD\_ERR\_WAVE}}
\index{AD\_ERR\_WAVE@{AD\_ERR\_WAVE}!ad.h@{ad.h}}
\doxysubsubsection{AD\_ERR\_WAVE}
{\footnotesize\ttfamily \#define AD\+\_\+\+ERR\+\_\+\+WAVE~-\/3}



Definition at line \textbf{ 148} of file \textbf{ ad.\+h}.

\label{ad_8h_a8d1358baba080a2f6b0d350928af7a89} 
\index{ad.h@{ad.h}!AD\_OK@{AD\_OK}}
\index{AD\_OK@{AD\_OK}!ad.h@{ad.h}}
\doxysubsubsection{AD\_OK}
{\footnotesize\ttfamily \#define AD\+\_\+\+OK~0}



Definition at line \textbf{ 144} of file \textbf{ ad.\+h}.

\label{ad_8h_a21e7cf6f08592c2fa2f78eb069f0e161} 
\index{ad.h@{ad.h}!AD\_SAMPLE\_SIZE@{AD\_SAMPLE\_SIZE}}
\index{AD\_SAMPLE\_SIZE@{AD\_SAMPLE\_SIZE}!ad.h@{ad.h}}
\doxysubsubsection{AD\_SAMPLE\_SIZE}
{\footnotesize\ttfamily \#define AD\+\_\+\+SAMPLE\+\_\+\+SIZE~(sizeof(int16))}



Definition at line \textbf{ 140} of file \textbf{ ad.\+h}.

\label{ad_8h_a84cb8bbda8042a324f49102bc200cc54} 
\index{ad.h@{ad.h}!DEFAULT\_DEVICE@{DEFAULT\_DEVICE}}
\index{DEFAULT\_DEVICE@{DEFAULT\_DEVICE}!ad.h@{ad.h}}
\doxysubsubsection{DEFAULT\_DEVICE}
{\footnotesize\ttfamily \#define DEFAULT\+\_\+\+DEVICE~NULL}



Definition at line \textbf{ 254} of file \textbf{ ad.\+h}.

\label{ad_8h_af6fb753bcfbd8dedec800ba4d0fb8546} 
\index{ad.h@{ad.h}!DEFAULT\_SAMPLES\_PER\_SEC@{DEFAULT\_SAMPLES\_PER\_SEC}}
\index{DEFAULT\_SAMPLES\_PER\_SEC@{DEFAULT\_SAMPLES\_PER\_SEC}!ad.h@{ad.h}}
\doxysubsubsection{DEFAULT\_SAMPLES\_PER\_SEC}
{\footnotesize\ttfamily \#define DEFAULT\+\_\+\+SAMPLES\+\_\+\+PER\+\_\+\+SEC~16000}



Definition at line \textbf{ 141} of file \textbf{ ad.\+h}.



\doxysubsection{Function Documentation}
\label{ad_8h_a6bcf3ed5e9d0c2d51086cae93bc3b3fc} 
\index{ad.h@{ad.h}!ad\_close@{ad\_close}}
\index{ad\_close@{ad\_close}!ad.h@{ad.h}}
\doxysubsubsection{ad\_close()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+close (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{handle }\end{DoxyParamCaption})}



Definition at line \textbf{ 303} of file \textbf{ ad\+\_\+alsa.\+c}.

\label{ad_8h_aa65454c205e3f573f4f3433a6a044448} 
\index{ad.h@{ad.h}!ad\_close\_play@{ad\_close\_play}}
\index{ad\_close\_play@{ad\_close\_play}!ad.h@{ad.h}}
\doxysubsubsection{ad\_close\_play()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+close\+\_\+play (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+play\+\_\+t} $\ast$}]{p }\end{DoxyParamCaption})}



Definition at line \textbf{ 306} of file \textbf{ play\+\_\+win32.\+c}.

\label{ad_8h_a78a497fc664b6b8c88eed88aa624a042} 
\index{ad.h@{ad.h}!ad\_open@{ad\_open}}
\index{ad\_open@{ad\_open}!ad.h@{ad.h}}
\doxysubsubsection{ad\_open()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ ad\+\_\+open (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Open the default audio device. 



Definition at line \textbf{ 296} of file \textbf{ ad\+\_\+alsa.\+c}.



References \textbf{ ad\+\_\+open()}, and \textbf{ ad\+\_\+open\+\_\+sps()}.



Referenced by \textbf{ ad\+\_\+open()}.

\label{ad_8h_a6cb4b7947a1c737a3889396eaabc69da} 
\index{ad.h@{ad.h}!ad\_open\_dev@{ad\_open\_dev}}
\index{ad\_open\_dev@{ad\_open\_dev}!ad.h@{ad.h}}
\doxysubsubsection{ad\_open\_dev()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ ad\+\_\+open\+\_\+dev (\begin{DoxyParamCaption}\item[{const char $\ast$}]{dev,  }\item[{int32}]{samples\+\_\+per\+\_\+sec }\end{DoxyParamCaption})}



Open a specific audio device for recording. 

The device is opened in non-\/blocking mode and placed in idle state.

\begin{DoxyReturn}{Returns}
pointer to read-\/only \doxyref{ad\+\_\+rec\+\_\+t}{p.}{structad__rec__t} structure if successful, NULL otherwise. The return value to be used as the first argument to other recording functions. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em dev} & Device name (platform-\/specific)  \\
\hline
{\em samples\+\_\+per\+\_\+sec} & Samples per second \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 252} of file \textbf{ ad\+\_\+alsa.\+c}.



References \textbf{ ad\+\_\+open\+\_\+dev()}, \textbf{ ad\+\_\+rec\+\_\+t\+::bps}, and \textbf{ ad\+\_\+rec\+\_\+t\+::sps}.



Referenced by \textbf{ ad\+\_\+open\+\_\+dev()}, and \textbf{ ad\+\_\+open\+\_\+sps()}.

\label{ad_8h_ad48b4d1fb6dfa7c5c5e8053e649ab94c} 
\index{ad.h@{ad.h}!ad\_open\_play@{ad\_open\_play}}
\index{ad\_open\_play@{ad\_open\_play}!ad.h@{ad.h}}
\doxysubsubsection{ad\_open\_play()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ ad\+\_\+open\+\_\+play (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Definition at line \textbf{ 299} of file \textbf{ play\+\_\+win32.\+c}.

\label{ad_8h_aa3a4ba52f5dac88a6d1a35ea289cfb07} 
\index{ad.h@{ad.h}!ad\_open\_play\_sps@{ad\_open\_play\_sps}}
\index{ad\_open\_play\_sps@{ad\_open\_play\_sps}!ad.h@{ad.h}}
\doxysubsubsection{ad\_open\_play\_sps()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ ad\+\_\+open\+\_\+play\+\_\+sps (\begin{DoxyParamCaption}\item[{int32}]{samples\+\_\+per\+\_\+sec }\end{DoxyParamCaption})}



Definition at line \textbf{ 246} of file \textbf{ play\+\_\+win32.\+c}.

\label{ad_8h_ab1b76be29cf610259ade485fec9c3a59} 
\index{ad.h@{ad.h}!ad\_open\_sps@{ad\_open\_sps}}
\index{ad\_open\_sps@{ad\_open\_sps}!ad.h@{ad.h}}
\doxysubsubsection{ad\_open\_sps()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ ad\+\_\+open\+\_\+sps (\begin{DoxyParamCaption}\item[{int32}]{samples\+\_\+per\+\_\+sec }\end{DoxyParamCaption})}



Open the default audio device with a given sampling rate. 


\begin{DoxyParams}{Parameters}
{\em samples\+\_\+per\+\_\+sec} & Samples per second \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 290} of file \textbf{ ad\+\_\+alsa.\+c}.



References \textbf{ ad\+\_\+open\+\_\+dev()}, and \textbf{ ad\+\_\+open\+\_\+sps()}.



Referenced by \textbf{ ad\+\_\+open()}, and \textbf{ ad\+\_\+open\+\_\+sps()}.

\label{ad_8h_ad4a5f4ab5267003169f6d3e15e54f697} 
\index{ad.h@{ad.h}!ad\_read@{ad\_read}}
\index{ad\_read@{ad\_read}!ad.h@{ad.h}}
\doxysubsubsection{ad\_read()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+read (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{handle,  }\item[{int16 $\ast$}]{buf,  }\item[{int32}]{max }\end{DoxyParamCaption})}



Definition at line \textbf{ 369} of file \textbf{ ad\+\_\+alsa.\+c}.

\label{ad_8h_a899e10aaecde4ab33b9849ed7bb9fb73} 
\index{ad.h@{ad.h}!ad\_start\_play@{ad\_start\_play}}
\index{ad\_start\_play@{ad\_start\_play}!ad.h@{ad.h}}
\doxysubsubsection{ad\_start\_play()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+start\+\_\+play (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+play\+\_\+t} $\ast$}]{p }\end{DoxyParamCaption})}



Definition at line \textbf{ 323} of file \textbf{ play\+\_\+win32.\+c}.

\label{ad_8h_a9cb212b93cb439ba04dec2109ca043ff} 
\index{ad.h@{ad.h}!ad\_start\_rec@{ad\_start\_rec}}
\index{ad\_start\_rec@{ad\_start\_rec}!ad.h@{ad.h}}
\doxysubsubsection{ad\_start\_rec()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+start\+\_\+rec (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{handle }\end{DoxyParamCaption})}



Definition at line \textbf{ 320} of file \textbf{ ad\+\_\+alsa.\+c}.

\label{ad_8h_a823c2efb2892ff2c9b112ffcda58ce17} 
\index{ad.h@{ad.h}!ad\_stop\_play@{ad\_stop\_play}}
\index{ad\_stop\_play@{ad\_stop\_play}!ad.h@{ad.h}}
\doxysubsubsection{ad\_stop\_play()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+stop\+\_\+play (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+play\+\_\+t} $\ast$}]{p }\end{DoxyParamCaption})}



Definition at line \textbf{ 340} of file \textbf{ play\+\_\+win32.\+c}.

\label{ad_8h_a20fb285a5f93e172f6a6e04359216aa5} 
\index{ad.h@{ad.h}!ad\_stop\_rec@{ad\_stop\_rec}}
\index{ad\_stop\_rec@{ad\_stop\_rec}!ad.h@{ad.h}}
\doxysubsubsection{ad\_stop\_rec()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+stop\+\_\+rec (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+rec\+\_\+t} $\ast$}]{handle }\end{DoxyParamCaption})}



Definition at line \textbf{ 347} of file \textbf{ ad\+\_\+alsa.\+c}.

\label{ad_8h_aea278a0c26051f4fe011778f225ea9c4} 
\index{ad.h@{ad.h}!ad\_write@{ad\_write}}
\index{ad\_write@{ad\_write}!ad.h@{ad.h}}
\doxysubsubsection{ad\_write()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 ad\+\_\+write (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+play\+\_\+t} $\ast$}]{p,  }\item[{int16 $\ast$}]{buf,  }\item[{int32}]{len }\end{DoxyParamCaption})}



Queue a block of audio samples for playback. 

Write the next block of [len] samples from rawbuf to the A/D device for playback. The device may queue less than len samples, possibly 0, since it is non-\/blocking. The application should resubmit the remaining data to be played. Return value\+: \# samples accepted for playback; -\/1 if error. 

Definition at line \textbf{ 373} of file \textbf{ play\+\_\+win32.\+c}.



References \textbf{ ad\+\_\+write()}.



Referenced by \textbf{ ad\+\_\+write()}.

