//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Mon Feb 7 20:57:12 PST 2005
// Last Modified: Mon Feb 7 20:57:15 PST 2005
// Filename: ...sig/examples/all/iweight.cpp
// Web Address: http://sig.sapp.org/examples/museinfo/humdrum/iweight.cpp
// Syntax: C++; museinfo
//
// Description: Generate a set of interval weights from a parameterize
// spatial configuration of pitches.
//
// Models: * Diatonic (slightly chromatic) the default method
// * Single-Angle chromatic -- -t option ranges from 0 degrees
// to 90 degrees. 0 degrees is equivalent to diatonic model.
// * Double-Angle chromatic -- -t options is the same as before,
// --t2 is the secondary angle from -45 to +45 degrees.
//
//
#include "humdrum.h"
// function declarations
void checkOptions(Options& opts, int argc, char* argv[]);
void example(void);
void usage(const char* command);
// global variables
Options options; // database for command-line arguments
int debugQ = 0; // used with the --debug option
double theta1 = 0.0; // used with the -t option
double theta2 = 0.0; // used with the -u option
int theta1Q = 0; // used with the -t option
int theta2Q = 0; // used with the -u option
double radius = 1.0; // used with the -r option
double height = 1.0; // used with the -h option
int radiusQ = 0; // used with the -r option
int heightQ = 0; // used with the -h option
///////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[]) {
// process the command-line options
checkOptions(options, argc, argv);
IntervalWeight iweights;
if (radiusQ && heightQ) {
iweights.setSpiral(radius, height);
cout << "!!!model: Spiral: radius = " << radius;
cout << " height = " << height << "\n";
} else if (!theta1Q && !theta2Q) {
iweights.setDiatonic();
cout << "!!!model: Diatonic\n";
} else if (theta1Q && !theta2Q) {
cout << "!!!model: Chromatic-1: theta = " << theta1;
cout << "\n";
iweights.setChromatic1(theta1);
} else if (theta1Q && theta2Q) {
cout << "!!!model: Chromatic-2: theta1 = " << theta1;
cout << " theta2 = " << theta2;
cout << "\n";
iweights.setChromatic2(theta1, theta2);
}
iweights.newprint(cout);
return 0;
}
///////////////////////////////////////////////////////////////////////////
//////////////////////////////
//
// checkOptions -- validate and process command-line options.
//
void checkOptions(Options& opts, int argc, char* argv[]) {
opts.define("t|theta|theta1=d:0.0", "theta1 for interval weight cals.");
opts.define("u|t2|theta2=d:0.0", "theta2 for interval weight calculations");
opts.define("r|radius=d:1.0", "radius of the Spiral Array");
opts.define("h|height=d:1.0", "quarter-height of the Spiral Array");
opts.define("debug=b", "trace input parsing");
opts.define("author=b", "author of the program");
opts.define("version=b", "compilation information");
opts.define("example=b", "example usage");
opts.define("help=b", "short description");
opts.process(argc, argv);
// handle basic options:
if (opts.getBoolean("author")) {
cout << "Written by Craig Stuart Sapp, "
<< "craig@ccrma.stanford.edu, Feb 2004" << endl;
exit(0);
} else if (opts.getBoolean("version")) {
cout << argv[0] << ", version: 7 Feb 2004" << endl;
cout << "compiled: " << __DATE__ << endl;
cout << MUSEINFO_VERSION << endl;
exit(0);
} else if (opts.getBoolean("help")) {
usage(opts.getCommand());
exit(0);
} else if (opts.getBoolean("example")) {
example();
exit(0);
}
theta1 = opts.getDouble("theta1");
theta2 = opts.getDouble("theta2");
theta1Q = opts.getBoolean("theta1");
theta2Q = opts.getBoolean("theta2");
radius = opts.getDouble("radius");
height = opts.getDouble("height");
radiusQ = opts.getBoolean("radius");
heightQ = opts.getBoolean("height");
}
//////////////////////////////
//
// example -- example usage of the program
//
void example(void) {
cout <<
" \n"
<< endl;
}
//////////////////////////////
//
// usage -- gives the usage statement for the program
//
void usage(const char* command) {
cout <<
" \n"
<< endl;
}
// md5sum: 9203439bed9e5f2a0b12c0943d4ce1dd iweights.cpp [20050403]