~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmid/player/player.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  player.h  - class MidiPlayer. Plays a set of tracks
 
2
    Copyright (C) 1997,98,99,2000  Antonio Larrosa Jimenez
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
17
 
 
18
    Send comments and bug fixes to antlarr@arrakis.es
 
19
    or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
 
20
 
 
21
***************************************************************************/
 
22
#ifndef _PLAYER_H
 
23
#define _PLAYER_H
 
24
 
 
25
#include "dattypes.h"
 
26
#include "midfile.h"
 
27
#include "deviceman.h"
 
28
#include "track.h"
 
29
#include "notearray.h"
 
30
 
 
31
/**
 
32
 * This struct identifies text, lyrics and change tempo events 
 
33
 *
 
34
 * It includes 
 
35
 */
 
36
struct SpecialEvent
 
37
{
 
38
    int     id;
 
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
 
42
    int     type;
 
43
    //     0 Nothing, end of linked list
 
44
    //     1 Text
 
45
    //     3 Change Tempo
 
46
    //     5 Lyrics
 
47
    //     6 Change number of beats per measure
 
48
    //     7 Beat
 
49
    char    text[1024];
 
50
    ulong   tempo;
 
51
    int     num;
 
52
    int     den;
 
53
    struct  SpecialEvent *next;
 
54
};
 
55
 
 
56
 
 
57
struct PlayerController
 
58
{
 
59
    volatile ulong      ticksTotal;
 
60
    volatile ulong      ticksPlayed;
 
61
    volatile double     millisecsPlayed;
 
62
    volatile ulong      beginmillisec;
 
63
    
 
64
    volatile int        tempo;
 
65
    volatile int        num;
 
66
    volatile int        den;
 
67
    
 
68
    volatile int        SPEVprocessed;
 
69
    volatile int        SPEVplayed;
 
70
    
 
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
 
74
    
 
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 :
 
80
    
 
81
#define PLAYER_DOPAUSE  1
 
82
#define PLAYER_DOSTOP   2
 
83
#define PLAYER_SETPOS   4
 
84
#define PLAYER_HALT     8
 
85
    
 
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
 
88
    
 
89
    volatile int        gm; // if 1 then song is GeneralMidi, if 0 then MT32
 
90
    
 
91
    volatile int        volumepercentage ; //100 is no change, 50 halfs the
 
92
    // volume and 200 doubles it (if possible)
 
93
    
 
94
    volatile bool       forcepgm[16];  // Force to use patch ... or not forced
 
95
    volatile int        pgm[16];       // Patch used at "this" moment
 
96
    
 
97
    
 
98
    volatile double      ratioTempo; // ratio to multiply the tempo
 
99
    
 
100
    volatile MidiEvent  *ev;
 
101
};
 
102
 
 
103
 
 
104
class MidiStatus;
 
105
 
 
106
class MidiPlayer
 
107
{
 
108
    
 
109
    DeviceManager *midi;
 
110
    MidiFileInfo *info;
 
111
    MidiTrack **tracks;
 
112
    SpecialEvent *spev;
 
113
    NoteArray *na;
 
114
    
 
115
    int songLoaded;
 
116
    
 
117
    PlayerController *ctl;
 
118
    
 
119
    bool parseSong;
 
120
    
 
121
    void removeSpecialEvents(void);
 
122
    void parseSpecialEvents(void);
 
123
    void insertBeat(SpecialEvent *ev,ulong ms,int num,int den);
 
124
    void generateBeats(void);
 
125
    
 
126
public:
 
127
 
 
128
    MidiPlayer(DeviceManager *midi_,PlayerController *pctl);
 
129
    ~MidiPlayer();
 
130
    
 
131
    int loadSong(const char *filename);
 
132
    void removeSong(void); // Unload the current song, so that everything is empty
 
133
    
 
134
    int isSongLoaded(void) { return songLoaded; };
 
135
    SpecialEvent *specialEvents() { return spev; };
 
136
    void debugSpecialEvents(void);
 
137
 
 
138
    //NoteArray *parseNotes(void);
 
139
 
 
140
    NoteArray *getNoteArray(void) { return na; };
 
141
    
 
142
    void play(int calloutput,void output(void));
 
143
    
 
144
    void setParseSong(bool b);
 
145
    
 
146
    MidiFileInfo *getInfo(void) { return info; };
 
147
    
 
148
    void setPos(ulong gotomsec,MidiStatus *midistat);
 
149
    
 
150
    void setTempoRatio(double ratio);
 
151
    
 
152
};
 
153
 
 
154
#endif