CLAM-Development  1.4.0
MIDIEvent.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * MIDIFileReader C++ classes
20  * This code is part of the CLAM library, but also usable stand-alone.
21  * Maarten de Boer <mdeboer@iua.upf.es>
22  *
23  */
24 #ifndef __MIDIEvent__
25 #define __MIDIEvent__
26 
27 #include <CLAM/MIDIMessage.hxx>
28 
29 namespace MIDI
30 {
31 
32  class Event
33  /* a midi event is a time-stamped midi message */
34  {
35  private:
36  Message mMessage;
37  Ticks mTicks;
38  public:
40  {
41  mTicks = 0;
42  }
43 
44  Event(const Message& m,const Ticks& t):mMessage(m),mTicks(t)
45  {
46  }
47 
48  Byte operator [] (int i) const { return mMessage[i]; }
49 
50  Ticks GetTicks(void) const { return mTicks; }
51  };
52 
53 
54  /* meta and sysex events are really different, can be any length, etc
55  ** so we subclass Event for them
56  */
57 
58  class MetaEvent:public Event
59  {
60  public:
62  MetaEvent(const Message& m,const Ticks& t,int datasize):Event(m,t)
63  {
64  mData = new Byte[datasize];
65  }
66  };
67 
68  class SysExEvent:public Event
69  {
70  public:
72  SysExEvent(const Message& m,const Ticks& t,int datasize):Event(m,t)
73  {
74  mData = new Byte[datasize];
75  }
76  };
77 
78 }
79 
80 #endif
81