// // Programmer: Craig Stuart Sapp // Creation Date: Tue Aug 2 13:23:45 PDT 2011 // Last Modified: Tue Aug 2 13:23:48 PDT 2011 // Filename: ...sig/examples/all/sprialfile.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/sprialfile.cpp // Syntax: C++; museinfo // // Description: Convert **kern data into sonorities for sprial analysis. // #include "humdrum.h" #include "PerlRegularExpression.h" #include #ifndef OLDCPP using namespace std; #include #else #include #endif /////////////////////////////////////////////////////////////////////////// // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void processFile (ostream& out, HumdrumFile& infile); void processDataLine (ostream& out, RationalNumber& rn, HumdrumFile& infile, int line); void addNotes (Array& notes, HumdrumFile& infile, int line, int spine); void printCurrentTime (ostream& out); // global variables Options options; // database for command-line arguments int debugQ; // used for debugging /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // process the command-line options checkOptions(options, argc, argv); string filename; infile.clear(); // if no command-line arguments read data file from standard input int numinputs = options.getArgCount(); if (numinputs < 1) { infile.read(cin); } else { filename = options.getArg(1); infile.read(filename.c_str()); } processFile(cout, infile); } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // processFile -- // void processFile(ostream& out, HumdrumFile& infile) { infile.analyzeRhythm(); RationalNumber rn = infile.getMinTimeBaseR(); int i; PerlRegularExpression pre; out << "--LINERHYTHM: " << rn << endl; for (i=0; itm_year + 1900 << "/"; if (current->tm_mon+1 < 10) { out << "0"; } out << current->tm_mon + 1 << "/"; if (current->tm_mday < 10) { out << "0"; } out << current->tm_mday << " "; if (current->tm_hour < 10) { out << "0"; } out << current->tm_hour << ":"; if (current->tm_min < 10) { out << "0"; } out << current->tm_min << ":"; if (current->tm_sec < 10) { out << "0"; } out << current->tm_sec << endl; } ////////////////////////////// // // processDataLine -- // void processDataLine(ostream& out, RationalNumber& rn, HumdrumFile& infile, int line) { RationalNumber linedur = infile[line].getDurationR(); RationalNumber zero(0,1); if (debugQ) { cout << "LINE DURATION = " << linedur << endl; } if (linedur == zero) { // grace note or other non-durational material. return; } int j; int ii, jj; Array notes; notes.setSize(0); RationalNumber repeat = (rn * linedur) / 4; if (repeat.getDenominator() != 1) { cout << "Something funny happend on repeater: " << repeat << endl; } for (j=0; j 0) { for (ii=0; ii& notes, HumdrumFile& infile, int line, int spine) { int k; int base40; char buffer[1024] = {0}; int tokens = infile[line].getTokenCount(spine); for (k=0; k