// // Programmer: Craig Stuart Sapp // Creation Date: Sat Dec 16 13:17:40 PST 2000 // Last Modified: Sat Dec 16 13:17:43 PST 2000 // Filename: ...sig/examples/all/cliche.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/cliche.cpp // Syntax: C++; museinfo // // Description: search for identical textures in a musical score. // // Note: The program is not yet finished. // // -u = match only using non-repeated notes // -p = match only using pitch classes // -d = duration to match // -i = display cliches in integer form (default it alphabetic) // -b = match by exact beat locations // -n = minimum occurances of the cliche in order to mark it // -m = match by exact meter position // -t = match by transposition // etc. // // // #include "humdrum.h" #include #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void printAnalysis (HumdrumFile& infile, Array& cliche, int max); void usage (const char* command); char* getClicheSymbol (char* buffer, int cliche, int maxcount, int style); // global variables Options options; // database for command-line arguments int debugQ = 0; // used with the --debug option int appendQ = 0; // used with the -a option int compoundQ = 1; // used with the -c option int pcQ = 0; // used with the -p option double duration = 1.0; // used with the -d option int minimum = 1; // used with the -n option int integerQ = 0; // used with the -i option char buffer[1000] = {0}; /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array cliche; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); for (int i=0; i 0) { sprintf(buffer, "%d", cliche); } else { buffer[0] = '.'; buffer[1] = '\0'; } return buffer; } if (cliche == 0) { buffer[0] = '.'; buffer[1] = '\0'; return buffer; } int copy = abs(cliche); int digits = (int)(log10((double)copy)/log10(26.0) + 1); buffer[0] = '\0'; if (cliche < 0) { buffer[0] = '@'; buffer[1] = '\0'; } char letter[2]; letter[1] = '\0'; int i; int current = copy-1; int digit; for (i=digits; i>0; i--) { digit = current % (int)pow(26.0, i); letter[0] = 'a' + digit; current -= (int)(digit * pow(26.0, i)); strcat(buffer, letter); } return buffer; } ////////////////////////////// // // printAnalysis -- // void printAnalysis(HumdrumFile& infile, Array& cliche, int max) { int i; if (appendQ) { for (i=0; i