// // Programmer: Craig Stuart Sapp // Creation Date: Tue Dec 2 21:56:54 PST 2003 // Last Modified: Tue Dec 2 21:56:58 PST 2003 // Filename: ...sig/examples/all/beat.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/beat.cpp // Syntax: C++; museinfo // // Description: Measure the duration since the last note // of the pitch class. Idea of Max Mathews for // application in Director Musices for performance // rules of pitch novelty. // #include "humdrum.h" #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void printAnalysis (HumdrumFile& file, Array >& pastdur); void analyzeFile (HumdrumFile& infile, Array >& pastdur); double getAverage (HumdrumFile& infile, Array >& pastdist, double abeat, int index); // global variables Options options; // database for command-line arguments int appendQ = 0; // used with -a option int averageQ = 0; // used with -g option double averagebeat = 4.0; // used with -g option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; Array > pastdur; Array lines; // 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 >& pastdur) { infile.analyzeRhythm(); Array > notes; pastdur.setSize(infile.getNumLines()); notes.setSize(infile.getNumLines()); int i, j, k; for (i=0; i base40pc; base40pc.setSize(40); base40pc.setAll(-1.0); // -1 means that the note is the first to // be played on that pitch class in the piece Array oldbase40pc; oldbase40pc.setSize(40); oldbase40pc.setAll(-1.0); double curdur; // current beat location double dist; // distance to last pc int bpc; for (i=0; i >& pastdist, double abeat, int index) { int i, j; int count = 0; double sum = 0.0; double startdur = infile[index].getAbsBeat(); for (i=index; i>=0; i--) { if (startdur - infile[i].getAbsBeat() > abeat) { break; } for (j=0; j 0) { return sum/count; } return 0; } ////////////////////////////// // // printAnalysis -- does a nauty thing by possibly chaning input // parameter pastdist. // void printAnalysis(HumdrumFile& file, Array >& pastdist) { int i; int jj; Array average; average.setSize(file.getNumLines()); average.setAll(-1); if (averageQ) { for (i=0; i