player.h
00001 /* player.h - class MidiPlayer. Plays a set of tracks 00002 This file is part of LibKMid 0.9.5 00003 Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez 00004 LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 00021 Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org> 00022 00023 ***************************************************************************/ 00024 #ifndef _PLAYER_H 00025 #define _PLAYER_H 00026 00027 #include <libkmid/dattypes.h> 00028 #include <libkmid/midfile.h> 00029 #include <libkmid/deviceman.h> 00030 #include <libkmid/track.h> 00031 #include <libkmid/notearray.h> 00032 #include <kdemacros.h> 00033 00048 struct SpecialEvent 00049 { 00053 int id; 00054 00060 ulong diffmilliseconds; 00061 00068 ulong absmilliseconds; 00069 00073 int ticks; 00074 00089 int type; 00090 00094 char text[1024]; 00095 00099 ulong tempo; 00104 int num; 00109 int den; 00110 00121 struct SpecialEvent *next; 00122 00127 }; 00128 00129 00138 struct PlayerController 00139 { 00140 volatile ulong ticksTotal; 00141 volatile ulong ticksPlayed; 00142 volatile double millisecsPlayed; 00143 volatile ulong beginmillisec; 00144 00145 volatile int tempo; 00146 volatile int num; 00147 volatile int den; 00148 00149 volatile int SPEVprocessed; 00150 volatile int SPEVplayed; 00151 00157 volatile int OK; 00158 00162 volatile int playing; 00163 00167 volatile int paused; 00168 00172 volatile int moving; 00173 00177 volatile int finished; 00178 00184 volatile int message KDE_DEPRECATED; // set one of the following : 00185 00186 #define PLAYER_DOPAUSE 1 00187 #define PLAYER_DOSTOP 2 00188 #define PLAYER_SETPOS 4 00189 #define PLAYER_HALT 8 00190 00191 volatile ulong gotomsec; //milliseconds to go to,if player_setpos is set 00192 00196 volatile int error; 00197 00202 volatile int gm; 00203 00209 volatile int volumepercentage ; 00210 00215 volatile bool forcepgm[16]; 00216 00221 volatile int pgm[16]; 00222 00226 volatile double ratioTempo; 00227 00232 volatile bool isSendingAllNotesOff; 00233 00234 volatile MidiEvent *ev; 00235 }; 00236 00237 00260 class KMID_EXPORT MidiPlayer 00261 { 00262 class MidiPlayerPrivate; 00263 MidiPlayerPrivate *d; 00264 00265 DeviceManager *midi; 00266 MidiFileInfo *info; 00267 MidiTrack **tracks; 00268 SpecialEvent *spev; 00269 NoteArray *na; 00270 00271 int songLoaded; 00272 00273 PlayerController *ctl; 00274 00275 bool parsesong; 00276 bool generatebeats; 00277 00278 void removeSpecialEvents(void); 00279 void parseSpecialEvents(void); 00280 void insertBeat(SpecialEvent *ev,ulong ms,int num,int den); 00281 void generateBeats(void); 00282 00283 //NoteArray *parseNotes(void); 00284 void debugSpecialEvents(void); 00285 public: 00286 00292 MidiPlayer(DeviceManager *midi_,PlayerController *pctl); 00293 00297 ~MidiPlayer(); 00298 00305 int loadSong(const char *filename); 00306 00311 void removeSong(void); 00312 00317 int isSongLoaded(void) { return songLoaded; }; 00318 00323 SpecialEvent *specialEvents() { return spev; }; 00324 00333 NoteArray *noteArray(void) { return na; }; 00334 00335 00355 void play(bool calloutput=false,void output(void) = 0); 00356 00362 void setParseSong(bool b = true); 00363 00368 void setGenerateBeats(bool b = false); 00369 00375 MidiFileInfo *information(void) { return info; }; 00376 00386 void setPos(ulong gotomsec, class MidiStatus *midistat); 00387 00392 void setTempoRatio(double ratio); 00393 00394 }; 00395 00396 #endif