// // Programmer: Craig Stuart Sapp // Creation Date: Tue Jan 16 11:25:31 PST 2001 // Last Modified: Wed Jan 17 10:16:23 PST 2001 // Filename: ...sig/examples/all/vroot.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/vroot.cpp // Syntax: C++; museinfo // // Description: determine the chord at a given metric level // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); int findMinimum (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 rval = 1.0; // used with the -r option int srhythm = 4; // used with the -r option double empirical1 = -5.8; // used with the --e1 option double empirical2 = 2.225; // used with the --e2 option double sx = 1.0; // used with the --sx option double sy = 1.0; // used with the --sx option int octave = -1; // used with the -o option /////////////////////////////////////////////////////////////////////////// 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}; char buffer2[128] = {0}; Array tonicscores; for (int i=0; i= infile.getNumLines()) { endline = infile.getNumLines() - 1; } most = infile.analyzeChordProbability(values, line, endline - 1, rhylev, empirical1, empirical2, sx, sy); if (octave < 0) { nextroot = (most + 2) % 40 + 80; if (abs(nextroot + 40 - lastroot) < 13) { nextroot += 40; } else if (abs(nextroot - 40 - lastroot) < 13) { nextroot -= 40; } } else { nextroot = (most + 2) % 40 + 40 * octave; } Convert::base40ToKern(buffer, nextroot); lastroot = nextroot; cout << "\t"; if (infile[line].getDuration() > 1.0/rval) { cout << Convert::durationToKernRhythm(buffer2, infile[line].getDuration()); } else { cout << srhythm; } if (values[most] == 0) { cout << "r"; } else { cout << buffer; } // cout << " [" << line << ", " << endline-1 << "]"; cout << endl; } else { cout << "\t." << endl; } } } return 0; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // findMinimum -- // int findMinimum(Array& values) { int i; int min = 0; for (i=1; i