\section{Muse\-Dec Class Reference}
\label{classMuseDec}\index{MuseDec@{MuseDec}}
{\tt \#include $<$decoder.h$>$}

Inherited by {\bf Muse\-Dec\-Mp3}.

Inheritance diagram for Muse\-Dec:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=57pt]{classMuseDec__inherit__graph}
\end{center}
\end{figure}


\subsection{Detailed Description}
decoder parent abstraction class

This class should be inherited by every decoder implementation: it is the decoder parent class giving some common functionalities to its childs.

Most important thing for making decoders is to implement the pure virtual functions of this class, inheriting all the rest. The pure virtual functions to be carefully implemented in a decoder are:\begin{itemize}
\item {\bf Muse\-Dec::load}\item the destructor class for closing\item {\bf Muse\-Dec::seek}\item {\bf Muse\-Dec::get\_\-audio} Then the decoder must also take care to set properly the following variables inside the load function:\item {\bf Muse\-Dec::samplerate}\item {\bf Muse\-Dec::channels}\item {\bf Muse\-Dec::bitrate}\item {\bf Muse\-Dec::frametot}\item {\bf Muse\-Dec::seekable} And the following variables in the get\_\-audio function:\item {\bf Muse\-Dec::frames}\item {\bf Muse\-Dec::fps}\item {\bf Muse\-Dec::eos}\item {\bf Muse\-Dec::err}\end{itemize}


For example decoder implementations, please refer to:\begin{itemize}
\item {\bf Muse\-Dec\-Mp3} class implemented in {\bf dec\_\-mp3.h} and {\bf dec\_\-mp3.cpp}\item Muse\-Dec\-Ogg class implemented in {\bf dec\_\-ogg.h} and {\bf dec\_\-ogg.cpp}\end{itemize}




Definition at line 66 of file decoder.h.\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Muse\-Dec} ()
\begin{CompactList}\small\item\em decoder parent class constructor\item\end{CompactList}\item 
virtual {\bf $\sim$Muse\-Dec} ()
\begin{CompactList}\small\item\em decoder parent class destructor\item\end{CompactList}\item 
virtual int {\bf load} (char $\ast$file)=0
\begin{CompactList}\small\item\em open file in decoder\item\end{CompactList}\item 
virtual bool {\bf seek} (float pos)=0
\begin{CompactList}\small\item\em seek to a position\item\end{CompactList}\item 
virtual IN\_\-DATATYPE $\ast$ {\bf get\_\-audio} ()=0
\begin{CompactList}\small\item\em decode a chunk of channel audio\item\end{CompactList}\item 
void {\bf lock} ()\label{classMuseDec_a5}

\item 
void {\bf unlock} ()\label{classMuseDec_a6}

\end{CompactItemize}
\subsection*{Public Attributes}
\begin{CompactItemize}
\item 
char {\bf name} [5]\label{classMuseDec_m0}

\begin{CompactList}\small\item\em decoder short name (3 letters)\item\end{CompactList}\item 
int {\bf samplerate}
\begin{CompactList}\small\item\em samplerate of audio decoded\item\end{CompactList}\item 
int {\bf channels}\label{classMuseDec_m2}

\begin{CompactList}\small\item\em number of audio channels decoded\item\end{CompactList}\item 
int {\bf bitrate}\label{classMuseDec_m3}

\begin{CompactList}\small\item\em bitrate of the compressed audio being decoded\item\end{CompactList}\item 
int {\bf frames}\label{classMuseDec_m4}

\begin{CompactList}\small\item\em quantity of audio frames (16bit words) decoded\item\end{CompactList}\item 
int {\bf framepos}\label{classMuseDec_m5}

\begin{CompactList}\small\item\em position offset on the frames\item\end{CompactList}\item 
int {\bf frametot}\label{classMuseDec_m6}

\begin{CompactList}\small\item\em total frames in opened audio (if seekable, othwrwise 0)\item\end{CompactList}\item 
int {\bf fps}\label{classMuseDec_m7}

\begin{CompactList}\small\item\em samplerate / frames quantity\item\end{CompactList}\item 
bool {\bf seekable}\label{classMuseDec_m8}

\begin{CompactList}\small\item\em true if the channel audio is seekable\item\end{CompactList}\item 
bool {\bf eos}\label{classMuseDec_m9}

\begin{CompactList}\small\item\em true on end of stream reached\item\end{CompactList}\item 
bool {\bf err}\label{classMuseDec_m10}

