• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdemid
 

libtdemid

  • libtdemid
player.h
1 /* player.h - class MidiPlayer. Plays a set of tracks
2  This file is part of LibKMid 0.9.5
3  Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez
4  LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libtdemid.html
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 
21  Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
22 
23 ***************************************************************************/
24 #ifndef _PLAYER_H
25 #define _PLAYER_H
26 
27 #include <libtdemid/dattypes.h>
28 #include <libtdemid/midfile.h>
29 #include <libtdemid/deviceman.h>
30 #include <libtdemid/track.h>
31 #include <libtdemid/notearray.h>
32 #include <tdemacros.h>
33 
48 struct SpecialEvent
49 {
53  int id;
54 
60  ulong diffmilliseconds;
61 
68  ulong absmilliseconds;
69 
73  int ticks;
74 
89  int type;
90 
94  char text[1024];
95 
99  ulong tempo;
104  int num;
109  int den;
110 
121  struct SpecialEvent *next;
122 
127 };
128 
129 
138 struct PlayerController
139 {
140  volatile ulong ticksTotal;
141  volatile ulong ticksPlayed;
142  volatile double millisecsPlayed;
143  volatile ulong beginmillisec;
144 
145  volatile int tempo;
146  volatile int num;
147  volatile int den;
148 
149  volatile int SPEVprocessed;
150  volatile int SPEVplayed;
151 
157  volatile int OK;
158 
162  volatile int playing;
163 
167  volatile int paused;
168 
172  volatile int moving;
173 
177  volatile int finished;
178 
184  volatile int message TDE_DEPRECATED; // set one of the following :
185 
186 #define PLAYER_DOPAUSE 1
187 #define PLAYER_DOSTOP 2
188 #define PLAYER_SETPOS 4
189 #define PLAYER_HALT 8
190 
191  volatile ulong gotomsec; //milliseconds to go to,if player_setpos is set
192 
196  volatile int error;
197 
202  volatile int gm;
203 
209  volatile int volumepercentage ;
210 
215  volatile bool forcepgm[16];
216 
221  volatile int pgm[16];
222 
226  volatile double ratioTempo;
227 
232  volatile bool isSendingAllNotesOff;
233 
234  volatile MidiEvent *ev;
235 };
236 
237 
260 class KMID_EXPORT MidiPlayer
261 {
262  class MidiPlayerPrivate;
263  MidiPlayerPrivate *d;
264 
265  DeviceManager *midi;
266  MidiFileInfo *info;
267  MidiTrack **tracks;
268  SpecialEvent *spev;
269  NoteArray *na;
270 
271  int songLoaded;
272 
273  PlayerController *ctl;
274 
275  bool parsesong;
276  bool generatebeats;
277 
278  void removeSpecialEvents(void);
279  void parseSpecialEvents(void);
280  void insertBeat(SpecialEvent *ev,ulong ms,int num,int den);
281  void generateBeats(void);
282 
283  //NoteArray *parseNotes(void);
284  void debugSpecialEvents(void);
285  public:
286 
292  MidiPlayer(DeviceManager *midi_,PlayerController *pctl);
293 
297  ~MidiPlayer();
298 
305  int loadSong(const char *filename);
306 
311  void removeSong(void);
312 
317  int isSongLoaded(void) { return songLoaded; }
318 
323  SpecialEvent *specialEvents() { return spev; }
324 
333  NoteArray *noteArray(void) { return na; }
334 
335 
355  void play(bool calloutput=false,void output(void) = 0);
356 
362  void setParseSong(bool b = true);
363 
368  void setGenerateBeats(bool b = false);
369 
375  MidiFileInfo *information(void) { return info; }
376 
386  void setPos(ulong gotomsec, class MidiStatus *midistat);
387 
392  void setTempoRatio(double ratio);
393 
394 };
395 
396 #endif
DeviceManager
MIDI Device Manager class .
Definition: deviceman.h:48
MidiPlayer
MIDI file player routines .
Definition: player.h:261
MidiPlayer::information
MidiFileInfo * information(void)
Returns information about the current MIDI file.
Definition: player.h:375
MidiPlayer::specialEvents
SpecialEvent * specialEvents()
Returns the linked list of SpecialEvents objects .
Definition: player.h:323
MidiPlayer::noteArray
NoteArray * noteArray(void)
Returns and array with the notes playen through the song .
Definition: player.h:333
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
MidiStatus
Stores the status of a MIDI device .
Definition: midistat.h:41
MidiTrack
Stores a MIDI track.
Definition: track.h:127
NoteArray
Holds a resizeable array of note on/off and patch change events.
Definition: notearray.h:39
MidiEvent
An structure that represents a MIDI event.
Definition: track.h:38
MidiFileInfo
Contains all the information about a MIDI file.
Definition: midfile.h:40
PlayerController
PlayerController is a struct that is used by the MidiPlayer object to tell other parts of the applica...
Definition: player.h:139
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
PlayerController::ratioTempo
volatile double ratioTempo
Ratio to multiply the tempo to.
Definition: player.h:226
PlayerController::paused
volatile int paused
When the player is paused, paused is set to 1.
Definition: player.h:167
PlayerController::playing
volatile int playing
When the player is playing (or paused), playing is set to 1.
Definition: player.h:162
PlayerController::pgm
volatile int pgm[16]
Force a given patch in each channel at "this" moment, as determined by forcepgm.
Definition: player.h:221
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::moving
volatile int moving
When the player seeking the position of the song, moving is set to 1.
Definition: player.h:172
PlayerController::volumepercentage
volatile int volumepercentage
100 means no change, 50 halfs the volume, 200 doubles it (if possible), etc.
Definition: player.h:209
PlayerController::error
volatile int error
When error is 1, an error has ocurred (i.e.
Definition: player.h:196
PlayerController::finished
volatile int finished
When the player has finished playing a song, finished is set to 1.
Definition: player.h:177
PlayerController::forcepgm
volatile bool forcepgm[16]
Activate or disactivate the force to use a patch for a given channel.
Definition: player.h:215
SpecialEvent
This struct stores text, lyrics and change tempo events among others.
Definition: player.h:49
SpecialEvent::ticks
int ticks
MIDI ticks (from the beginning of the song) at which this event is played.
Definition: player.h:73
SpecialEvent::tempo
ulong tempo
Tempo field .
Definition: player.h:99
SpecialEvent::text
char text[1024]
Text field .
Definition: player.h:94
SpecialEvent::num
int num
Numerator .
Definition: player.h:104
SpecialEvent::next
struct SpecialEvent * next
This struct stores text, lyrics and change tempo events among others.
Definition: player.h:121
SpecialEvent::den
int den
Denominator .
Definition: player.h:109
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::diffmilliseconds
ulong diffmilliseconds
Delta milliseconds from the previous SpecialEvent.
Definition: player.h:60
SpecialEvent::type
int type
Type of event.
Definition: player.h:89
SpecialEvent::id
int id
An integer ID, that is assigned in order to each SpecialEvent.
Definition: player.h:53

libtdemid

Skip menu "libtdemid"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdemid

Skip menu "libtdemid"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for libtdemid by doxygen 1.9.1
This website is maintained by Timothy Pearson.