// // Programmer: Craig Stuart Sapp // Creation Date: Mon Oct 14 23:58:44 2002 // Last Modified: Mon Apr 25 11:30:20 PDT 2005 // Filename: ...sig/examples/all/jointextract.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/jointextract.cpp // Syntax: C++; museinfo // // Description: Extract joint information from a spine related to multiple // **kern data spines. // #include "humdrum.h" #include #include #ifndef OLDCPP using namespace std; #include #else #include #endif // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); void processFile (HumdrumFile& infile); int findTargetSpine (HumdrumFile& infile, string& targetstr); void printExtractedJointInfo(HumdrumFile& infile, int line, int targetspine); string interp = "**kern"; string target = ""; // User interface variables: Options options; int jointspine = 1; // used with -j option int inlineq = 0; // used with -i option ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); HumdrumFile infile; int i; for (i=1; i<=options.getArgCount(); i++) { infile.clear(); infile.read(options.getArg(i)); processFile(infile); } return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // findTargetSpine -- // int findTargetSpine(HumdrumFile& infile, string& targetstr) { int i, j; for (i=0; i basecounts; basecounts.setSize(infile.getMaxTracks()); basecounts.setSize(0); int count = 0; int targetindex = -1; int i, j; for (i=0; i 1) { cout << "\t"; } cout << infile[i][j]; } } } else { cout << infile[i]; } cout << "\n"; break; case E_humrec_data: printExtractedJointInfo(infile, i, targetspine); cout << "\n"; break; case E_humrec_none: case E_humrec_empty: case E_humrec_global_comment: case E_humrec_bibliography: default: cout << infile[i] << "\n"; } } } ////////////////////////////// // // checkOptions -- // void checkOptions(Options& opts, int argc, char* argv[]) { opts.define("joint|j=i:1", "the joint spine to extract, starting at 1"); opts.define("target|t=s", "the target interpretation to extract from"); opts.define("inline|i=b", "extract the data inline with original input"); opts.define("author=b", "author of program"); opts.define("version=b", "compilation info"); opts.define("example=b", "example usages"); opts.define("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, Sep 2006" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 12 Sep 2006" << 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); } jointspine = opts.getInteger("joint") - 1; if (jointspine < 0) { jointspine = 0; } target = opts.getString("target"); inlineq = opts.getBoolean("inline"); } ////////////////////////////// // // example -- // void example(void) { } ////////////////////////////// // // usage -- // void usage(const char* command) { } // md5sum: 80f684c94da61a86bca2ccada16fb5f2 jointextract.cpp [20160320]