CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * MIDIFileReader C++ classes 00020 * This code is part of the CLAM library, but also usable stand-alone. 00021 * Maarten de Boer <mdeboer@iua.upf.es> 00022 * 00023 */ 00024 #ifndef __MIDITrack__ 00025 #define __MIDITrack__ 00026 00027 #include <list> 00028 #include "MIDIEvent.hxx" 00029 00030 namespace MIDI 00031 { 00032 00033 class Track 00034 { 00035 private: 00036 /* a midi track consists of a list of midi event */ 00037 std::list<Event*> mEventList; 00038 00039 /* and may have a name */ 00040 char* mName; 00041 00042 public: 00043 Track(void) 00044 :mName(0) 00045 { 00046 } 00047 00048 ~Track(void) 00049 { 00050 if (mName) delete mName; 00051 } 00052 00053 void Add(Event* e) 00054 { 00055 mEventList.push_back(e); 00056 } 00057 00058 void Name(const Byte* ptr, int len) 00059 { 00060 if (mName) delete mName; 00061 mName = new char[len+1]; 00062 for (int i=0;i<len;i++) mName[i] = ptr[i]; 00063 mName[len] = 0; 00064 } 00065 00066 00067 /* iterator to traverse the list of events */ 00068 typedef std::list<Event*>::const_iterator EventIterator; 00069 00070 EventIterator Begin(void) { return mEventList.begin(); } 00071 EventIterator End(void) { return mEventList.end(); } 00072 00073 bool HasTempoEvents(void) 00074 { 00075 EventIterator it = Begin(); 00076 00077 while (it!=End()) 00078 { 00079 const Event &ev = **it; 00080 if ( ev[0]==0xFF && ev[1]==0x51 ) return true; 00081 it++; 00082 } 00083 return false; 00084 } 00085 00086 }; 00087 00088 } 00089 00090 #endif 00091