// // Programmer: Craig Stuart Sapp // Creation Date: Wed Oct 15 04:30:17 PDT 2008 // Last Modified: Wed Oct 15 08:13:13 PDT 2008 // Filename: ...sig/examples/all/marcello1.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/marcello1.cpp // Syntax: C++; museinfo // // Description: Feature extractor which extract the metrical position // of each beat, the number of events in the left hand, // and the number of events in a beat for the right hand // in piano music (two primary spines of music, the first // **kern spine contains the left hand, the second **kern spine // contains the right hand. Any primary **kern spines after // the first two will be ignored. #ifndef OLDCPP #include using namespace std; #else #include #endif #include "humdrum.h" #define FIELDCOUNT 5 ////////////////////////////////////////////////////////////////////////// // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); void countEvents (int& lh, int &rh, HumdrumFile& infile, int line); void createAnalysisOne (ostream& out, HumdrumFile& infile); // User interface variables: Options options; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { // process the command-line options checkOptions(options, argc, argv); HumdrumFile infile; infile.read(options.getArg(1)); createAnalysisOne(std::cout, infile); return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // createAnalysisOne -- print the metrical position, the number of // events in the left hand (bottom staff), the number of events in // the right hand (top staff). // void createAnalysisOne(ostream& out, HumdrumFile& infile) { int i, j; int absbeat = -1; int lastabsbeat = -1; int metrical = -1; int lastmetrical = -1; int lhcounter = -1; int rhcounter = -1; int rh; int lh; int datafound = 0; int endofdata = -1; int measureQ = 0; int difference; int measurenum; char measure[32] = {0}; infile.analyzeRhythm("4"); for (i=0; i 1) { for (j=1; j trackfound; trackfound.setSize(2); trackfound.setAll(0); Array trackcounts; trackcounts.setSize(2); trackcounts.setAll(0); for (i=0; i