.TH "MidiPlayer" 3 "28 Jan 2004" "libkmid Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
MidiPlayer \- MIDI file player routines . The MIDI file player engine.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <player.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBMidiPlayer\fP (\fBDeviceManager\fP *midi_, \fBPlayerController\fP *pctl)"
.br
.RI "\fIConstructor . \fP"
.ti -1c
.RI "\fB~MidiPlayer\fP ()"
.br
.RI "\fIDestructor. \fP"
.ti -1c
.RI "int \fBloadSong\fP (const  char *filename)"
.br
.RI "\fILoads a Song, and parses it (it the parse wasn't disabled with \fBsetParseSong\fP() ) . \fP"
.ti -1c
.RI "void \fBremoveSong\fP (void)"
.br
.RI "\fIUnloads the current song, so that every internal variable is empty and clean for further usage. \fP"
.ti -1c
.RI "int \fBisSongLoaded\fP (void)"
.br
.RI "\fIReturns true if there's a song already loaded (with a previous call to \fBloadSong\fP() ) and false if not. \fP"
.ti -1c
.RI "\fBSpecialEvent\fP * \fBspecialEvents\fP ()"
.br
.RI "\fIReturns the linked list of \fBSpecialEvents\fP objects . \fP"
.ti -1c
.RI "\fBNoteArray\fP * \fBnoteArray\fP (void)"
.br
.RI "\fIReturns and array with the notes playen through the song . \fP"
.ti -1c
.RI "void \fBplay\fP (bool calloutput=false, void output(void)=0)"
.br
.RI "\fIPlays the song using the \fBDeviceManager\fP object supplied in the constructor. \fP"
.ti -1c
.RI "void \fBsetParseSong\fP (bool b=true)"
.br
.RI "\fIEnables or disables the parsing of the song when loading it. \fP"
.ti -1c
.RI "void \fBsetGenerateBeats\fP (bool b=false)"
.br
.RI "\fIEnables or disables the generation of beats event in a song when loading it. \fP"
.ti -1c
.RI "\fBMidiFileInfo\fP * \fBinformation\fP (void)"
.br
.RI "\fIReturns information about the current MIDI file. \fP"
.ti -1c
.RI "void \fBsetPos\fP (\fBulong\fP gotomsec, class \fBMidiStatus\fP *midistat)"
.br
.RI "\fISets the position in a song. \fP"
.ti -1c
.RI "void \fBsetTempoRatio\fP (double ratio)"
.br
.RI "\fIChanges the speed at which a song is played. \fP"
.in -1c
.SH "Detailed Description"
.PP 
MIDI file player routines . The MIDI file player engine. 

This class reads a MIDI file and play it using a \fBDeviceManager\fP object.
.PP
To use it, just call \fBloadSong\fP() with the filename you want to play, and then \fBplay\fP().
.PP
Please have a look at the note in the \fBplay\fP() documentation.
.PP
MidiPlayer will write information about the playing process on a \fBPlayerController\fP() structure that you must supply to the constructor
.PP
Alternatively, if everything you want is to play a midi file in a game or any other application that doesn't need to fine tune the midi playing, just use the \fBkmidplay\fP() function.
.PP
\fBSee also:\fP
.RS 4
\fBKMidSimpleAPI\fP
.RE
.PP
.PP
\fBVersion:\fP
.RS 4
0.9.5 17/01/2000 
.RE
.PP
\fBAuthor:\fP
.RS 4
Antonio Larrosa Jimenez <larrosa@kde.org> 
.RE
.PP

