\hypertarget{ai_8h}{
\section{libbroadway/include/broadway/ai.h File Reference}
\label{ai_8h}\index{libbroadway/include/broadway/ai.h@{libbroadway/include/broadway/ai.h}}
}
{\ttfamily \#include $<$types.h$>$}\par
{\ttfamily \#include $<$broadway.h$>$}\par
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{ai_8h_a60cd7fdce5e62c1151efa7a213acc746}{ai\_\-sample\_\-rate\_\-t} \{ \hyperlink{ai_8h_a60cd7fdce5e62c1151efa7a213acc746a1116642249176619f04011350878386d}{AI\_\-SAMPLE\_\-RATE\_\-48000} =  0, 
\hyperlink{ai_8h_a60cd7fdce5e62c1151efa7a213acc746aa6a586b09cf2cf0baecb5575ff0fc747}{AI\_\-SAMPLE\_\-RATE\_\-32000}
 \}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{ai_8h_a137310c0977765736bedf74782f2cf08}{ai\_\-initialize} (void)
\begin{DoxyCompactList}\small\item\em Initialize the AI subsystem. \item\end{DoxyCompactList}\item 
int \hyperlink{ai_8h_a71a8611577381c8eda5f50066fd179bb}{ai\_\-shutdown} (void)
\begin{DoxyCompactList}\small\item\em Shut down the AI subsystem. \item\end{DoxyCompactList}\item 
void \hyperlink{ai_8h_a6a1605cb632cdfd7b8cb06068b62970c}{ai\_\-set\_\-sample\_\-rate} (\hyperlink{ai_8h_a60cd7fdce5e62c1151efa7a213acc746}{ai\_\-sample\_\-rate\_\-t} rate)
\begin{DoxyCompactList}\small\item\em Set the sample rate. \item\end{DoxyCompactList}\item 
\hyperlink{ai_8h_a60cd7fdce5e62c1151efa7a213acc746}{ai\_\-sample\_\-rate\_\-t} \hyperlink{ai_8h_abbb9f7d4c8d3bb83c88ece2aa01522a6}{ai\_\-get\_\-sample\_\-rate} (void)
\begin{DoxyCompactList}\small\item\em Get the sample rate. \item\end{DoxyCompactList}\item 
void \hyperlink{ai_8h_abb9eb2608b7086736df30743175ee7cd}{ai\_\-enable\_\-irq} (int on\_\-sample, int($\ast$exec)(u32 irq, void $\ast$data), void $\ast$data)
\begin{DoxyCompactList}\small\item\em Enable the sample-\/reached IRQ. \item\end{DoxyCompactList}\item 
void \hyperlink{ai_8h_af4adcb45c7b8b7a2f8c0c4b0b118963b}{ai\_\-disable\_\-irq} (void)
\begin{DoxyCompactList}\small\item\em Disable the sample-\/reached IRQ. \item\end{DoxyCompactList}\item 
void \hyperlink{ai_8h_a1f84017dde13b74f480c25382a533192}{ai\_\-set\_\-volume} (u8 left, u8 right)
\begin{DoxyCompactList}\small\item\em Sets the volume of the stereo output. \item\end{DoxyCompactList}\item 
void \hyperlink{ai_8h_ac42b75c2f12c7c3e46b7bf6f6be8c74b}{ai\_\-get\_\-volume} (u8 $\ast$left, u8 $\ast$right)
\begin{DoxyCompactList}\small\item\em Gets the volume of the stereo output. \item\end{DoxyCompactList}\item 
u32 \hyperlink{ai_8h_a3122c67bacf71005b51bab2ba9b9b8d5}{ai\_\-samples\_\-played} (void)
\begin{DoxyCompactList}\small\item\em Gets how many samples have been played. \item\end{DoxyCompactList}\item 
\hypertarget{ai_8h_ad17937cd8d45f0c532786186e5976a4d}{
void \hyperlink{ai_8h_ad17937cd8d45f0c532786186e5976a4d}{ai\_\-reset\_\-sample\_\-counter} (void)}
\label{ai_8h_ad17937cd8d45f0c532786186e5976a4d}

\begin{DoxyCompactList}\small\item\em Resets the sample played counter. \item\end{DoxyCompactList}\item 
int \hyperlink{ai_8h_ad4f90d5d0b62dfb33298b699a380d7c4}{ai\_\-is\_\-playing} (void)
\begin{DoxyCompactList}\small\item\em Returns whether AI is playing audio or not. \item\end{DoxyCompactList}\item 
int \hyperlink{ai_8h_ab341c5bdc14500b57cb093adf3a09c98}{ai\_\-play} (int play)
\begin{DoxyCompactList}\small\item\em Starts or stops the AI from playing audio. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
An abstraction of the Audio Interface (AI). Controls various portions of the audio output (including volume and sample rate). 

\subsection{Enumeration Type Documentation}
\hypertarget{ai_8h_a60cd7fdce5e62c1151efa7a213acc746}{
\index{ai.h@{ai.h}!ai\_\-sample\_\-rate\_\-t@{ai\_\-sample\_\-rate\_\-t}}
\index{ai\_\-sample\_\-rate\_\-t@{ai\_\-sample\_\-rate\_\-t}!ai.h@{ai.h}}
\subsubsection[{ai\_\-sample\_\-rate\_\-t}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf ai\_\-sample\_\-rate\_\-t}}}
\label{ai_8h_a60cd7fdce5e62c1151efa7a213acc746}
The sample rates supported by AI \begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{AI\_\-SAMPLE\_\-RATE\_\-48000@{AI\_\-SAMPLE\_\-RATE\_\-48000}!ai.h@{ai.h}}\index{ai.h@{ai.h}!AI\_\-SAMPLE\_\-RATE\_\-48000@{AI\_\-SAMPLE\_\-RATE\_\-48000}}\item[{\em 
\hypertarget{ai_8h_a60cd7fdce5e62c1151efa7a213acc746a1116642249176619f04011350878386d}{
AI\_\-SAMPLE\_\-RATE\_\-48000}
\label{ai_8h_a60cd7fdce5e62c1151efa7a213acc746a1116642249176619f04011350878386d}
}]48kHz \index{AI\_\-SAMPLE\_\-RATE\_\-32000@{AI\_\-SAMPLE\_\-RATE\_\-32000}!ai.h@{ai.h}}\index{ai.h@{ai.h}!AI\_\-SAMPLE\_\-RATE\_\-32000@{AI\_\-SAMPLE\_\-RATE\_\-32000}}\item[{\em 
\hypertarget{ai_8h_a60cd7fdce5e62c1151efa7a213acc746aa6a586b09cf2cf0baecb5575ff0fc747}{
AI\_\-SAMPLE\_\-RATE\_\-32000}
\label{ai_8h_a60cd7fdce5e62c1151efa7a213acc746aa6a586b09cf2cf0baecb5575ff0fc747}
}]32kHz \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{ai_8h_af4adcb45c7b8b7a2f8c0c4b0b118963b}{
\index{ai.h@{ai.h}!ai\_\-disable\_\-irq@{ai\_\-disable\_\-irq}}
\index{ai\_\-disable\_\-irq@{ai\_\-disable\_\-irq}!ai.h@{ai.h}}
\subsubsection[{ai\_\-disable\_\-irq}]{\setlength{\rightskip}{0pt plus 5cm}void ai\_\-disable\_\-irq (void)}}
\label{ai_8h_af4adcb45c7b8b7a2f8c0c4b0b118963b}


Disable the sample-\/reached IRQ. 

Turns off the IRQ that fires when the AI plays a specific sample. \begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_abb9eb2608b7086736df30743175ee7cd}{ai\_\-enable\_\-irq()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_abb9eb2608b7086736df30743175ee7cd}{
\index{ai.h@{ai.h}!ai\_\-enable\_\-irq@{ai\_\-enable\_\-irq}}
\index{ai\_\-enable\_\-irq@{ai\_\-enable\_\-irq}!ai.h@{ai.h}}
\subsubsection[{ai\_\-enable\_\-irq}]{\setlength{\rightskip}{0pt plus 5cm}void ai\_\-enable\_\-irq (int {\em on\_\-sample}, \/  int($\ast$)(u32 irq, void $\ast$data) {\em exec}, \/  void $\ast$ {\em data})}}
\label{ai_8h_abb9eb2608b7086736df30743175ee7cd}


