// // Programmer: Craig Stuart Sapp // Creation Date: Thu Nov 9 17:08:28 PST 2000 // Last Modified: Sun Nov 12 18:54:06 PST 2000 // Filename: ...sig/examples/all/pchlist.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/pchlist.cpp // Syntax: C++; museinfo // // Description: Generates a list of pitches in a Humdrum file and // the beat position and duration of the pitch. // #include "humdrum.h" #include #ifndef OLDCPP #include using namespace std; #else #include #endif // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void preparePitch (char* buffer2, const char* buffer1); void printOutput (HumdrumFile& hfile); void usage (const char* command); // User interface variables: Options options; int barlinesQ = 1; // used with the -B option int midinoteQ = 0; // used with the -m option int classQ = 0; // used with the -c option int base40Q = 0; // used with the -b option int trackQ = 0; // used with the -r option int tactusQ = 0; // used with the -t option ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); HumdrumFile hfile(options.getArg(1)); hfile.analyzeRhythm(); printOutput(hfile); return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // checkOptions -- // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("B|nobarlines=b", "don't display barlines"); opts.define("m|midi|MIDI=b", "display pitches as MIDI note numbers"); opts.define("c|class=b", "display pitches in pitch class notation"); opts.define("b|base40=b", "display pitches in base40 notation"); opts.define("r|track=b", "display track information"); opts.define("t|tactus=b", "display metrical positions"); 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, May 1998" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 3 July 1998" << endl; cout << "compiled: " << __DATE__ << endl; cout << MUSEINFO_VERSION << endl; exit(0); } else if (opts.getBoolean("help")) { usage(opts.getCommand().c_str()); exit(0); } else if (opts.getBoolean("example")) { example(); exit(0); } if (opts.getBoolean("nobarlines")) { barlinesQ = 0; } else { barlinesQ = 1; } if (opts.getBoolean("midi")) { midinoteQ = 1; base40Q = 0; } else { midinoteQ = 0; } if (opts.getBoolean("base40")) { base40Q = 1; midinoteQ = 0; } else { base40Q = 0; } if (opts.getBoolean("class")) { classQ = 1; } else { classQ = 0; } if (opts.getBoolean("tactus")) { tactusQ = 1; } else { tactusQ = 0; } if (opts.getBoolean("track")) { trackQ = 1; } else { trackQ = 0; } } ////////////////////////////// // // example -- // void example(void) { } ////////////////////////////// // // printOutput -- // void printOutput(HumdrumFile& hfile) { int i, j, k; char buffer1[1024] = {0}; char buffer2[1024] = {0}; double duration; for (i=0; i