<HTML> <HEAD> <TITLE>class KMidSimpleAPI</TITLE> <META NAME="Generator" CONTENT="KDOC "> </HEAD> <BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff"> <TABLE WIDTH="100%" BORDER="0"> <TR> <TD> <TABLE BORDER="0"> <TR><TD valign="top" align="left" cellspacing="10"> <h1>class KMidSimpleAPI</h1> </TD> <TD valign="top" align="right" colspan="1">A very simple API around the rest of libkmid. <small><A HREF="#longdesc">More...</A></small></TD></TR> </TABLE> <HR> <TABLE BORDER="0"> <TR><TH>Definition</TH><TD><code>#include <<A HREF="libkmid_h.html">libkmid.h</A>></code></TD></TR> <TR><TH><A HREF="full-list-KMidSimpleAPI.html">List of all Methods</A></TH></TR> </TABLE> </TD> <TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR> <TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR> <TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR> <TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR> <TR><TD><small><A HREF="index.html">Index</A></small></TD></TR> </TABLE></TD></TR></TABLE> <h4>Public Static Methods</h4><ul><LI>static int <b><A HREF="#ref3">kMidInit</A></b> (void) </LI> <LI>static int <b><A HREF="#ref4">kMidLoad</A></b> (const char *filename) </LI> <LI>static int <b><A HREF="#ref5">kMidPlay</A></b> (int loop=0) </LI> <LI>static int <b><A HREF="#ref6">kMidStop</A></b> (void) </LI> <LI>static void <b><A HREF="#ref7">kMidDestruct</A></b> (void) </LI> <LI>static int <b><A HREF="#ref8">kMidIsPlaying</A></b> (void) </LI> <LI>static int <b><A HREF="#ref9">kMidDevices</A></b> (void) </LI> <LI>static const char * <b><A HREF="#ref10">kMidName</A></b> (int i) </LI> <LI>static const char * <b><A HREF="#ref11">kMidType</A></b> (int i) </LI> <LI>static void <b><A HREF="#ref12">kMidSetDevice</A></b> (int i) </LI> <LI>static void <b><A HREF="#ref13">kMidSetMidiMapper</A></b> (const char *mapfilename) </LI> <LI>static const char * <b><A HREF="#ref14">kMidVersion</A></b> (void) </LI> <LI>static const char * <b><A HREF="#ref15">kMidCopyright</A></b> (void) </LI> </ul><HR><H2><A NAME="longdesc">Detailed Description</A></H2><p> Simple API covering most of the uses of libkmid. </p> <p> You can use the members of this class in pure C applications, just by using the same name as the corresponding function member. </p> <p> Suppose you're developing a game and you want to play some background music while the user is playing. You only have to call : </p> <p></p> <ul> <li><A HREF="KMidSimpleAPI.html#kMidInit">kMidInit</A>(); </li> <li><A HREF="KMidSimpleAPI.html#kMidLoad">kMidLoad</A>("RideOfTheValkyries.mid"); </li> <li><A HREF="KMidSimpleAPI.html#kMidPlay">kMidPlay</A>(); </li> </ul> <p> </p> <p> When the user decides to quit the game, use </p> <p></p> <ul> <li><A HREF="KMidSimpleAPI.html#kMidStop">kMidStop</A>(); </li> <li><A HREF="KMidSimpleAPI.html#kMidDestruct">kMidDestruct</A>(); </li> </ul> <p> </p> <p> to stop the music and release the memory allocated by libkmid. </p> <p></p> <A NAME="kMidInit"></A><A NAME="ref3"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidInit</strong> (void) <br></td><td align="right"><h3><strong>kMidInit</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Initializes libkmid. Creates the DeviceManager object, and initializes some variables that will be used later. </p> <p></p> <p><b>Returns</b>: 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) </p> <A NAME="kMidLoad"></A><A NAME="ref4"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidLoad</strong> (const char *filename) <br></td><td align="right"><h3><strong>kMidLoad</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Loads a song that will be played with the next call to <A HREF="KMidSimpleAPI.html#kMidPlay">kMidPlay</A>(). </p> <A NAME="kMidPlay"></A><A NAME="ref5"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidPlay</strong> (int loop=0) <br></td><td align="right"><h3><strong>kMidPlay</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Plays the song currently loaded with <A HREF="KMidSimpleAPI.html#kMidLoad">kMidLoad</A>(). kMidPlay 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. </p> <p> 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 <A HREF="KMidSimpleAPI.html#kMidStop">kMidStop</A>() is called. You can call <A HREF="KMidSimpleAPI.html#kMidStop">kMidStop</A>() anytime you want (also if loop is 0) to stop the song and kill the child process. </p> <p></p> <p><b>See also</b>: <A HREF="#kMidStop">kMidStop</A>, <A HREF="#kMidIsPlaying">kMidIsPlaying</A></p> <A NAME="kMidStop"></A><A NAME="ref6"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidStop</strong> (void) <br></td><td align="right"><h3><strong>kMidStop</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Stops playing a song inmediatly. It doesn't return until the child process that is playing the song is terminated. </p> <p></p> <p><b>See also</b>: <A HREF="KMidSimpleAPI.html#kMidPlay">kMidPlay</A></p> <A NAME="kMidDestruct"></A><A NAME="ref7"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void <strong>kMidDestruct</strong> (void) <br></td><td align="right"><h3><strong>kMidDestruct</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Releases the memory allocated by libkmid. To continue playing, you must first make a(nother) call to <A HREF="KMidSimpleAPI.html#kMidInit">kMidInit</A>(). </p> <A NAME="kMidIsPlaying"></A><A NAME="ref8"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidIsPlaying</strong> (void) <br></td><td align="right"><h3><strong>kMidIsPlaying</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns 1 if the library is playing a song, and 0 if it's not. </p> <p><b>See also</b>: <A HREF="KMidSimpleAPI.html#kMidPlay">kMidPlay</A></p> <A NAME="kMidDevices"></A><A NAME="ref9"></A><table width="100%"><tr bgcolor="#eeeeee"><td> int <strong>kMidDevices</strong> (void) <br></td><td align="right"><h3><strong>kMidDevices</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns the number of MIDI devices ( MIDI ports + synthesizers ) </p> <p><b>See also</b>: <A HREF="DeviceManager.html#midiPorts">midiPorts</A>, <A HREF="DeviceManager.html#synthDevices">synthDevices</A>, <A HREF="KMidSimpleAPI.html#kMidName">kMidName</A>, <A HREF="KMidSimpleAPI.html#kMidType">kMidType</A></p> <A NAME="kMidName"></A><A NAME="ref10"></A><table width="100%"><tr bgcolor="#eeeeee"><td> const char * <strong>kMidName</strong> (int i) <br></td><td align="right"><h3><strong>kMidName</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns the name of the i-th device . In case libkmid wasn't yet initialized ( see <A HREF="KMidSimpleAPI.html#kMidInit">kMidInit</A>() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see <A HREF="KMidSimpleAPI.html#kMidDevices">kMidDevices</A>() ) it returns an empty string. </p> <p></p> <p><b>See also</b>: <A HREF="KMidSimpleAPI.html#kMidDevices">kMidDevices</A>, <A HREF="KMidSimpleAPI.html#kMidType">kMidType</A></p> <A NAME="kMidType"></A><A NAME="ref11"></A><table width="100%"><tr bgcolor="#eeeeee"><td> const char * <strong>kMidType</strong> (int i) <br></td><td align="right"><h3><strong>kMidType</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns the type of the i-th device . In case libkmid wasn't yet initialized ( see <A HREF="KMidSimpleAPI.html#kMidInit">kMidInit</A>() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see <A HREF="KMidSimpleAPI.html#kMidDevices">kMidDevices</A>() ) it returns an empty string. </p> <p></p> <p><b>See also</b>: <A HREF="#kMidDevices">kMidDevices</A>, <A HREF="#kMidName">kMidName</A></p> <A NAME="kMidSetDevice"></A><A NAME="ref12"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void <strong>kMidSetDevice</strong> (int i) <br></td><td align="right"><h3><strong>kMidSetDevice</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Sets the MIDI device to use when playing a song. </p> <p><b>See also</b>: <A HREF="#kMidDevices">kMidDevices</A>, <A HREF="#kMidName">kMidName</A>, <A HREF="DeviceManager.html">DeviceManager</A></p> <A NAME="kMidSetMidiMapper"></A><A NAME="ref13"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void <strong>kMidSetMidiMapper</strong> (const char *mapfilename) <br></td><td align="right"><h3><strong>kMidSetMidiMapper</strong></h3></td></tr></table><p> <small>[static]</small></p><p> 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. </p> <p> Please have a look at KMid's documentation for more information about MIDI mappers and how to write a MIDI mapper for your keyboard. </p> <A NAME="kMidVersion"></A><A NAME="ref14"></A><table width="100%"><tr bgcolor="#eeeeee"><td> const char * <strong>kMidVersion</strong> (void) <br></td><td align="right"><h3><strong>kMidVersion</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns the version number of libkmid, i.e. "0.9.5" or "1.0 Beta" </p> <A NAME="kMidCopyright"></A><A NAME="ref15"></A><table width="100%"><tr bgcolor="#eeeeee"><td> const char * <strong>kMidCopyright</strong> (void) <br></td><td align="right"><h3><strong>kMidCopyright</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Returns the copyright notice that applications using libkmid should print to the user in an about box or somewhere visible. I.e. </p> <p> "LibKMid 0.9.5 (C) 1997-2000 Antonio Larrosa Jimenez <larrosa@kde.org>. Spain" </p> <HR><UL><LI><i>Version</i>: 0.9.5 17/01/2000 </LI><LI><i>Author</i>: Antonio Larrosa Jimenez <larrosa@kde.org> </LI><LI><i>Generated</i>: qateam on updates.mandrakesoft.com on Mon Dec 30 16:09:46 2002, using kdoc 2.0a53.</LI></UL></BODY></HTML>