Enable the sample-\/reached IRQ. 

Turns on the IRQ that fires when the AI plays a specified sample. 
\begin{DoxyParams}{Parameters}
\item[{\em on\_\-sample}]the sample that the IRQ fires on. \item[{\em exec}]the callback that is called when the IRQ fires. \item[{\em data}]data provided to the callback when it fires. \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_af4adcb45c7b8b7a2f8c0c4b0b118963b}{ai\_\-disable\_\-irq()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_abbb9f7d4c8d3bb83c88ece2aa01522a6}{
\index{ai.h@{ai.h}!ai\_\-get\_\-sample\_\-rate@{ai\_\-get\_\-sample\_\-rate}}
\index{ai\_\-get\_\-sample\_\-rate@{ai\_\-get\_\-sample\_\-rate}!ai.h@{ai.h}}
\subsubsection[{ai\_\-get\_\-sample\_\-rate}]{\setlength{\rightskip}{0pt plus 5cm}{\bf ai\_\-sample\_\-rate\_\-t} ai\_\-get\_\-sample\_\-rate (void)}}
\label{ai_8h_abbb9f7d4c8d3bb83c88ece2aa01522a6}


Get the sample rate. 

\begin{DoxyReturn}{Returns}
The sample rate that AI was set to use. -\/1 if there was an error. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_a6a1605cb632cdfd7b8cb06068b62970c}{ai\_\-set\_\-sample\_\-rate()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_ac42b75c2f12c7c3e46b7bf6f6be8c74b}{
\index{ai.h@{ai.h}!ai\_\-get\_\-volume@{ai\_\-get\_\-volume}}
\index{ai\_\-get\_\-volume@{ai\_\-get\_\-volume}!ai.h@{ai.h}}
\subsubsection[{ai\_\-get\_\-volume}]{\setlength{\rightskip}{0pt plus 5cm}void ai\_\-get\_\-volume (u8 $\ast$ {\em left}, \/  u8 $\ast$ {\em right})}}
\label{ai_8h_ac42b75c2f12c7c3e46b7bf6f6be8c74b}