\begin{CompactList}\small\item\em true when an error occurred during audio decoding\item\end{CompactList}\end{CompactItemize}


\subsection{Constructor \& Destructor Documentation}
\index{MuseDec@{MuseDec}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!MuseDec@{MuseDec}}\index{MuseDec@{Muse\-Dec}!MuseDec@{MuseDec}}
\index{MuseDec@{MuseDec}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Muse\-Dec::Muse\-Dec ()}\label{classMuseDec_a0}


decoder parent class constructor

The decoder implementations inheriting from this class can use their constructor to initialize their variables and to fill up the {\bf Muse\-Dec::name} buffer with their identification. 

Definition at line 8 of file decoder.cpp.\index{~MuseDec@{$\sim$MuseDec}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!~MuseDec@{$\sim$MuseDec}}\index{MuseDec@{Muse\-Dec}!~MuseDec@{$\sim$MuseDec}}
\index{~MuseDec@{$\sim$MuseDec}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Muse\-Dec::$\sim$Muse\-Dec ()\hspace{0.3cm}{\tt  [virtual]}}\label{classMuseDec_a1}


decoder parent class destructor

A decoder implementation should take care to close all files and free all buffers in the destructor. 

Definition at line 16 of file decoder.cpp.

\subsection{Member Function Documentation}
\index{get_audio@{get\_\-audio}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!get_audio@{get\_\-audio}}\index{MuseDec@{Muse\-Dec}!get_audio@{get\_\-audio}}
\index{get_audio@{get\_\-audio}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual IN\_\-DATATYPE$\ast$ Muse\-Dec::get\_\-audio ()\hspace{0.3cm}{\tt  [pure virtual]}}\label{classMuseDec_a4}


decode a chunk of channel audio

Decode another chunk of audio for the channel at the current position, this function is implementing the low-level decoder functionalities to obtain the audio pcm to be mixed.

The audio will be then resampled at a common rate and mixed by Mu\-SE.

This is a pure virtual function: needs to be implemented in decoders.

\begin{Desc}
\item[Returns:]pointer to decoded pcm buffer \end{Desc}


Implemented in {\bf Muse\-Dec\-Mp3} {\rm (p.\,\pageref{classMuseDecMp3_a5})}.\index{load@{load}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!load@{load}}\index{MuseDec@{Muse\-Dec}!load@{load}}
\index{load@{load}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual int Muse\-Dec::load (char $\ast$ {\em file})\hspace{0.3cm}{\tt  [pure virtual]}}\label{classMuseDec_a2}


open file in decoder

Open up a filename (full path) and makes it ready for decoding, the filename or url can be formed in different ways, depending on the decoder implementation.

This is a pure virtual function: needs to be implemented in decoders.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em file}]full pathname for file, or url accepted by the decoder \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on error, otherwise\begin{itemize}
\item 1 = success, channel is seekable\item 2 = success, channel is not seekable \end{itemize}
\end{Desc}


Implemented in {\bf Muse\-Dec\-Mp3} {\rm (p.\,\pageref{classMuseDecMp3_a2})}.\index{seek@{seek}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!seek@{seek}}\index{MuseDec@{Muse\-Dec}!seek@{seek}}
\index{seek@{seek}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool Muse\-Dec::seek (float {\em pos})\hspace{0.3cm}{\tt  [pure virtual]}}\label{classMuseDec_a3}


seek to a position

Seek position over the audio data available to an opened channel.

This operation is only possible if the channel is seekable (see the flag in this class and the return code of {\bf Muse\-Dec::load}).

This is a pure virtual function: needs to be implemented in decoders.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em pos}]floating point value from 0.0 to 1.0 \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true on success, false otherwise \end{Desc}


Implemented in {\bf Muse\-Dec\-Mp3} {\rm (p.\,\pageref{classMuseDecMp3_a3})}.

\subsection{Member Data Documentation}
\index{samplerate@{samplerate}!MuseDec@{MuseDec}}\index{MuseDec@{MuseDec}!samplerate@{samplerate}}\index{MuseDec@{Muse\-Dec}!samplerate@{samplerate}}
\index{samplerate@{samplerate}!MuseDec@{Muse\-Dec}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Muse\-Dec::samplerate}\label{classMuseDec_m1}


samplerate of audio decoded

the following variables describe the audio returned by {\bf Muse\-Dec::get\_\-audio} and must be setted up by the decoder implementation. 

Definition at line 133 of file decoder.h.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
{\bf decoder.h}\item 
decoder.cpp\end{CompactItemize}
