The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# MidiFileIn.h

    00001 #ifndef STK_MIDIFILEIN_H
    00002 #define STK_MIDIFILEIN_H
    00003
    00004 #include "Stk.h"
    00005 #include <string>
    00006 #include <vector>
    00007 #include <fstream>
    00008 #include <sstream>
    00009
    00010 namespace stk {
    00011
    00012 /**********************************************************************/
    00027 /**********************************************************************/
    00028
    00029 class MidiFileIn : public Stk
    00030 {
    00031  public:
    00033
    00037   MidiFileIn( std::string fileName );
    00038
    00040   ~MidiFileIn();
    00041
    00043   int getFileFormat() const { return format_; };
    00044
    00046   unsigned int getNumberOfTracks() const { return nTracks_; };
    00047
    00049
    00054   int getDivision() const { return division_; };
    00055
    00057
    00061   void rewindTrack( unsigned int track = 0 );
    00062
    00064
    00071   double getTickSeconds( unsigned int track = 0 );
    00072
    00074
    00086   unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 );
    00087
    00089
    00099   unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 );
    00100
    00101  protected:
    00102
    00103   // This protected class function is used for reading variable-length
    00104   // MIDI file values. It is assumed that this function is called with
    00105   // the file read pointer positioned at the start of a
    00106   // variable-length value.  The function returns true if the value is
    00107   // successfully parsed.  Otherwise, it returns false.
    00108   bool readVariableLength( unsigned long *value );
    00109
    00110   std::ifstream file_;
    00111   unsigned int nTracks_;
    00112   int format_;
    00113   int division_;
    00114   bool usingTimeCode_;
    00115   std::vector<double> tickSeconds_;
    00116   std::vector<long> trackPointers_;
    00117   std::vector<long> trackOffsets_;
    00118   std::vector<long> trackLengths_;
    00119   std::vector<char> trackStatus_;
    00120
    00121   // This structure and the following variables are used to save and
    00122   // keep track of a format 1 tempo map (and the initial tickSeconds
    00123   // parameter for formats 0 and 2).
    00124   struct TempoChange {
    00125     unsigned long count;
    00126     double tickSeconds;
    00127   };
    00128   std::vector<TempoChange> tempoEvents_;
    00129   std::vector<unsigned long> trackCounters_;
    00130   std::vector<unsigned int> trackTempoIndex_;
    00131 };
    00132
    00133 } // stk namespace
    00134
    00135 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.