Gets the volume of the stereo output. 


\begin{DoxyParams}{Parameters}
\item[{\em left}]a pointer to which the left volume is put. NULL if you don't want the output. \item[{\em right}]a pointer to which the right volume is put. NULL if you don't want the output. \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_a1f84017dde13b74f480c25382a533192}{ai\_\-set\_\-volume()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_a137310c0977765736bedf74782f2cf08}{
\index{ai.h@{ai.h}!ai\_\-initialize@{ai\_\-initialize}}
\index{ai\_\-initialize@{ai\_\-initialize}!ai.h@{ai.h}}
\subsubsection[{ai\_\-initialize}]{\setlength{\rightskip}{0pt plus 5cm}int ai\_\-initialize (void)}}
\label{ai_8h_a137310c0977765736bedf74782f2cf08}


Initialize the AI subsystem. 

Initializes the AI subsystem, registers the handler for the AI interrupt and performs all other required initialization tasks. \begin{DoxyReturn}{Returns}
If initialization was successful, returns 1. Otherwise 0. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_a71a8611577381c8eda5f50066fd179bb}{ai\_\-shutdown()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_ad4f90d5d0b62dfb33298b699a380d7c4}{
\index{ai.h@{ai.h}!ai\_\-is\_\-playing@{ai\_\-is\_\-playing}}
\index{ai\_\-is\_\-playing@{ai\_\-is\_\-playing}!ai.h@{ai.h}}
\subsubsection[{ai\_\-is\_\-playing}]{\setlength{\rightskip}{0pt plus 5cm}int ai\_\-is\_\-playing (void)}}
\label{ai_8h_ad4f90d5d0b62dfb33298b699a380d7c4}


Returns whether AI is playing audio or not. 

\begin{DoxyReturn}{Returns}
Returns 1 if it was playing, 0 otherwise. -\/1 if an error occurred. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_ab341c5bdc14500b57cb093adf3a09c98}{ai\_\-play()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_ab341c5bdc14500b57cb093adf3a09c98}{
\index{ai.h@{ai.h}!ai\_\-play@{ai\_\-play}}
\index{ai\_\-play@{ai\_\-play}!ai.h@{ai.h}}
\subsubsection[{ai\_\-play}]{\setlength{\rightskip}{0pt plus 5cm}int ai\_\-play (int {\em play})}}
\label{ai_8h_ab341c5bdc14500b57cb093adf3a09c98}


Starts or stops the AI from playing audio. 


