# libkmid Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KMidSimpleAPI Class Reference

Simple API covering most of the uses of libkmid. A very simple API around the rest of libkmid. More...

`#include <libkmid.h>`

List of all members.

## Static Public Member Functions

int | kMidInit (void)
| Initializes libkmid.
int | kMidLoad (const char *filename)
| Loads a song that will be played with the next call to kMidPlay().
int | kMidPlay (int loop=0)
| Plays the song currently loaded with kMidLoad().
int | kMidStop (void)
| Stops playing a song inmediatly.
void | kMidDestruct (void)
| Releases the memory allocated by libkmid.
int | kMidIsPlaying (void)
| Returns 1 if the library is playing a song, and 0 if it's not.
int | kMidDevices (void)
| Returns the number of MIDI devices ( MIDI ports + synthesizers ).
const char * | kMidName (int i)
| Returns the name of the i-th device .
const char * | kMidType (int i)
| Returns the type of the i-th device .
void | kMidSetDevice (int i)
| Sets the MIDI device to use when playing a song.
void | kMidSetMidiMapper (const char *mapfilename)
| Sets the Midi Mapper to use.
const char * | kMidVersion (void)
| Returns the version number of libkmid, i.e.
const char * | kMidCopyright (void)
| Returns the copyright notice that applications using libkmid should print to the user in an about box or somewhere visible.

## 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 :

- kMidInit();
- kMidLoad("RideOfTheValkyries.mid");
- kMidPlay();

When the user decides to quit the game, use

- kMidStop();
- kMidDestruct();

to stop the music and release the memory allocated by libkmid.

Version:
  0.9.5 17/01/2000

Author:
  Antonio Larrosa Jimenez <larrosa@kde.org>

Definition at line 54 of file libkmid.h.

## Member Function Documentation

int KMidSimpleAPI::kMidInit | ( | void |  | ) | `[static]`

Initializes libkmid.

Creates the DeviceManager object, and initializes some variables that will be used later.

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)

Definition at line 42 of file libkmid.cc.

int KMidSimpleAPI::kMidLoad | ( | const char * | filename | ) | `[static]`

| Loads a song that will be played with the next call to kMidPlay(). Definition at line 78 of file libkmid.cc. References kMidDevices().

int KMidSimpleAPI::kMidPlay | ( | int | loop = 0 | ) | `[static]`

Plays the song currently loaded with kMidLoad().

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.

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 kMidStop() is called. You can call kMidStop() anytime you want (also if loop is 0) to stop the song and kill the child process.

See also:
  kMidStop

  kMidIsPlaying

Definition at line 84 of file libkmid.cc.

References kMidDevices().

int KMidSimpleAPI::kMidStop | ( | void |  | ) | `[static]`

Stops playing a song inmediatly.

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

See also:
  kMidPlay

Definition at line 123 of file libkmid.cc.

References kMidDevices().

void KMidSimpleAPI::kMidDestruct | ( | void |  | ) | `[static]`

| Releases the memory allocated by libkmid. To continue playing, you must first make a(nother) call to kMidInit(). Definition at line 138 of file libkmid.cc.

int KMidSimpleAPI::kMidIsPlaying | ( | void |  | ) | `[static]`

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

See also:
  kMidPlay

Definition at line 149 of file libkmid.cc.

int KMidSimpleAPI::kMidDevices | ( | void |  | ) | `[static]`

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

See also:
  DeviceManager::midiPorts

  DeviceManager::synthDevices

  kMidName

  kMidType

Definition at line 154 of file libkmid.cc.

Referenced by kMidLoad(), kMidPlay(), kMidSetMidiMapper(), and kMidStop().

const char * KMidSimpleAPI::kMidName | ( | int | i | ) | `[static]`

Returns the name of the i-th device .

In case libkmid wasn't yet initialized ( see kMidInit() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see kMidDevices() ) it returns an empty string.

See also:
  kMidDevices

  kMidType

Definition at line 159 of file libkmid.cc.

const char * KMidSimpleAPI::kMidType | ( | int | i | ) | `[static]`

Returns the type of the i-th device .

In case libkmid wasn't yet initialized ( see kMidInit() ), the return value is NULL, and in case the parameter has a value out of the valid range ( see kMidDevices() ) it returns an empty string.

See also:
  kMidDevices

  kMidName

Definition at line 164 of file libkmid.cc.

void KMidSimpleAPI::kMidSetDevice | ( | int | i | ) | `[static]`

Sets the MIDI device to use when playing a song.

See also:
  kMidDevices

  kMidName

  DeviceManager

Definition at line 169 of file libkmid.cc.

void KMidSimpleAPI::kMidSetMidiMapper | ( | const char * | mapfilename | ) | `[static]`

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 kMidDevices().

const char * KMidSimpleAPI::kMidVersion | ( | void |  | ) | `[static]`

| Returns the version number of libkmid, i.e. "0.9.5" or "1.0 Beta" Definition at line 182 of file libkmid.cc.

const char * KMidSimpleAPI::kMidCopyright | ( | void |  | ) | `[static]`

| Returns the copyright notice that applications using libkmid should print to the user in an about box or somewhere visible. I.e. "LibKMid 0.9.5 (C) 1997-2000 Antonio Larrosa Jimenez <larrosa@kde.org>. Spain" Definition at line 187 of file libkmid.cc.

The documentation for this class was generated from the following files:

- libkmid.h
- libkmid.cc

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:28:39 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001