// // Programmer: Craig Stuart Sapp // Creation Date: Thu Oct 17 14:50:33 PDT 2013 // Last Modified: Thu Oct 17 14:50:39 PDT 2013 // Filename: ...museinfo/examples/all/location.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/location.cpp // Syntax: C++; museinfo // // Description: Give the location of data lines in various formats. // #include "humdrum.h" #include #include "PerlRegularExpression.h" #ifndef OLDCPP #include #include #include #define SSTREAM stringstream #define CSTRING str().c_str() using namespace std; #else #include #include #ifdef VISUAL #include #else #include #endif #define SSTREAM strstream #define CSTRING str() #endif /////////////////////////////////////////////////////////////////////////// // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void processFile (HumdrumFile& infile); int getVoiceCount (HumdrumFile& infile, int line); int getNoteCount (HumdrumFile& infile, int line); void printExclusiveInterpretation(void); void printLocation (HumdrumFile& infile, int line, int measure); int getStartingMeasure (HumdrumFile& infile); // global variables Options options; // database for command-line arguments int debugQ = 0; // used with --debug option int appendQ = 0; // used with -a option int prependQ = 0; // used with -p option int measureQ = 0; // used with -m option int doubleQ = 0; // used with -d option int labelQ = 1; // used with -L option int lineQ = 0; // used with -l option int fileQ = 0; // used with -f option int absQ = 0; // used with -q, -h, -w, -e, -x options int beatQ = 0; // used with -b option int rationalQ = 0; // used with -R option int spaceQ = 0; // used with -S option int quotesQ = 0; // used with -Q option char absChar = 'Q'; // used with -e, -q, -h, -w options RationalNumber absFactor = 1; // used with -q, -h, -w, -e, -x options /////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { checkOptions(options, argc, argv); HumdrumStream streamer(options); HumdrumFile infile; while (streamer.read(infile)) { if (beatQ || absQ) { infile.analyzeRhythm(); } processFile(infile); } return 0; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // processFile -- Do requested analysis on a given file. // void processFile(HumdrumFile& infile) { PerlRegularExpression pre; int measure = getStartingMeasure(infile); int i; for (i=0; i 1) { // use only quarter notes if more than one timebase is given. absFactor = 1; } if (appendQ) { // mutually exclusive options prependQ = 0; } if (!(measureQ || lineQ || fileQ)) { // if no location type selected, turn them all on fileQ = 1; lineQ = 1; measureQ = 1; beatQ = 1; absQ = 1; absFactor = 1; } } ////////////////////////////// // // 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: cde7fed6b654fb814d2b9ea960ccfa3e location.cpp [20131108]