1
/* player.h - class MidiPlayer. Plays a set of tracks
2
Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
Send comments and bug fixes to antlarr@arrakis.es
19
or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
21
***************************************************************************/
27
#include "deviceman.h"
29
#include "notearray.h"
32
* This struct identifies text, lyrics and change tempo events
39
ulong diffmilliseconds; //delta milliseconds from previous sp ev
40
ulong absmilliseconds; // milliseconds from beginning of song
41
int ticks; // ticks from begining of song
43
// 0 Nothing, end of linked list
47
// 6 Change number of beats per measure
53
struct SpecialEvent *next;
57
struct PlayerController
59
volatile ulong ticksTotal;
60
volatile ulong ticksPlayed;
61
volatile double millisecsPlayed;
62
volatile ulong beginmillisec;
68
volatile int SPEVprocessed;
69
volatile int SPEVplayed;
71
volatile int OK; // when pause is released, the ui must know
72
// when the player has opened the devices and it is
73
// playing again then it put OK=1
75
volatile int playing; // if 1, the player is playing (or paused)
76
volatile int paused; // if 1, the player is paused
77
volatile int moving; // if 1, the player is moving the position
78
volatile int finished;// if 1, the song has finished playing
79
volatile int message; // set one of the following :
81
#define PLAYER_DOPAUSE 1
82
#define PLAYER_DOSTOP 2
83
#define PLAYER_SETPOS 4
86
volatile int error; //An error has ocurred(i.e. couldn't open device)
87
volatile ulong gotomsec;//milliseconds to go to,if player_setpos is set
89
volatile int gm; // if 1 then song is GeneralMidi, if 0 then MT32
91
volatile int volumepercentage ; //100 is no change, 50 halfs the
92
// volume and 200 doubles it (if possible)
94
volatile bool forcepgm[16]; // Force to use patch ... or not forced
95
volatile int pgm[16]; // Patch used at "this" moment
98
volatile double ratioTempo; // ratio to multiply the tempo
100
volatile MidiEvent *ev;
117
PlayerController *ctl;
121
void removeSpecialEvents(void);
122
void parseSpecialEvents(void);
123
void insertBeat(SpecialEvent *ev,ulong ms,int num,int den);
124
void generateBeats(void);
128
MidiPlayer(DeviceManager *midi_,PlayerController *pctl);
131
int loadSong(const char *filename);
132
void removeSong(void); // Unload the current song, so that everything is empty
134
int isSongLoaded(void) { return songLoaded; };
135
SpecialEvent *specialEvents() { return spev; };
136
void debugSpecialEvents(void);
138
//NoteArray *parseNotes(void);
140
NoteArray *getNoteArray(void) { return na; };
142
void play(int calloutput,void output(void));
144
void setParseSong(bool b);
146
MidiFileInfo *getInfo(void) { return info; };
148
void setPos(ulong gotomsec,MidiStatus *midistat);
150
void setTempoRatio(double ratio);