.PP
Definition at line 259 of file player.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "MidiPlayer::MidiPlayer (\fBDeviceManager\fP * midi_, \fBPlayerController\fP * pctl)"
.PP
Constructor . You must construct and pass a \fBDeviceManager\fP object and a \fBPlayerController\fP structure. None of them will be destroyed by this object, so you should do it after destroying the MidiPlayer object. Definition at line 46 of file player.cc.
.SS "MidiPlayer::~\fBMidiPlayer\fP ()"
.PP
Destructor. Definition at line 59 of file player.cc.
.PP
References removeSong().
.SH "Member Function Documentation"
.PP 
.SS "int MidiPlayer::loadSong (const char * filename)"
.PP
Loads a Song, and parses it (it the parse wasn't disabled with \fBsetParseSong\fP() ) . It also generates the Beat events (see \fBSpecialEvent::type\fP() ) if you enabled this by using \fBsetGenerateBeats\fP() . Definition at line 89 of file player.cc.
.PP
References PlayerController::ratioTempo, and removeSong().
.SS "void MidiPlayer::removeSong (void)"
.PP
Unloads the current song, so that every internal variable is empty and clean for further usage. Definition at line 65 of file player.cc.
.PP
References MidiFileInfo::ntracks.
.PP
Referenced by loadSong(), and ~MidiPlayer().
.SS "int MidiPlayer::isSongLoaded (void)\fC [inline]\fP"
.PP
Returns true if there's a song already loaded (with a previous call to \fBloadSong\fP() ) and false if not. Definition at line 316 of file player.h.
.SS "\fBSpecialEvent\fP* MidiPlayer::specialEvents ()\fC [inline]\fP"
.PP
Returns the linked list of \fBSpecialEvents\fP objects . For this to work, the parse should be enabled (the default), by using \fBsetParseSong\fP(). Definition at line 322 of file player.h.
.SS "\fBNoteArray\fP* MidiPlayer::noteArray (void)\fC [inline]\fP"
.PP
Returns and array with the notes playen through the song . MidiPlayer must parse the song to get the notes, so be sure not to disable the parsing of the song.
.PP
Returns an array of notes, (just note on and note off events), in the form of a \fBNoteArray\fP object Definition at line 332 of file player.h.
.SS "void MidiPlayer::play (bool calloutput = false, void  output(void) = 0)"
.PP
Plays the song using the \fBDeviceManager\fP object supplied in the constructor. It should be already configured, as play doesn't change the volume, nor midi mapper, for example.
.PP
Note: Calling this function will block the execution of your application until the song finishes playing. The solution for this is simple, fork before calling it, and create the \fBPlayerController\fP object on shared memory.
.PP
As alternative, if everything you want is playing a midi file in a game or any other application that doesn't need to fine tune the midi playing, just use the \fBKMidSimpleAPI::kMidPlay\fP() function.
.PP
\fBSee also:\fP
.RS 4
\fBKMidSimpleAPI::kMidInit\fP 
.PP
\fBKMidSimpleAPI::kMidPlay\fP 
.PP
\fBKMidSimpleAPI::kMidStop\fP 
.PP
\fBKMidSimpleAPI::kMidDestruct\fP 
.RE
.PP
Definition at line 531 of file player.cc.
.PP
References MidiTrack::absMsOfNextEvent(), DeviceManager::allNotesOff(), PlayerController::beginmillisec, MidiTrack::changeTempo(), MidiEvent::chn, DeviceManager::chnController(), DeviceManager::chnPatchChange(), DeviceManager::chnPitchBender(), DeviceManager::chnPressure(), DeviceManager::closeDev(), MidiEvent::command, MidiEvent::ctl, MidiTrack::currentMs(), MidiEvent::d1, MidiEvent::d2, MidiEvent::d3, MidiEvent::data, PlayerController::den, PlayerController::error, PlayerController::ev, PlayerController::finished, PlayerController::forcepgm, PlayerController::gm, PlayerController::gotomsec, MidiTrack::init(), DeviceManager::initDev(), DeviceManager::keyPressure(), PlayerController::message, DeviceManager::midiPorts(), PlayerController::moving, MidiEvent::note, DeviceManager::noteOff(), DeviceManager::noteOn(), MidiFileInfo::ntracks, PlayerController::num, PlayerController::OK, DeviceManager::ok(), DeviceManager::openDev(), MidiEvent::patch, MidiFileInfo::patchesUsed, PlayerController::paused, PlayerController::pgm, PlayerController::playing, PlayerController::ratioTempo, MidiTrack::readEvent(), MidiStatus::sendData(), DeviceManager::setPatchesToUse(), setPos(), DeviceManager::setVolumePercentage(), PlayerController::SPEVplayed, DeviceManager::sync(), DeviceManager::synthDevices(), PlayerController::tempo, MidiFileInfo::ticksPerCuarterNote, PlayerController::ticksPlayed, MidiFileInfo::ticksTotal, PlayerController::ticksTotal, DeviceManager::tmrSetTempo(), DeviceManager::tmrStart(), DeviceManager::tmrStop(), MidiEvent::vel, PlayerController::volumepercentage, and DeviceManager::wait().
.SS "void MidiPlayer::setParseSong (bool b = true)"
.PP
Enables or disables the parsing of the song when loading it. This affects the SpecialEvents (\fBspecialEvents\fP() ) and the \fBNoteArray\fP (\fBnoteArray\fP() ). Definition at line 927 of file player.cc.
.SS "void MidiPlayer::setGenerateBeats (bool b = false)"
.PP
Enables or disables the generation of beats event in a song when loading it. Definition at line 932 of file player.cc.
.SS "\fBMidiFileInfo\fP* MidiPlayer::information (void)\fC [inline]\fP"
.PP
Returns information about the current MIDI file. \fBSee also:\fP
.RS 4
\fBloadSong\fP 
.RE
.PP
Definition at line 374 of file player.h.
.SS "void MidiPlayer::setPos (\fBulong\fP gotomsec, class \fBMidiStatus\fP * midistat)"
.PP
Sets the position in a song. \fBParameters:\fP
.RS 4
\fIgotomsec\fP the number of milliseconds to go to . A subsequent call to \fBplay\fP() will start playing the song from that moment, instead of the beginning. 
.br
\fImidistat\fP a \fBMidiStatus\fP object that will contain the status in which the MIDI device would be if it would have arrived to this situation by a normal playing of the song. 
.RE
.PP
Definition at line 795 of file player.cc.
.PP
References MidiTrack::absMsOfNextEvent(), MidiTrack::changeTempo(), MidiEvent::chn, MidiStatus::chnController(), MidiStatus::chnPatchChange(), MidiStatus::chnPitchBender(), MidiStatus::chnPressure(), MidiEvent::command, MidiEvent::ctl, MidiTrack::currentMs(), MidiEvent::d1, MidiEvent::d2, MidiEvent::d3, MidiEvent::data, PlayerController::den, PlayerController::forcepgm, MidiTrack::init(), MidiFileInfo::ntracks, PlayerController::num, MidiEvent::patch, PlayerController::pgm, PlayerController::ratioTempo, MidiTrack::readEvent(), PlayerController::SPEVplayed, PlayerController::tempo, MidiStatus::tmrSetTempo(), and MidiEvent::vel.
.PP
Referenced by play().
.SS "void MidiPlayer::setTempoRatio (double ratio)"
.PP
Changes the speed at which a song is played. The song's tempo is multiplied by the specified ratio. Definition at line 937 of file player.cc.
.PP
References PlayerController::ratioTempo, and PlayerController::tempo.

.SH "Author"
.PP 
Generated automatically by Doxygen for libkmid Library from the source code.
