player.h
/* player.h - class MidiPlayer. Plays a set of tracks
This file is part of LibKMid 0.9.5
Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez
LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
***************************************************************************/
#ifndef _PLAYER_H
#define _PLAYER_H
#include <libkmid/dattypes.h>
#include <libkmid/midfile.h>
#include <libkmid/deviceman.h>
#include <libkmid/track.h>
#include <libkmid/notearray.h>
#include <kdemacros.h>
struct SpecialEvent
{
int id;
ulong diffmilliseconds;
ulong absmilliseconds;
int ticks;
int type;
char text[1024];
ulong tempo;
int num;
int den;
struct SpecialEvent *next;
};
struct PlayerController
{
volatile ulong ticksTotal;
volatile ulong ticksPlayed;
volatile double millisecsPlayed;
volatile ulong beginmillisec;
volatile int tempo;
volatile int num;
volatile int den;
volatile int SPEVprocessed;
volatile int SPEVplayed;
volatile int OK;
volatile int playing;
volatile int paused;
volatile int moving;
volatile int finished;
volatile int message KDE_DEPRECATED; // set one of the following :
#define PLAYER_DOPAUSE 1
#define PLAYER_DOSTOP 2
#define PLAYER_SETPOS 4
#define PLAYER_HALT 8
volatile ulong gotomsec; //milliseconds to go to,if player_setpos is set
volatile int error;
volatile int gm;
volatile int volumepercentage ;
volatile bool forcepgm[16];
volatile int pgm[16];
volatile double ratioTempo;
volatile bool isSendingAllNotesOff;
volatile MidiEvent *ev;
};
class KMID_EXPORT MidiPlayer
{
class MidiPlayerPrivate;
MidiPlayerPrivate *d;
DeviceManager *midi;
MidiFileInfo *info;
MidiTrack **tracks;
SpecialEvent *spev;
NoteArray *na;
int songLoaded;
PlayerController *ctl;
bool parsesong;
bool generatebeats;
void removeSpecialEvents(void);
void parseSpecialEvents(void);
void insertBeat(SpecialEvent *ev,ulong ms,int num,int den);
void generateBeats(void);
//NoteArray *parseNotes(void);
void debugSpecialEvents(void);
public:
MidiPlayer(DeviceManager *midi_,PlayerController *pctl);
~MidiPlayer();
int loadSong(const char *filename);
void removeSong(void);
int isSongLoaded(void) { return songLoaded; }
SpecialEvent *specialEvents() { return spev; }
NoteArray *noteArray(void) { return na; }
void play(bool calloutput=false,void output(void) = 0);
void setParseSong(bool b = true);
void setGenerateBeats(bool b = false);
MidiFileInfo *information(void) { return info; }
void setPos(ulong gotomsec, class MidiStatus *midistat);
void setTempoRatio(double ratio);
};
#endif
PlayerController::gm
volatile int gm
If gm is 1, the song follows the General Midi standard, if gm is 0, the song is in MT 32 format...
Definition: player.h:202
PlayerController::ratioTempo
volatile double ratioTempo
Ratio to multiply the tempo to.
Definition: player.h:226
SpecialEvent::id
int id
An integer ID, that is assigned in order to each SpecialEvent.
Definition: player.h:53
SpecialEvent::type
int type
Type of event.
Definition: player.h:89
MidiStatus
Stores the status of a MIDI device .
Definition: midistat.h:40
SpecialEvent::absmilliseconds
ulong absmilliseconds
The absolute millisecond (from the beginning of the song) at which this SpecialEvent object is played...
Definition: player.h:68
SpecialEvent::den
int den
Denominator .
Definition: player.h:109
MidiEvent
An structure that represents a MIDI event.
Definition: track.h:37
PlayerController::paused
volatile int paused
When the player is paused, paused is set to 1.
Definition: player.h:167
SpecialEvent::diffmilliseconds
ulong diffmilliseconds
Delta milliseconds from the previous SpecialEvent.
Definition: player.h:60
MidiPlayer::isSongLoaded
int isSongLoaded(void)
Returns true if there's a song already loaded (with a previous call to loadSong() ) and false if not...
Definition: player.h:317
MidiFileInfo
Contains all the information about a MIDI file.
Definition: midfile.h:39
PlayerController::playing
volatile int playing
When the player is playing (or paused), playing is set to 1.
Definition: player.h:162
PlayerController::moving
volatile int moving
When the player seeking the position of the song, moving is set to 1.
Definition: player.h:172
MidiPlayer
MIDI file player routines .
Definition: player.h:260
PlayerController
PlayerController is a struct that is used by the MidiPlayer object to tell other parts of the applica...
Definition: player.h:138
PlayerController::forcepgm
volatile bool forcepgm[16]
Activate or disactivate the force to use a patch for a given channel.
Definition: player.h:215
PlayerController::volumepercentage
volatile int volumepercentage
100 means no change, 50 halfs the volume, 200 doubles it (if possible), etc.
Definition: player.h:209
MidiPlayer::noteArray
NoteArray * noteArray(void)
Returns and array with the notes playen through the song .
Definition: player.h:333
PlayerController::finished
volatile int finished
When the player has finished playing a song, finished is set to 1.
Definition: player.h:177
NoteArray
Holds a resizeable array of note on/off and patch change events.
Definition: notearray.h:38
SpecialEvent::num
int num
Numerator .
Definition: player.h:104
SpecialEvent::tempo
ulong tempo
Tempo field .
Definition: player.h:99
MidiPlayer::information
MidiFileInfo * information(void)
Returns information about the current MIDI file.
Definition: player.h:375
SpecialEvent::text
char text[1024]
Text field .
Definition: player.h:94
PlayerController::OK
volatile int OK
When pause is released, if the caller must know when the player has opened the devices and is playing...
Definition: player.h:157
SpecialEvent
This struct stores text, lyrics and change tempo events among others.
Definition: player.h:48
SpecialEvent::next
struct SpecialEvent * next
This struct stores text, lyrics and change tempo events among others.
Definition: player.h:121
MidiTrack
Stores a MIDI track.
Definition: track.h:126
PlayerController::error
volatile int error
When error is 1, an error has ocurred (i.e.
Definition: player.h:196
DeviceManager
MIDI Device Manager class .
Definition: deviceman.h:47
SpecialEvent::ticks
int ticks
MIDI ticks (from the beginning of the song) at which this event is played.
Definition: player.h:73
MidiPlayer::specialEvents
SpecialEvent * specialEvents()
Returns the linked list of SpecialEvents objects .
Definition: player.h:323
PlayerController::pgm
volatile int pgm[16]
Force a given patch in each channel at "this" moment, as determined by forcepgm.
Definition: player.h:221

KDE Home | KDE Accessibility Home | Description of Access Keys