\section{KMid\-Simple\-API Class Reference}
\label{classKMidSimpleAPI}\index{KMidSimpleAPI@{KMidSimpleAPI}}
Simple API covering most of the uses of libkmid. A very simple API around the rest of libkmid.  


{\tt \#include $<$libkmid.h$>$}

\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
int {\bf k\-Mid\-Init} (void)
\begin{CompactList}\small\item\em Initializes libkmid. \item\end{CompactList}\item 
int {\bf k\-Mid\-Load} (const  char $\ast$filename)
\begin{CompactList}\small\item\em Loads a song that will be played with the next call to {\bf k\-Mid\-Play}{\rm (p.\,\pageref{classKMidSimpleAPI_e2})}(). \item\end{CompactList}\item 
int {\bf k\-Mid\-Play} (int loop=0)
\begin{CompactList}\small\item\em Plays the song currently loaded with {\bf k\-Mid\-Load}{\rm (p.\,\pageref{classKMidSimpleAPI_e1})}(). \item\end{CompactList}\item 
int {\bf k\-Mid\-Stop} (void)
\begin{CompactList}\small\item\em Stops playing a song inmediatly. \item\end{CompactList}\item 
void {\bf k\-Mid\-Destruct} (void)
\begin{CompactList}\small\item\em Releases the memory allocated by libkmid. \item\end{CompactList}\item 
int {\bf k\-Mid\-Is\-Playing} (void)
\begin{CompactList}\small\item\em Returns 1 if the library is playing a song, and 0 if it's not. \item\end{CompactList}\item 
int {\bf k\-Mid\-Devices} (void)
\begin{CompactList}\small\item\em Returns the number of MIDI devices ( MIDI ports + synthesizers ). \item\end{CompactList}\item 
const  char $\ast$ {\bf k\-Mid\-Name} (int i)
\begin{CompactList}\small\item\em Returns the name of the i-th device . \item\end{CompactList}\item 
const  char $\ast$ {\bf k\-Mid\-Type} (int i)
\begin{CompactList}\small\item\em Returns the type of the i-th device . \item\end{CompactList}\item 
void {\bf k\-Mid\-Set\-Device} (int i)
\begin{CompactList}\small\item\em Sets the MIDI device to use when playing a song. \item\end{CompactList}\item 
void {\bf k\-Mid\-Set\-Midi\-Mapper} (const  char $\ast$mapfilename)
\begin{CompactList}\small\item\em Sets the Midi Mapper to use. \item\end{CompactList}\item 
const  char $\ast$ {\bf k\-Mid\-Version} (void)
\begin{CompactList}\small\item\em Returns the version number of libkmid, i.e. \item\end{CompactList}\item 
const  char $\ast$ {\bf k\-Mid\-Copyright} (void)
\begin{CompactList}\small\item\em Returns the copyright notice that applications using libkmid should print to the user in an about box or somewhere visible. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Simple API covering most of the uses of libkmid. A very simple API around the rest of libkmid. 

You can use the members of this class in pure C applications, just by using the same name as the corresponding function member.

Suppose you're developing a game and you want to play some background music while the user is playing. You only have to call :

\begin{itemize}
\item {\bf k\-Mid\-Init}{\rm (p.\,\pageref{classKMidSimpleAPI_e0})}(); \item {\bf k\-Mid\-Load}{\rm (p.\,\pageref{classKMidSimpleAPI_e1})}(\char`\"{}Ride\-Of\-The\-Valkyries.mid\char`\"{}); \item {\bf k\-Mid\-Play}{\rm (p.\,\pageref{classKMidSimpleAPI_e2})}();\end{itemize}
When the user decides to quit the game, use

\begin{itemize}
\item {\bf k\-Mid\-Stop}{\rm (p.\,\pageref{classKMidSimpleAPI_e3})}(); \item {\bf k\-Mid\-Destruct}{\rm (p.\,\pageref{classKMidSimpleAPI_e4})}();\end{itemize}
to stop the music and release the memory allocated by libkmid.

\begin{Desc}
\item[Version:]0.9.5 17/01/2000 \end{Desc}
\begin{Desc}
\item[Author:]Antonio Larrosa Jimenez $<${\tt larrosa@kde.org}$>$ \end{Desc}




Definition at line 54 of file libkmid.h.

\subsection{Member Function Documentation}
\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidInit@{kMidInit}}
\index{kMidInit@{kMidInit}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Init (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e0}


Initializes libkmid. 

Creates the {\bf Device\-Manager}{\rm (p.\,\pageref{classDeviceManager})} object, and initializes some variables that will be used later.

\begin{Desc}
\item[Returns:]0 if OK, and a positive number when there's any error (for example, because the /dev/sequencer device couldn't be opened, be it because it was already opened by another application, or because the sound card wasn't configured) \end{Desc}


Definition at line 42 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidLoad@{kMidLoad}}
\index{kMidLoad@{kMidLoad}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Load (const char $\ast$ {\em filename})\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e1}


Loads a song that will be played with the next call to {\bf k\-Mid\-Play}{\rm (p.\,\pageref{classKMidSimpleAPI_e2})}(). 



Definition at line 78 of file libkmid.cc.

References k\-Mid\-Devices().\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidPlay@{kMidPlay}}
\index{kMidPlay@{kMidPlay}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Play (int {\em loop} = 0)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e2}


