// // Programmer: Craig Stuart Sapp // Creation Date: Mon Apr 23 14:00:47 PDT 2012 // Last Modified: Mon Apr 23 14:00:50 PDT 2012 // Filename: ...sig/examples/all/tacet.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/tacet.cpp // Syntax: C++; museinfo // // Description: Locate/label sections where **kern spines contain no notes. // #include "humdrum.h" #include "PerlRegularExpression.h" #ifndef OLDCPP #include #define SSTREAM stringstream #define CSTRING str().c_str() using namespace std; #else #ifdef VISUAL #include /* for windows 95 */ #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 checkForTacets (HumdrumFile& infile, Array >& tacetinfo); void printTacetInfo (HumdrumFile& infile, Array >& tacetinfo); void verifyNoTacetMarkers (HumdrumFile& infile); void printWithMarkers (HumdrumFile& infile, Array >& tacetinfo); void printTacetLine (HumdrumFile& infile, int line, Array >& tacetinfo, int aline); Options options; // database for command-line arguments string Filename = ""; // used with nothing at the moment int pathQ = 1; // used with nothing at the moment int insertQ = 0; // used with -i option int lineQ = 1; // used with -l option int fileQ = 0; // used with -f option int debugQ = 0; // used with --debug option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); Array > tacetinfo; PerlRegularExpression pre; for (int i=0; i >& tacetinfo) { int jj = 0; int i; for (i=0; i >& tacetinfo, int aline) { int j; int track; int printQ = 0; char buffer[8192] = {0}; if (aline == 0) { // print *tacet for any track which contains a 0. for (j=0; j 0) && (tacetinfo[aline-1][track] == 0)) { // print *xtacet if non-zero and previous section was tacet strcat(buffer, "*xtacet"); printQ = 1; } else { strcat(buffer, "*"); } } else { strcat(buffer, "*"); } if (j < infile[line].getFieldCount()-1) { strcat(buffer, "\t"); } } strcat(buffer, "\n"); if (printQ) { cout << buffer; } } ////////////////////////////// // // verifyNoTacetMarkers -- // void verifyNoTacetMarkers(HumdrumFile& infile) { int i, j; for (i=0; i >& tacetinfo) { int i, j; for (i=0; i >& tacetinfo) { int lastsection = 0; int lastmeasure = 0; int datafound = 0; int measurenum = 0; PerlRegularExpression pre; int printedfilename = 0; tacetinfo.setSize(1000); tacetinfo.setSize(0); tacetinfo.setGrowth(1123123); Array kerntracks; infile.getTracksByExInterp(kerntracks, "**kern"); Array kernstates; kernstates.setSize(infile.getMaxTracks()+1); kernstates.setAll(0); Array > tracknames; tracknames.setSize(infile.getMaxTracks()+1); int j; for (j=0; j