// // Programmer: Craig Stuart Sapp // Creation Date: Tue Jun 18 16:02:28 PDT 2002 // Last Modified: Tue Jun 18 16:02:31 PDT 2002 // Filename: ...sig/examples/all/diaroot.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/diaroot.cpp // Syntax: C++; museinfo // // Description: Determine the root weightings for every possible // root using a diatonic metric. // #include "humdrum.h" #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void printScores (Array& rootscores); int analyzeRootProbability1 (Array& rootscores, HumdrumFile& infile, int startline, int stopline, int debugQ = 0); double base40ToBase7 (int pitch); void findErrors (HumdrumFile& infile, int debugQ); char base7pcToName (int value); // 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 rootQ = 0; // used with the -R option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // process the command-line options checkOptions(options, argc, argv); Array rootscores; rootscores.setSize(40); rootscores.setSize(0); int i; for (i=1; i<=options.getArgCount() || options.getArgCount()==0; i++) { infile.clear(); // if no command-line arguments read data file from standard input if (options.getArgCount() < 1) { infile.read(cin); } else { infile.read(options.getArg(i)); } if (rootQ == 0) { analyzeRootProbability1(rootscores, infile, 0, 0, debugQ); printScores(rootscores); } else { findErrors(infile, debugQ); } } return 0; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // findErrors -- compare root scores value to root in data. // void findErrors(HumdrumFile& infile, int debugQ) { int oldline = 0; int init = 0; int best; int correct = 0; int i; int j; Array rootscores(7); rootscores.setAll(0); for (i=0; i