Plays the song currently loaded with {\bf k\-Mid\-Load}{\rm (p.\,\pageref{classKMidSimpleAPI_e1})}(). 

k\-Mid\-Play forks in order to play the song in a different process, it exits inmediately, so that the application can follow the normal execution flow while the sone is played.

If loop is 0 the song is played once and then the child process finishes. If loop is 1, the song is played repeatedly until {\bf k\-Mid\-Stop}{\rm (p.\,\pageref{classKMidSimpleAPI_e3})}() is called. You can call {\bf k\-Mid\-Stop}{\rm (p.\,\pageref{classKMidSimpleAPI_e3})}() anytime you want (also if loop is 0) to stop the song and kill the child process.

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Stop}{\rm (p.\,\pageref{classKMidSimpleAPI_e3})} 

{\bf k\-Mid\-Is\-Playing}{\rm (p.\,\pageref{classKMidSimpleAPI_e5})} \end{Desc}


Definition at line 84 of file libkmid.cc.

References k\-Mid\-Devices().\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidStop@{kMidStop}}
\index{kMidStop@{kMidStop}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Stop (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e3}


Stops playing a song inmediatly. 

It doesn't return until the child process that is playing the song is terminated.

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Play}{\rm (p.\,\pageref{classKMidSimpleAPI_e2})} \end{Desc}


Definition at line 123 of file libkmid.cc.

References k\-Mid\-Devices().\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidDestruct@{kMidDestruct}}
\index{kMidDestruct@{kMidDestruct}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KMid\-Simple\-API::k\-Mid\-Destruct (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e4}


Releases the memory allocated by libkmid. 

To continue playing, you must first make a(nother) call to {\bf k\-Mid\-Init}{\rm (p.\,\pageref{classKMidSimpleAPI_e0})}(). 

Definition at line 138 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidIsPlaying@{kMidIsPlaying}}
\index{kMidIsPlaying@{kMidIsPlaying}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Is\-Playing (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e5}


Returns 1 if the library is playing a song, and 0 if it's not. 

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Play}{\rm (p.\,\pageref{classKMidSimpleAPI_e2})} \end{Desc}


Definition at line 149 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidDevices@{kMidDevices}}
\index{kMidDevices@{kMidDevices}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KMid\-Simple\-API::k\-Mid\-Devices (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e6}


Returns the number of MIDI devices ( MIDI ports + synthesizers ). 

\begin{Desc}
\item[See also:]{\bf Device\-Manager::midi\-Ports}{\rm (p.\,\pageref{classDeviceManager_a35})} 

{\bf Device\-Manager::synth\-Devices}{\rm (p.\,\pageref{classDeviceManager_a36})} 

{\bf k\-Mid\-Name}{\rm (p.\,\pageref{classKMidSimpleAPI_e7})} 

{\bf k\-Mid\-Type}{\rm (p.\,\pageref{classKMidSimpleAPI_e8})} \end{Desc}


Definition at line 154 of file libkmid.cc.

Referenced by k\-Mid\-Load(), k\-Mid\-Play(), k\-Mid\-Set\-Midi\-Mapper(), and k\-Mid\-Stop().\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidName@{kMidName}}
\index{kMidName@{kMidName}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const  char $\ast$ KMid\-Simple\-API::k\-Mid\-Name (int {\em i})\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e7}


