// // Programmer: Craig Stuart Sapp // Creation Date: Wed Nov 22 18:42:05 PST 2000 // Last Modified: Wed Nov 29 14:29:53 PST 2000 // Last Modified: Wed Jan 1 22:55:05 PST 2003 (change Maxwell function style) // Filename: ...sig/examples/all/arto.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/arto.cpp // Syntax: C++; museinfo // // Description: reduces chordal textures to their unembellished forms. // #include "humdrum.h" #include #ifndef OLDCPP #include using namespace std; #else #include #endif // function declarations int displayChord(HumdrumFile& infile, Array& chord, int line); void generateReduction(HumdrumFile& infile, Array& chord); double getChordDuration(HumdrumFile& infile, Array& chord, int line); void printNewDuration(const char* kern, double duration); void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); // global variables Options options; // database for command-line arguments int debugQ = 0; // used with the --debug option int appendQ = 0; // used with the -a option int compoundQ = 1; // used with the -c option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array sonrel; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); for (int i=0; i& chord) { int i; for (i=0; i& chord, int line) { double duration = 0.0; int i; if (chord[line] == 'c') { duration = getChordDuration(infile, chord, line); for (i=0; i& chord, int line) { double output = 0; output += infile[line].getDuration(); int i; for (i=line+1; i= 0; i--) { if (chord[i] == 'c') { break; } if (chord[i] == 'n') { output += infile[i].getDuration(); } if (chord[i] == 'g') { break; } if (chord[i] == 'p') { break; } } return output; } ////////////////////////////// // // checkOptions -- validate and process command-line options. // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("a|append=b", "append analysis to data in output"); opts.define("C|compound=b", "don't try to use compound meters"); opts.define("debug=b", "trace input parsing"); opts.define("author=b", "author of the program"); opts.define("version=b", "compilation information"); opts.define("example=b", "example usage"); 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, Nov 2000" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: Nov 2000" << endl; cout << "compiled: " << __DATE__ << endl; cout << MUSEINFO_VERSION << endl; exit(0); } else if (opts.getBoolean("help")) { usage(opts.getCommand()); exit(0); } else if (opts.getBoolean("example")) { example(); exit(0); } debugQ = opts.getBoolean("debug"); appendQ = opts.getBoolean("append"); if (opts.getBoolean("compound")) { compoundQ = 0; } else { compoundQ = 0; } } ////////////////////////////// // // example -- example usage of the maxent program // void example(void) { cout << " \n" << endl; } ////////////////////////////// // // usage -- gives the usage statement for the quality program // void usage(const char* command) { cout << " \n" << endl; } // md5sum: 82e4cb1ccf446d2eead5adbb2e75ad95 arto.cpp [20050403]