00001 #include "MIDI.h" 00002 00003 #include <iostream> 00004 #include <iomanip> 00005 using namespace std; 00006 00007 int main(int argc,char* argv[]) 00008 { 00009 if(argc!=2) 00010 { 00011 cerr << "usage: " << argv[0] << " midifile.mid" << endl; 00012 return -1; 00013 } 00014 MIDI::File mid(argv[1]); 00015 mid.open(); 00016 00017 MIDI::Header* header=mid.header(); 00018 00019 cout << "Header" << endl; 00020 cout << "\tFormat Type: " << header->formatType() << endl; 00021 cout << "\tNumber of Tracks: " << header->numTracks() << endl; 00022 00023 if(header->framesPerSecond()) 00024 { 00025 cout << "\tFrames Per Second: " << header->framesPerSecond() << endl; 00026 cout << "\tTicks Per Frame: " << header->ticksPerFrame() << endl; 00027 } 00028 else 00029 cout << "\tTicks Per Beat: " << header->ticksPerBeat() << endl; 00030 00031 for(int i=0;i<mid.numTracks();i++) 00032 { 00033 MIDI::Track* track=mid.track(i); 00034 cout << "Track #" << i+1 << endl; 00035 00036 for(int j=0;j<track->numEvents();j++) 00037 { 00038 MIDI::Event* event=track->event(j); 00039 event->debug(); 00040 } 00041 } 00042 00043 return 0; 00044 }