\section{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
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ ad\+\_\+rec\+\_\+t}
\item 
struct \textbf{ ad\+\_\+play\+\_\+t}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{ad_8h_a21e7cf6f08592c2fa2f78eb069f0e161}} 
\#define {\bfseries A\+D\+\_\+\+S\+A\+M\+P\+L\+E\+\_\+\+S\+I\+ZE}~(sizeof(int16))
\item 
\mbox{\label{ad_8h_af6fb753bcfbd8dedec800ba4d0fb8546}} 
\#define {\bfseries D\+E\+F\+A\+U\+L\+T\+\_\+\+S\+A\+M\+P\+L\+E\+S\+\_\+\+P\+E\+R\+\_\+\+S\+EC}~16000
\item 
\mbox{\label{ad_8h_a8d1358baba080a2f6b0d350928af7a89}} 
\#define {\bfseries A\+D\+\_\+\+OK}~0
\item 
\mbox{\label{ad_8h_a8aa969c2d485c3c17cf9abfd1bb88bdd}} 
\#define {\bfseries A\+D\+\_\+\+E\+OF}~-\/1
\item 
\mbox{\label{ad_8h_ad75f71249c0e72e6867599af315fe27d}} 
\#define {\bfseries A\+D\+\_\+\+E\+R\+R\+\_\+\+G\+EN}~-\/1
\item 
\mbox{\label{ad_8h_a7ac31adbbd108d40792fc6ba3d14929f}} 
\#define {\bfseries A\+D\+\_\+\+E\+R\+R\+\_\+\+N\+O\+T\+\_\+\+O\+P\+EN}~-\/2
\item 
\mbox{\label{ad_8h_abdeca1c656c9ed4699402adb3556ae39}} 
\#define {\bfseries A\+D\+\_\+\+E\+R\+R\+\_\+\+W\+A\+VE}~-\/3
\item 
\mbox{\label{ad_8h_a84cb8bbda8042a324f49102bc200cc54}} 
\#define {\bfseries D\+E\+F\+A\+U\+L\+T\+\_\+\+D\+E\+V\+I\+CE}~N\+U\+LL
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
\mbox{\label{ad_8h_a3def0da951e840fb4c72ef9259540686}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ad\+\_\+rec\+\_\+t} $\ast$ \textbf{ ad\+\_\+open} (void)
\begin{DoxyCompactList}\small\item\em Open the default audio device. \end{DoxyCompactList}\item 
\mbox{\label{ad_8h_a9cb212b93cb439ba04dec2109ca043ff}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+start\+\_\+rec} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
\mbox{\label{ad_8h_a20fb285a5f93e172f6a6e04359216aa5}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+stop\+\_\+rec} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
\mbox{\label{ad_8h_a6bcf3ed5e9d0c2d51086cae93bc3b3fc}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+close} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$)
\item 
\mbox{\label{ad_8h_ad4a5f4ab5267003169f6d3e15e54f697}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+read} (\textbf{ ad\+\_\+rec\+\_\+t} $\ast$, int16 $\ast$buf, int32 max)
\item 
\mbox{\label{ad_8h_a89f8a1820e1c5ea658e692d2d15a7315}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ {\bfseries ad\+\_\+open\+\_\+play\+\_\+sps} (int32 samples\+\_\+per\+\_\+sec)
\item 
\mbox{\label{ad_8h_a859bfe925f634f6bb3faa1a52c013388}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ad\+\_\+play\+\_\+t} $\ast$ {\bfseries ad\+\_\+open\+\_\+play} (void)
\item 
\mbox{\label{ad_8h_a899e10aaecde4ab33b9849ed7bb9fb73}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+start\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
\mbox{\label{ad_8h_a823c2efb2892ff2c9b112ffcda58ce17}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+stop\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
\mbox{\label{ad_8h_aa65454c205e3f573f4f3433a6a044448}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries ad\+\_\+close\+\_\+play} (\textbf{ ad\+\_\+play\+\_\+t} $\ast$)
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
\mbox{\label{ad_8h_a7eab4d2f35d221c569b85d4240b83600}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ad\+\_\+mu2li} (int16 $\ast$outbuf, unsigned char $\ast$inbuf, int32 n\+\_\+samp)
\begin{DoxyCompactList}\small\item\em Convert mu-\/law data to int16 linear P\+CM format. \end{DoxyCompactList}\end{DoxyCompactItemize}


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



\subsection{Function Documentation}
\mbox{\label{ad_8h_a43f66257a2457d6c711dc5c694bfc02f}} 
\index{ad.\+h@{ad.\+h}!ad\+\_\+open\+\_\+dev@{ad\+\_\+open\+\_\+dev}}
\index{ad\+\_\+open\+\_\+dev@{ad\+\_\+open\+\_\+dev}!ad.\+h@{ad.\+h}}
\subsubsection{ad\+\_\+open\+\_\+dev()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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, N\+U\+LL 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 252 of file ad\+\_\+alsa.\+c.



Referenced by ad\+\_\+open\+\_\+sps().

\mbox{\label{ad_8h_a71b4eec805fbe5c398ea0897816de6f0}} 
\index{ad.\+h@{ad.\+h}!ad\+\_\+open\+\_\+sps@{ad\+\_\+open\+\_\+sps}}
\index{ad\+\_\+open\+\_\+sps@{ad\+\_\+open\+\_\+sps}!ad.\+h@{ad.\+h}}
\subsubsection{ad\+\_\+open\+\_\+sps()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 290 of file ad\+\_\+alsa.\+c.



References ad\+\_\+open\+\_\+dev().



Referenced by ad\+\_\+open().

\mbox{\label{ad_8h_aea278a0c26051f4fe011778f225ea9c4}} 
\index{ad.\+h@{ad.\+h}!ad\+\_\+write@{ad\+\_\+write}}
\index{ad\+\_\+write@{ad\+\_\+write}!ad.\+h@{ad.\+h}}
\subsubsection{ad\+\_\+write()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ad\+\_\+write (\begin{DoxyParamCaption}\item[{\textbf{ ad\+\_\+play\+\_\+t} $\ast$}]{,  }\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 373 of file play\+\_\+win32.\+c.

