// // Programmer: Craig Stuart Sapp // Creation Date: Wed Jan 10 12:32:52 PST 2001 // Last Modified: Mon Jan 29 10:39:20 PST 2001 // Filename: ...sig/examples/all/ccheck.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/ccheck.cpp // Syntax: C++; museinfo // // Description: determine the chord information for the given region // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void printAnalysis (HumdrumFile& infile, Array& rhylev); void usage (const char* command); int findMinimum (Array& values); int findBestMode (Array& values, int bestroot); int findBestTonic (Array& values); // 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 double e1; // used with the --e1 option double e2; // used with the --e2 option double sx; // used with the --sx option double sy; // used with the --sy option double neighbornorm[40] = { 0.0000000000000, // C C 0 0 0 1.4142135623731, // C C# 1 1 -1 2.8284271247462, // C C## 2 2 -2 100000.0, // invalid 3 3.0000000000000, // C D-- 4 -3 0 2.2360679774998, // C D- 5 -2 -1 2.2360679774998, // C D 6 -1 -2 3.0000000000000, // C D# 7 0 -3 4.0000000000000, // C D## 8 4 0 100000.0, // invalid 9 2.2360679774998, // C E-- 10 -1 2 1.0000000000000, // C E- 11 0 1 1.0000000000000, // C E 12 1 0 2.2360679774998, // C E# 13 2 -1 3.6055512754640, // C E## 14 3 -2 3.1622776601684, // C F-- 15 -3 1 2.0000000000000, // C F- 16 -2 0 1.4142135623731, // C F 17 -1 -1 2.0000000000000, // C F# 18 0 -2 3.1622776601684, // C F## 19 1 -3 100000.0, // invalid 20 3.1622776601684, // C G-- 21 -1 3 2.0000000000000, // C G- 22 0 2 1.4142135623731, // C G 23 1 1 2.0000000000000, // C G# 24 2 0 3.1622776601684, // C G## 25 3 -1 100000.0, // invalid 26 2.2360679774998, // C A-- 27 -2 1 1.0000000000000, // C A- 28 -1 0 1.0000000000000, // C A 29 0 -1 2.2360679774998, // C A# 30 1 -2 3.6055512754640, // C A## 31 2 -3 100000.0, // invalid 32 3.0000000000000, // C B-- 33 0 3 2.2360679774998, // C B- 34 1 2 2.2360679774998, // C B 35 2 1 3.0000000000000, // C B# 36 3 0 4.1231056256176, // C B## 37 4 -1 2.8284271247462, // C C-- -2 -2 2 1.4142135623731, // C C- -1 -1 1 }; /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array rhylev; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); // int most = 0; Array values; values.setSize(0); char buffer[128] = {0}; Array tonicscores; for (int i=0; i& values, int majorbest) { int majindexnatu = (12 + majorbest) % 40; int majindexflat = (11 + majorbest) % 40; cout << "tonic " << majorbest << "\t= " << values[majorbest] << endl; cout << "values " << majindexnatu << "\t= " << values[majindexnatu] << endl; cout << "values " << majindexflat << "\t= " << values[majindexflat] << endl; cout << "Diff = " << values[majindexflat]-values[majorbest] << endl; if (values[majindexnatu] < values[majindexflat]) { return 0; } else { return 1; } } ////////////////////////////// // // findMinimum -- // int findMinimum(Array& values) { int i; int min = 0; for (i=1; i& values) { int i; int best = 0; for (i=1; i& rhylev) { int i; if (appendQ) { for (i=0; i