// // Programmer: Craig Stuart Sapp // Creation Date: Tue Jan 22 22:09:46 PST 2002 // Last Modified: Mon Feb 9 21:26:32 PST 2015 Updated for C++11. // Filename: tools/midi2text.cpp // URL: https://github.com/craigsapp/midifile/blob/master/tools/midi2text.cpp // Syntax: C++11 // vim: ts=3 // // Description: Converts a MIDI file into a text based notelist. // #include "MidiFile.h" #include "Options.h" #include #include #include #include #include using namespace std; using namespace smf; void convertMidiFileToText (MidiFile& midifile); void setTempo (MidiFile& midifile, int index, double& tempo); void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); // User interface variables: Options options; int debugQ = 0; // use with --debug option int maxcount = 100000; double tempo = 60.0; ////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { checkOptions(options, argc, argv); MidiFile midifile(options.getArg(1)); convertMidiFileToText(midifile); return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // convertMidiFileToText -- // void convertMidiFileToText(MidiFile& midifile) { midifile.absoluteTicks(); midifile.joinTracks(); vector ontimes(128); vector onvelocities(128); int i; for (i=0; i<128; i++) { ontimes[i] = -1.0; onvelocities[i] = -1; } double offtime = 0.0; int key = 0; int vel = 0; for (i=0; i