Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 /**********************************************************************/ 00016 /**********************************************************************/ 00017 00018 #ifndef STK_MIDIFILEIN_H 00019 #define STK_MIDIFILEIN_H 00020 00021 #include "Stk.h" 00022 #include <string> 00023 #include <vector> 00024 #include <fstream> 00025 #include <sstream> 00026 00027 class MidiFileIn : public Stk 00028 { 00029 public: 00031 00035 MidiFileIn( std::string fileName ); 00036 00038 ~MidiFileIn(); 00039 00041 int getFileFormat() const; 00042 00044 unsigned int getNumberOfTracks() const; 00045 00047 00052 int getDivision() const; 00053 00055 00059 void rewindTrack( unsigned int track = 0 ); 00060 00062 00069 double getTickSeconds( unsigned int track = 0 ); 00070 00072 00084 unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 ); 00085 00087 00097 unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 ); 00098 00099 protected: 00100 00101 // This protected class function is used for reading variable-length 00102 // MIDI file values. It is assumed that this function is called with 00103 // the file read pointer positioned at the start of a 00104 // variable-length value. The function returns true if the value is 00105 // successfully parsed. Otherwise, it returns false. 00106 bool readVariableLength( unsigned long *value ); 00107 00108 std::ifstream file_; 00109 unsigned int nTracks_; 00110 int format_; 00111 int division_; 00112 bool usingTimeCode_; 00113 std::vector<double> tickSeconds_; 00114 std::vector<long> trackPointers_; 00115 std::vector<long> trackOffsets_; 00116 std::vector<long> trackLengths_; 00117 std::vector<char> trackStatus_; 00118 00119 // This structure and the following variables are used to save and 00120 // keep track of a format 1 tempo map (and the initial tickSeconds 00121 // parameter for formats 0 and 2). 00122 struct TempoChange { 00123 unsigned long count; 00124 double tickSeconds; 00125 }; 00126 std::vector<TempoChange> tempoEvents_; 00127 std::vector<unsigned long> trackCounters_; 00128 std::vector<unsigned int> trackTempoIndex_; 00129 }; 00130 00131 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |