MIDITypes.hxx

Go to the documentation of this file.
00001 #ifndef __MIDITYPES__
00002 #define __MIDITYPES__
00003 
00004 #include <string>
00005 #include "DynamicType.hxx"
00006 #include "DataTypes.hxx"
00007 #include "List.hxx"
00008 #include "Array.hxx"
00009 #include "MIDIMelody.hxx"
00010 #include "ProcessingData.hxx"
00011 
00012 namespace CLAM
00013 {
00014         class MIDIEvent : public ProcessingData
00015         {
00016         public:
00017                 DYNAMIC_TYPE_USING_INTERFACE (MIDIEvent, 4, ProcessingData);
00018                 /* Event name */
00019                 DYN_ATTRIBUTE (0, public, std::string, Name);
00020                 /* Time in seconds */
00021                 DYN_ATTRIBUTE (1, public, TTime, Time);   
00022                 /* flag to indicate that this is the last event */
00023                 DYN_ATTRIBUTE (2, public, bool, Last);
00024                 /* Message */
00025                 DYN_ATTRIBUTE (3, public, Array<TMIDIByte>, Message);
00026                 
00027                 unsigned Ticks() const;
00028                 unsigned TicksFromDuration() const;
00029                 int Length() const;
00030 
00031                 bool operator==(const MIDIEvent& ev) {return Ticks()==ev.Ticks();}
00032                 bool operator<(const MIDIEvent& ev) {return Ticks()<ev.Ticks();}
00033                 bool operator>(const MIDIEvent& ev) {return Ticks()>ev.Ticks();}
00034                 bool operator==(const MIDIEvent& ev) const {return Ticks()==ev.Ticks();}
00035                 bool operator<(const MIDIEvent& ev) const {return Ticks()<ev.Ticks();}
00036                 bool operator>(const MIDIEvent& ev) const {return Ticks()>ev.Ticks();}
00037                 
00038         private:
00039                 void DefaultInit();
00040         };
00041 
00042         class MIDITrack : public ProcessingData
00043         {
00044         public:
00045                 DYNAMIC_TYPE_USING_INTERFACE (MIDITrack, 4, ProcessingData);
00046                 /* Track name */
00047                 DYN_ATTRIBUTE (0, public, std::string, Name);
00048                 /* MIDI channels for notes in the melody */
00049                 DYN_ATTRIBUTE (1, public, List<int>, Channels);
00050                 /* Event info list */
00051                 DYN_ATTRIBUTE (2, public, List<MIDIEvent>, EventInfo);   
00052                 /* Track melody */
00053                 DYN_ATTRIBUTE (3, public, MIDIMelody, TrackMelody);
00054 
00055         private:
00056                 void DefaultInit();
00057         };
00058 
00059         class MIDISong : public ProcessingData
00060         {
00061         public:
00062                 DYNAMIC_TYPE_USING_INTERFACE (MIDISong, 3, ProcessingData);
00063                 /* Song name */
00064                 DYN_ATTRIBUTE (0, public, std::string, Name);
00065                 /* Song tracks */
00066                 DYN_ATTRIBUTE (1, public, Array<MIDITrack>, Tracks);
00067                 /* Number of tracks */
00068                 DYN_ATTRIBUTE (2, public, int, NumberOfTracks);   
00069                 
00070         private:
00071                 void DefaultInit();
00072         };
00073 }
00074 
00075 #endif
00076 
Generated by  doxygen 1.6.3