// // Programmer: Craig Stuart Sapp // Creation Date: Thu Jul 31 13:11:46 PDT 2014 // Last Modified: Thu Jul 31 13:11:49 PDT 2014 // Filename: ...sig/examples/all/melseq.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/melseq.cpp // Syntax: C++; museinfo // // Description: Generate melodic sequence information from // polyphonic music with monophic lines. // #include "humdrum.h" // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void processFile (HumdrumFile& infile); void printTrack (ostream& out, int voice, int vcount, int track, HumdrumFile& infile, int attribution, Array& genre); int getAttribution (HumdrumFile& infile); void getGenre (Array& genre, HumdrumFile& infile); int getTrackSpine (HumdrumFile& infile, int line, int track); // global variables Options options; // database for command-line arguments /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { checkOptions(options, argc, argv); HumdrumFileSet infiles; infiles.read(options); for (int i=0; i ktracks; infile.getTracksByExInterp(ktracks, "**kern"); int i; int size = ktracks.getSize(); int attribution = getAttribution(infile); Array genre; getGenre(genre, infile); for (i=size-1; i>=0; i--) { printTrack(cout, size-i, size, ktracks[i], infile, attribution, genre); } } ////////////////////////////// // // getGenre -- // void getGenre(Array& genre, HumdrumFile& infile) { PerlRegularExpression pre; int i; genre.setSize(0); for (i=0; i& genre) { infile.analyzeRhythm("4"); int i, j; PerlRegularExpression pre; string tag; if (pre.search(infile.getFilename(), "([A-Z][a-z][a-z]\\d{4}[^-]*)-")) { tag = pre.getSubmatch(1); } else if (pre.search(infile.getFilename(), "([A-Z][a-z][a-z]\\d{4}[^-]*)$")) { tag = pre.getSubmatch(1); } else { tag = infile.getFilename(); } out << tag << "\t"; if (attribution > 0) { cout << "*A" << attribution << " "; } out << "*V" << voice << "/" << vcount << " "; if (genre.getSize() > 0) { out << "*G" << genre << " "; } int restline = -1; int b40, lastb40 = -1; double time1, time2, rdur; int interval; for (i=0; i= 0) { time1 = infile[restline].getAbsBeat(); time2 = infile[i].getAbsBeat(); rdur = (time2 - time1)/2; out << "R" << rdur << " "; restline = -1; } if (lastb40 > 0) { interval = Convert::base40ToDiatonic(b40) - Convert::base40ToDiatonic(lastb40); if (interval >= 0) { interval += 1; } else if (interval < 0) { interval -= 1; } out << interval << " "; } lastb40 = b40; } } } out << "\n"; } ////////////////////////////// // // getTrackSpine -- Get the spine index for the given track number. // int getTrackSpine(HumdrumFile& infile, int line, int track) { int tr; for (int j=0; j