// // Programmer: Craig Stuart Sapp // Creation Date: Sun Feb 11 15:15:53 PST 2001 // Last Modified: Sat Feb 17 09:52:27 PST 2001 // Last Modified: Fri Apr 6 14:54:35 PDT 2001 (added revised algorithm) // Filename: ...sig/examples/all/keyscape.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/keyscape.cpp // Syntax: C++; museinfo // // Description: generate a key landscape picture or numeric data. // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void makeGrayscale (void); void processMatrix (Array& matrix); void printMatrix (Array& matrix); void printTriangle (Array& matrix); void printPPM (Array& matrix); void printAveragePPM (Array& matrix); // global variables Options options; // database for command-line arguments int debugQ = 0; // used with the --debug option int compoundQ = 1; // used with the -c option double empirical1 = -4; // used with the --e1 option double empirical2 = -3; // used with the --e2 option double sx = 0.578; // used with the --sx option double sy = 1.0; // used with the --sx option int ppmQ = 0; // used with the --ppm option int ppmWidth = 1000; // used with the -m option int ppmHeight = 500; // used with the -t option int linearQ = 0; // used with the -l option int monochromeQ = 0; // used with the -b option int matrixQ = 0; // used with the -x option int mirrorQ = 0; // used with the --mirror option int maxdivisions = -1; // used with the -d option int averageQ = 0; // used with the -a option int algorithm = 0; // used with the -2 option /////////////////////////////////////////////////////////////////////////// // Pitch to Color translations int red[40] = { 0, 9, 18, 0, 63, 63, 63, 73, 82, 0, 218, 237, 255, 255, 255, 255, 255, 255, 218, 182, 0, 45, 54, 63, 63, 63, 0, 109, 118, 127, 145, 164, 0, 255, 255, 255, 255, 255, 73, 36 }; int green[40] = { 255, 246, 237, 0, 123, 109, 95, 86, 77, 0, 9, 4, 0, 18, 36, 218, 237, 255, 255, 255, 0, 209, 200, 191, 177, 164, 0, 50, 41, 31, 27, 22, 0, 91, 109, 127, 145, 164, 255, 255 }; int blue[40] = { 0, 36, 73, 0, 255, 255, 255, 255, 255, 0, 73, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 182, 218, 255, 255, 255, 0, 255, 255, 255, 219, 182, 0, 0, 0, 0, 0, 0, 0, 0 }; /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // input Humdrum Format file Array rhylev; // storage for metrical level analysis Array tonicscores; // storage for root scores tonicscores.setSize(0); Array matrix; // storage for root analysis results // 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 && totalrows > maxdivisions) { totalrows = maxdivisions; } int j, k; matrix.setSize(totalrows); for (k=0; k& matrix) { int row, column; int maxrow = ppmHeight; int maxcolumn = ppmWidth; int size = matrix.getSize(); int i, j; int root; cout << "P3\n"; cout << maxcolumn << " " << maxrow << "\n"; cout << "255\n"; for (row=0; row= 0) { cout << red[root] << " " << green[root] << " " << blue[root] << " "; } else { cout << " 0 0 0 "; } } cout << "\n"; } } ////////////////////////////// // // printAveragePPM -- // void printAveragePPM(Array& matrix) { int row, column; int maxrow = ppmHeight; int maxcolumn = ppmWidth; int size = matrix.getSize(); int i, j; int root; cout << "P3\n"; cout << maxcolumn << " " << maxrow << "\n"; cout << "255\n"; Array redsum(maxcolumn); Array greensum(maxcolumn); Array bluesum(maxcolumn); redsum.allowGrowth(0); greensum.allowGrowth(0); bluesum.allowGrowth(0); redsum.zero(); greensum.zero(); bluesum.zero(); for (row=0; row= 0) { redsum[column] += red[root]; greensum[column] += green[root]; bluesum[column] += blue[root]; } } } for (i=0; i& matrix) { int i, j; int size = matrix.getSize(); for (i=0; i& matrix) { processMatrix(matrix); int i, j; int size = matrix.getSize(); for (i=0; i& matrix) { int i, j; int size = matrix.getSize(); for (i=0; i