// // Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu> // Creation Date: Mon Feb 25 21:15:21 PST 2002 // Last Modified: Mon Feb 25 21:15:24 PST 2002 // Filename: ...sig/examples/all/staffinfo.cpp // Web Address: http://sig.sapp.org/examples/museinfo/score/staffinfo.cpp // Syntax: C++; museinfo // // Description: Display staff information for a SCORE page file. // #include "ScorePage.h" #include "Options.h" #include <string.h> #include <stdlib.h> // function declarations: void checkOptions(Options& opts, int argc, char* argv[]); void example(void); void usage(const char* command); void printSystemInfo(ScorePage& page); // interface variables: Options options; int verboseQ = 0; // used with -v option int debugQ = 0; // used with --debug option int durationQ = 0; // used with -d option const char* outputfilename = ""; // used with -o option ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { checkOptions(options, argc, argv); if (options.getArgCount() == 0) { cout << "Usage: " << argv[0] << " input.mus " << endl; exit(1); } ScorePage scorepage; for (int i=1; i<=options.getArgCount(); i++) { scorepage.readFile(options.getArg(i), verboseQ); scorepage.analyzeContent(); printSystemInfo(scorepage); } return 0; } ////////////////////////////////////////////////////////////////////////// /////////////////////////////// // // printSystemInfo -- // void printSystemInfo(ScorePage& page) { page.analyzeSystems(); cout << "Number of staves : " << page.getStaffCount() << "\n"; cout << "Maximum staff number : " << page.getMaxStaff() << "\n"; cout << "Number of systems : " << page.getSystemCount() << "\n"; int i, j; int staffnum; int barheight; for (i=0; i<page.getSystemCount(); i++) { cout << "System " << i+1 << endl; if (durationQ) { cout << "\tDuration: " << page.getSystemDuration(i) << " quarter notes" << "\n"; } cout << "\tStaves: " << page.getSystemStaffCount(i) << "\n"; for (j=page.getSystemStaffCount(i)-1; j>=0; j--) { staffnum = page.getSystemStaffP2(i,j); cout << "\t\t" << "Staff "; if (staffnum < 10) { cout << " "; } cout << staffnum; cout << endl; cout << "\t\t\t" << "MaxBarHeight:"; barheight = page.getMaxBarlineLength(i,j); cout << barheight; if (barheight > 1) { cout << " staves"; } else { cout << " staff"; } cout << "\n"; } } } ////////////////////////////// // // checkOptions -- validate and process command-line options. // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("v|verbose=b", "verbose display of information"); opts.define("d|duration=b", "display duration of systems"); opts.define("I|no-invisible=b", "do not dispay invisible rests"); opts.define("debug=b"); // determine bad input line num 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, Jul 2012" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 29 Jul 2012" << 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); } verboseQ = opts.getBoolean("verbose"); debugQ = opts.getBoolean("debug"); durationQ = opts.getBoolean("duration"); } ////////////////////////////// // // example -- example usage of the quality program // void example(void) { cout << " \n" << endl; } ////////////////////////////// // // usage -- gives the usage statement for the meter program // void usage(const char* command) { cout << " \n" << endl; } // md5sum: e9a4e72e84b3c90c266e3f3360115189 spageinfo.cpp [20120811]