// // 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/rootspace.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/rootspace.cpp // Syntax: C++; museinfo // // Description: Measure the chord information for a given space. // #include "humdrum.h" #include #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); int findMinimum (Array& values); void fillDataArrays (HumdrumFile& infile, Array& pitch, Array& testset, Array& duration, Array& level, int& target, int& targetindex); int generateAnalysis (Array& pitch, Array& duration, Array& level, Array& testset, double sx, double e1, double e2, Array& coef); int intcompare (const void* a, const void* b); double secondbest (int bestindex, Array& coef); // pitch space variables: int vectorxsq[40] = { 0, 49, 49, 1000000, 16, 16, 16, 16, 16, 1000000, 64, 1, 1, 64, 64, 25, 25, 25, 25, 25, 1000000, 81, 4, 4, 4, 81, 1000000, 36, 36, 36, 36, 36, 1000000, 9, 9, 9, 9, 100, 49, 49 }; int vectorysq[40] = { 0, 4, 16, 1000000, 16, 4, 0, 4, 16, 1000000, 9, 1, 1, 9, 25, 25, 9, 1, 1, 9, 1000000, 16, 4, 0, 4, 16, 1000000, 16, 4, 0, 4, 16, 1000000, 9, 1, 1, 9, 25, 16, 4 }; // user interface variables Options options; // database for command-line arguments int quietQ = 0; // display only data table or not int verboseQ = 1; // display only data table or not int compoundQ = 1; // used with the -c option double deltamin; // used with the --deltamin option double deltamax; // used with the --deltamax option double deltastep; // used with the --dstep option double lambdamin; // used with the --lambdamin option double lambdamax; // used with the --lambdamax option double lambdastep; // used with the --lstep option double sxmin; // used with the --sxmin option double sxmax; // used with the --sxmax option double xstep; // used with the --xstep option double sy; // used with the --sy 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 tonicscores; Array pitch; Array testset; Array duration; Array level; Array coef; int target = -1; // the correct root int targetindex = -1; // the correct root's index in the pitches array int i, root; double ewt, rwt; double a, b, c; double az, bz, cz; az = xstep/1000; bz = deltastep/1000; cz = lambdastep/1000; for (i=0; i& coef) { int secondbest = 0; if (coef.getSize() < 2) { return 0.0; } if (bestindex == 0) { secondbest = 1; } else { secondbest = 0; } int i; for (i=0; i& pitch, Array& duration, Array& level, Array& testset, double sx, double e1, double e2, Array& coef) { double suma; double sumb; coef.setSize(testset.getSize()); int rootindex = 0; double normvalue; double sxsq = sx * sx; int min = 0; int i, j; for (i=0; i& pitches, Array& testset, Array& durations, Array& levels, int& target, int& targetindex) { pitches.setSize(0); durations.setSize(0); levels.setSize(0); pitches.allowGrowth(1); durations.allowGrowth(1); levels.allowGrowth(1); Array scorelevels; infile.analyzeMetricLevel(scorelevels); int firsttime = 1; int i, j, k; int ii, jj; int ccount; static char buffer[1024] = {0}; int pitch; double duration; double level; for (i=0; i nodoubles(testset.getSize()); nodoubles.setSize(0); nodoubles.append(testset[0]); for (i=1; i *((int*)b)) { return 1; } else { return 0; } } ////////////////////////////// // // findMinimum -- // int findMinimum(Array& values) { int i; int min = 0; for (i=1; i