\begin{DoxyParams}{Parameters}
\item[{\em play}]if 1 starts playing, or if 0 stops playing. \end{DoxyParams}
\begin{DoxyReturn}{Returns}
Returns 1 if it was playing, 0 otherwise. -\/1 if an error occurred. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_ad4f90d5d0b62dfb33298b699a380d7c4}{ai\_\-is\_\-playing()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_a3122c67bacf71005b51bab2ba9b9b8d5}{
\index{ai.h@{ai.h}!ai\_\-samples\_\-played@{ai\_\-samples\_\-played}}
\index{ai\_\-samples\_\-played@{ai\_\-samples\_\-played}!ai.h@{ai.h}}
\subsubsection[{ai\_\-samples\_\-played}]{\setlength{\rightskip}{0pt plus 5cm}u32 ai\_\-samples\_\-played (void)}}
\label{ai_8h_a3122c67bacf71005b51bab2ba9b9b8d5}


Gets how many samples have been played. 

Gets the number of stereo samples that have been played since the counter was last reset (either by a system reset or a manual reset.) \begin{DoxyReturn}{Returns}
How many samples were played. 0xFFFFFFFF if an error occurred. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_ad17937cd8d45f0c532786186e5976a4d}{ai\_\-reset\_\-sample\_\-counter} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_a6a1605cb632cdfd7b8cb06068b62970c}{
\index{ai.h@{ai.h}!ai\_\-set\_\-sample\_\-rate@{ai\_\-set\_\-sample\_\-rate}}
\index{ai\_\-set\_\-sample\_\-rate@{ai\_\-set\_\-sample\_\-rate}!ai.h@{ai.h}}
\subsubsection[{ai\_\-set\_\-sample\_\-rate}]{\setlength{\rightskip}{0pt plus 5cm}void ai\_\-set\_\-sample\_\-rate ({\bf ai\_\-sample\_\-rate\_\-t} {\em rate})}}
\label{ai_8h_a6a1605cb632cdfd7b8cb06068b62970c}


Set the sample rate. 

Must only be called when the AI is not playing audio. 
\begin{DoxyParams}{Parameters}
\item[{\em rate}]a value from ai\_\-sample\_\-rate\_\-t specifying the sample rate to use. \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_abbb9f7d4c8d3bb83c88ece2aa01522a6}{ai\_\-get\_\-sample\_\-rate()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_a1f84017dde13b74f480c25382a533192}{
\index{ai.h@{ai.h}!ai\_\-set\_\-volume@{ai\_\-set\_\-volume}}
\index{ai\_\-set\_\-volume@{ai\_\-set\_\-volume}!ai.h@{ai.h}}
\subsubsection[{ai\_\-set\_\-volume}]{\setlength{\rightskip}{0pt plus 5cm}void ai\_\-set\_\-volume (u8 {\em left}, \/  u8 {\em right})}}
\label{ai_8h_a1f84017dde13b74f480c25382a533192}


Sets the volume of the stereo output. 

Sets the volume of the output sound, with the left and right speakers being changable independantly 
\begin{DoxyParams}{Parameters}
\item[{\em left}]the volume on the left speaker. 0 is mute, 0xFF is maximum. \item[{\em right}]the volume on the right speaker. 0 is mute, 0xFF is maximum. \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_ac42b75c2f12c7c3e46b7bf6f6be8c74b}{ai\_\-get\_\-volume()} 
\end{DoxySeeAlso}
\hypertarget{ai_8h_a71a8611577381c8eda5f50066fd179bb}{
\index{ai.h@{ai.h}!ai\_\-shutdown@{ai\_\-shutdown}}
\index{ai\_\-shutdown@{ai\_\-shutdown}!ai.h@{ai.h}}
\subsubsection[{ai\_\-shutdown}]{\setlength{\rightskip}{0pt plus 5cm}int ai\_\-shutdown (void)}}
\label{ai_8h_a71a8611577381c8eda5f50066fd179bb}


Shut down the AI subsystem. 

Shuts down the AI subsystem, unregisters the handler for the AI interrupt and performs all other required shut down tasks. \begin{DoxyReturn}{Returns}
If shut down was successful, returns 1. Otherwise 0. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{ai_8h_a137310c0977765736bedf74782f2cf08}{ai\_\-initialize()} 
\end{DoxySeeAlso}