Returns the name of the i-th device . 

In case libkmid wasn't yet initialized ( see {\bf k\-Mid\-Init}{\rm (p.\,\pageref{classKMidSimpleAPI_e0})}() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see {\bf k\-Mid\-Devices}{\rm (p.\,\pageref{classKMidSimpleAPI_e6})}() ) it returns an empty string.

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Devices}{\rm (p.\,\pageref{classKMidSimpleAPI_e6})} 

{\bf k\-Mid\-Type}{\rm (p.\,\pageref{classKMidSimpleAPI_e8})} \end{Desc}


Definition at line 159 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidType@{kMidType}}
\index{kMidType@{kMidType}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const  char $\ast$ KMid\-Simple\-API::k\-Mid\-Type (int {\em i})\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e8}


Returns the type of the i-th device . 

In case libkmid wasn't yet initialized ( see {\bf k\-Mid\-Init}{\rm (p.\,\pageref{classKMidSimpleAPI_e0})}() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see {\bf k\-Mid\-Devices}{\rm (p.\,\pageref{classKMidSimpleAPI_e6})}() ) it returns an empty string.

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Devices}{\rm (p.\,\pageref{classKMidSimpleAPI_e6})} 

{\bf k\-Mid\-Name}{\rm (p.\,\pageref{classKMidSimpleAPI_e7})} \end{Desc}


Definition at line 164 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidSetDevice@{kMidSetDevice}}
\index{kMidSetDevice@{kMidSetDevice}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KMid\-Simple\-API::k\-Mid\-Set\-Device (int {\em i})\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e9}


Sets the MIDI device to use when playing a song. 

\begin{Desc}
\item[See also:]{\bf k\-Mid\-Devices}{\rm (p.\,\pageref{classKMidSimpleAPI_e6})} 

{\bf k\-Mid\-Name}{\rm (p.\,\pageref{classKMidSimpleAPI_e7})} 

{\bf Device\-Manager}{\rm (p.\,\pageref{classDeviceManager})} \end{Desc}


Definition at line 169 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidSetMidiMapper@{kMidSetMidiMapper}}
\index{kMidSetMidiMapper@{kMidSetMidiMapper}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KMid\-Simple\-API::k\-Mid\-Set\-Midi\-Mapper (const char $\ast$ {\em mapfilename})\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e10}


Sets the Midi Mapper to use. 

Most of the users won't need a midi mapper, but there're still non-General Midi synthesizers out there, and people with one of those will get much better sound quality by using a MIDI mapper.

Please have a look at KMid's documentation for more information about MIDI mappers and how to write a MIDI mapper for your keyboard. 

Definition at line 174 of file libkmid.cc.

References k\-Mid\-Devices().\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidVersion@{kMidVersion}}
\index{kMidVersion@{kMidVersion}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const  char $\ast$ KMid\-Simple\-API::k\-Mid\-Version (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e11}


Returns the version number of libkmid, i.e. 

\char`\"{}0.9.5\char`\"{} or \char`\"{}1.0 Beta\char`\"{} 

Definition at line 182 of file libkmid.cc.\index{KMidSimpleAPI@{KMid\-Simple\-API}!kMidCopyright@{kMidCopyright}}
\index{kMidCopyright@{kMidCopyright}!KMidSimpleAPI@{KMid\-Simple\-API}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const  char $\ast$ KMid\-Simple\-API::k\-Mid\-Copyright (void)\hspace{0.3cm}{\tt  [static]}}\label{classKMidSimpleAPI_e12}


Returns the copyright notice that applications using libkmid should print to the user in an about box or somewhere visible. 

I.e.

\char`\"{}Lib\-KMid 0.9.5 (C) 1997-2000 Antonio Larrosa Jimenez $<$larrosa@kde.org$>$. Spain\char`\"{} 

Definition at line 187 of file libkmid.cc.

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