// // Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu> // Creation Date: Mon Apr 30 12:04:25 PDT 2001 // Last Modified: Mon Apr 30 12:04:32 PDT 2001 // Filename: ...sig/examples/all/midi2asc.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/midi2asc.cpp // Syntax: C++; museinfo // // Description: Description: Converts a MIDI file into an ASCII text format. // #include "MidiFile.h" #include "Options.h" // user interface variables Options options; // function declarations: void checkOptions(Options& opts, int argc, char** argv); void example(void); void usage(const char* command); ////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { checkOptions(options, argc, argv); MidiFile midifile(options.getArg(1)); if (options.getBoolean("type0")) { midifile.joinTracks(); } if (options.getBoolean("absolute")) { midifile.absoluteTime(); } else { midifile.deltaTime(); } cout << midifile; return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // checkOptions -- // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("a|absolute=b", "display in absolute ticks"); opts.define("0|O|o|type0|m|mono|s|single=b", "display in type 0 mode"); opts.define("author=b", "author of program"); opts.define("version=b", "compilation info"); opts.define("example=b", "example usages"); opts.define("h|help=b", "short description"); opts.process(argc, argv); // handle basic options: if (opts.getBoolean("author")) { cout << "Written by Craig Stuart Sapp, " << "craig@ccrma.stanford.edu, 30 April 2001" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: April 2001" << endl; cout << "compiled: " << __DATE__ << endl; exit(0); } else if (opts.getBoolean("help")) { usage(opts.getCommand()); exit(0); } else if (opts.getBoolean("example")) { example(); exit(0); } if (opts.getArgCount() != 1) { usage(opts.getCommand()); exit(1); } } ////////////////////////////// // // example -- // void example(void) { } ////////////////////////////// // // usage -- // void usage(const char* command) { } // md5sum: 7ff4280fae499e69ea4c5caad4a61876 midi2asc.cpp [20050403]