1 // 2 // Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu> 3 // Creation Date: Sat Feb 14 21:55:38 PST 2015 4 // Last Modified: Sat Apr 21 10:52:19 PDT 2018 Removed using namespace std; 5 // Filename: midifile/include/MidiEventList.h 6 // Website: http://midifile.sapp.org 7 // Syntax: C++11 8 // vim: ts=3 noexpandtab 9 // 10 // Description: A class that stores a MidiEvents for a MidiFile track. 11 // 12 13 #ifndef _MIDIEVENTLIST_H_INCLUDED 14 #define _MIDIEVENTLIST_H_INCLUDED 15 16 #include "MidiEvent.h" 17 #include <vector> 18 19 namespace smf { 20 21 class MidiEventList { 22 public: 23 MidiEventList (void); 24 MidiEventList (const MidiEventList& other); 25 MidiEventList (MidiEventList&& other); 26 27 ~MidiEventList (); 28 29 MidiEventList& operator= (MidiEventList& other); 30 MidiEvent& operator[] (int index); 31 const MidiEvent& operator[] (int index) const; 32 33 MidiEvent& back (void); 34 const MidiEvent& back (void) const; 35 MidiEvent& last (void); 36 const MidiEvent& last (void) const; 37 MidiEvent& getEvent (int index); 38 const MidiEvent& getEvent (int index) const; 39 void clear (void); 40 void reserve (int rsize); 41 int getEventCount (void) const; 42 int getSize (void) const; 43 int size (void) const; 44 void removeEmpties (void); 45 int linkNotePairs (void); 46 int linkEventPairs (void); 47 void clearLinks (void); 48 void clearSequence (void); 49 int markSequence (int sequence = 1); 50 51 int push (MidiEvent& event); 52 int push_back (MidiEvent& event); 53 int append (MidiEvent& event); 54 55 // careful when using these, intended for internal use in MidiFile class: 56 void detach (void); 57 int push_back_no_copy (MidiEvent* event); 58 59 // access to the list of MidiEvents for sorting with an external function: 60 MidiEvent** data (void); 61 62 protected: 63 std::vector<MidiEvent*> list; 64 65 private: 66 void sort (void); 67 68 // MidiFile class calls sort() 69 friend class MidiFile; 70 }; 71 72 73 int eventcompare(const void* a, const void* b); 74 75 } // end of namespace smf 76 77 #endif /* _MIDIEVENTLIST_H_INCLUDED */ 78 79 80 81