// // Programmer: Craig Stuart Sapp // Creation Date: Thu Jan 29 16:16:33 PST 2009 // Last Modified: Thu Jan 29 16:16:38 PST 2009 // Filename: ...sig/examples/all/updown.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/updown.cpp // Syntax: C++; museinfo // // Description: Identifies when there are m notes which rise in // in pitch, followed by n notes falling in pitch. // // four types of outputs can be given: // -u = specifies the number up expected ascending pitches // -d = specifies the number up expected descending pitches // -i = ignore repeated notes // #include "humdrum.h" // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void generateData (HumdrumFile& infile, Array& pitches, Array& lines, Array& measures, int ignorerepeat); void analyzeData (Array& matchstart, Array& pitches, int upcount, int downcount); void printAnalysis (Array& matchstart, HumdrumFile& infile, Array& pitches, Array& lines, Array& measures, int upcount, int downcount); int getFirstKernColumn (HumdrumFile& infile, int index); void printMatchSequence (Array& pitches, int startindex, int count); // global variables Options options; // database for command-line arguments int debugQ = 0; // set with --debug int risecount = 5; // set with -u option int fallcount = 5; // set with -d option int ignorerepeat = 0; // set with -i option /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); Array pitches; // list of pitches in melody Array lines; // list of lines in input file for pitches Array measures; // list of measures for pitches Array matchstart; // list of measures for pitches for (int i=0; i& pitches, Array& lines, Array& measures, int ignorerepeat) { // pre-allocate maximum array sizes: pitches.setSize(infile.getNumLines()); lines.setSize(infile.getNumLines()); measures.setSize(infile.getNumLines()); pitches.setSize(0); lines.setSize(0); measures.setSize(0); int currmeas = 0; int apitch = 0; int col = 0; int i; for (i=0; i& matchstart, Array& pitches, int upcount, int downcount) { matchstart.setSize(pitches.getSize()); matchstart.setSize(0); Array intervals; intervals.setSize(pitches.getSize()-1); int i, j; for (i=0; i= 0) { success = 0; break; } } } if (success) { matchstart.append(i); if (debugQ) { cout << "MATCH at index " << i << endl; } } } } ////////////////////////////// // // printAnalysis -- print the Analysis results. // void printAnalysis(Array& matchstart, HumdrumFile& infile, Array& pitches, Array& lines, Array& measures, int upcount, int downcount) { // analyze the input file according to command-line options infile.analyzeRhythm(); int i; for (i=0; i& pitches, int startindex, int count) { int i; char buffer[1024] = {0}; cout << "["; for (i=0; i