// // Programmer: Craig Stuart Sapp // Creation Date: Thu Jan 20 15:21:48 PST 2011 // Last Modified: Thu Jan 20 15:21:50 PST 2011 // Filename: ...sig/examples/all/chordmark.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/chordmark.cpp // Syntax: C++; museinfo // // Description: Add marks to notes according to their triadic position // in a chord. // #include #ifndef OLDCPP #include #include #define SSTREAM stringstream #define CSTRING str().c_str() using namespace std; #else #include #ifdef VISUAL #include #else #include #endif #define SSTREAM strstream #define CSTRING str() #endif #include "humdrum.h" #include "PerlRegularExpression.h" ////////////////////////////////////////////////////////////////////////// // function declarations: void checkOptions (Options& opts, int argc, char** argv); void example (void); void usage (const char* command); void chordmark (HumdrumFile& infile); void printHexColor (double color); void printChordMarkInfo (Array& marklevel, Array >& levelcolor, Array& markused); int getRootTrack (HumdrumFile& infile); void markToken (HumdrumFile& infile, int line, int col, int root); void printSubToken (ostream& out, const char* token, int root); int updateRoot (HumdrumFile& infile, int line, int root, int track); // User interface variables: Options options; int debugQ = 0; // used with --debug option Array marklevel; Array markused; Array > levelcolor; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { HumdrumFile infile; // initial processing of the command-line options checkOptions(options, argc, argv); if (options.getArgCount() < 1) { infile.read(cin); } else { infile.read(options.getArg(1)); } chordmark(infile); cout << infile; printChordMarkInfo(marklevel, levelcolor, markused); return 0; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // printChordMarkInfo -- // void printChordMarkInfo(Array& marklevel, Array >& levelcolor, Array& markused) { int i; for (i=0; i 1.0) { color = 1.0; } if (color < 0.0) { color = 0.0; } int icol = (int)(255 * color); int digit1 = icol / 16; int digit2 = icol % 16; char buffer[32] = {0}; sprintf(buffer, "%x%x", digit1, digit2); cout << buffer; } ////////////////////////////// // // chordmark -- add an up/down stem on notes in **kern data which do not // already have stem information. // void chordmark(HumdrumFile& infile) { int roottrack = getRootTrack(infile); int curroot = -1; int i, j; for (i=0; i