// // Programmer: Craig Stuart Sapp // Creation Date: Wed Nov 29 19:55:27 PST 2000 // Last Modified: Wed Nov 29 19:55:30 PST 2000 // Filename: ...sig/examples/all/atakcent.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/atakcent.cpp // Syntax: C++; museinfo // // Description: Determination of attack accentuation. // // #include "humdrum.h" #include #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); int doublecompare (const void* a, const void* b); void example (void); void generateSummary (HumdrumFile& infile, Array& atakcent); void insertdata (double beat, int value, Array& beatlocation, Array& occurance, Array& sum); void intialize (Array& beatlocation, Array& occurance, Array& sum); void printAnalysis (HumdrumFile& infile, Array& atakcent); void printSummary (double lasttop, double lastbottom, Array& beatlocation, Array& occurance, Array& sum); void usage (const char* command); // 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 int summaryQ = 0; // used with the -s option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array atakcent; // 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 *((double*)b)) { return 1; } else { return 0; } } ////////////////////////////// // // example -- example usage of the maxent program // void example(void) { cout << " \n" << endl; } ////////////////////////////// // // generateSummary -- // void generateSummary(HumdrumFile& infile, Array& atakcent) { int line; Array top; Array bottom; double lasttop = -1.0; double lastbottom = -1.0; Array beatlocation; Array occurance; Array sum; infile.analyzeRhythm(); intialize(beatlocation, occurance, sum); infile.analyzeMeter(top, bottom); for (line=0; line& beatlocation, Array& occurance, Array& sum) { int i; int foundQ = 0; int index = -1; for (i=0; i& beatlocation, Array& occurance, Array& sum) { beatlocation.setSize(0); occurance.setSize(0); sum.setSize(0); beatlocation.allowGrowth(1); occurance.allowGrowth(1); sum.allowGrowth(1); } ////////////////////////////// // // printAnalysis -- // void printAnalysis(HumdrumFile& infile, Array& atakcent) { int i; if (appendQ) { for (i=0; i& beatlocation, Array& occurance, Array& sum) { if (beatlocation.getSize() == 0) { return; } Array sortbeat = beatlocation; qsort(sortbeat.getBase(), sortbeat.getSize(), sizeof(double), doublecompare); cout << "*M" << lasttop << "/" << 4.0/lastbottom << endl; int index, sorti; int i; for (sorti=0; sorti