Example #1
0
void removeStems(ostream& out, HumdrumFile& infile) {
	int i, j;
	PerlRegularExpression pre;
	string buffer;
	buffer.resize(1024);

	for (i=0; i<infile.getNumLines(); i++) {
		if (!infile[i].isData()) {
			out << infile[i] << "\n";
			continue;
		}
		for (j=0; j<infile[i].getFieldCount(); j++) {
			if (!infile[i].isExInterp(j, "**kern")) {
				out << infile[i][j];
				if (j < infile[i].getFieldCount()-1) {
					out << "\t";
				}
				continue;
			}
			buffer = infile[i][j];
			if (removeallQ || overwriteallQ) {
				pre.sar(buffer, "[\\\\/]x(?!x)", "", "g");
				pre.sar(buffer, "[\\\\/](?!x)", "", "g");
			} else {
				pre.sar(buffer, "[\\\\/](?!x)", "", "g");
			}
			out << buffer;
	
			if (j < infile[i].getFieldCount()-1) {
				out << "\t";
			}
		}
		out << "\n";
	}
}
Example #2
0
void checkOptions(Options& opts, int argc, char* argv[]) {
	opts.define("p|parens=b", "print parentheses around dittox data");
	opts.define("r|rhythm=b", "print keeping kern data rhythm parseable");
	opts.define("c|char|chars=s:[rA-Ga-g#-]",
	                            "print only characters in list when dittoing");
	opts.define("C|xchar|xchars=s", "remove characters in list when dittoing");
	opts.define("k|kern|pitches=b", "print only pitch names in **kern data");

	opts.define("author=b");                     // author of program
	opts.define("version=b");                    // compilation info
	opts.define("example=b");                    // example usages
	opts.define("h|help=b");                     // short description
	opts.process(argc, argv);

	// handle basic options:
	if (opts.getBoolean("author")) {
		cout << "Written by Craig Stuart Sapp, "
			  << "[email protected], Nov 2000" << endl;
		exit(0);
	} else if (opts.getBoolean("version")) {
		cout << argv[0] << ", version: 14 Nov 2000" << endl;
		cout << "compiled: " << __DATE__ << endl;
		cout << MUSEINFO_VERSION << endl;
		exit(0);
	} else if (opts.getBoolean("help")) {
		usage(opts.getCommand());
		exit(0);
	} else if (opts.getBoolean("example")) {
		example();
		exit(0);
	}

	parensQ  = opts.getBoolean("parens");
	rhythmQ  = opts.getBoolean("rhythm");

	PerlRegularExpression pre;
	charQ    = opts.getBoolean("char");
	if (charQ) {
		charString = opts.getString("char");
		if (!pre.search(charString, "^\\[")) {
			pre.sar(charString, "^", "[");
			pre.sar(charString, "$", "]");
		}
		pre.sar(charString, "^\\[", "[^");
	}

	xcharQ    = opts.getBoolean("xchar");
	if (xcharQ) {
		xcharString = opts.getString("xchar");
		if (!pre.search(xcharString, "^\\[")) {
			pre.sar(xcharString, "^", "[");
			pre.sar(xcharString, "$", "]");
		}
	}

	if (opts.getBoolean("kern")) {
		charString = "[^rA-Ga-g#-]";
		charQ = 1;
	}
}
Example #3
0
void removeStem2(HumdrumFile& infile, int row, int col) {
	PerlRegularExpression pre;
	string strin = infile[row][col];
	pre.sar(strin, "[\\\\/]x(?!x)", "", "g");
	pre.sar(strin, "[\\\\/](?!x)", "", "g");
	infile[row].setToken(col, strin.c_str());
}
Example #4
0
void printFields(ostream& out, HumdrumFile& infile, int line) {
   out << "<tr class=\"hi\" valign=baseline>";
   int& i = line;
   int j;
   int track;
   int counter;
   int subtracks;
   PerlRegularExpression pre;
   Array<char> strang;

   for (track=1; track<=infile.getMaxTracks(); track++) {
      subtracks = getSubTracks(infile, line, track);
      out << "<td>";
      if (subtracks > 1) {
         out << "<table " << C0C0 << "><tr valign=top";
         if (infile[i].isMeasure()) {
            out << " bgcolor=#eeeeee ";
         }
         out << ">";
         counter = 0;
         for (j=0; j<infile[i].getFieldCount(); j++) {
            if (infile[i].getPrimaryTrack(j) == track) {
               strang.setSize(strlen(infile[i][j])+1);
               strcpy(strang.getBase(), infile[i][j]); 
               pre.sar(strang, " ", "&nbsp;", "g");
               if (pre.search(strang, "^\\*>.*\\[", "")) {
                  addLabelHyperlinks(strang);
               } else if (pre.search(strang, "^\\*>", "")) {
                  addLabelHyperlinkName(strang);
               }
               out << "<td width=" << TOKENWIDTH << ">" << strang << "</td>";
               counter++;
               if (counter < subtracks) {
                  out << "<td width=" << TDSEP << "></td>";
               }
            }
         }
         out << "</tr></table>\n";
      } else {
         for (j=0; j<infile[i].getFieldCount(); j++) {
            if (infile[i].getPrimaryTrack(j) == track) {
               strang.setSize(strlen(infile[i][j])+1);
               strcpy(strang.getBase(), infile[i][j]); 
               pre.sar(strang, " ", "&nbsp;", "g");
               if (pre.search(strang, "^\\*>.*\\[", "")) {
                  addLabelHyperlinks(strang);
               } else if (pre.search(strang, "^\\*>", "")) {
                  addLabelHyperlinkName(strang);
               }
               out << strang;
            }
         }
      }
      out << "</td>";
   }
   out << "</tr>\n";
}
Example #5
0
void removeStem2(HumdrumFile& infile, int row, int col) {
   Array<char> strin;
   int len = strlen(infile[row][col]);
   strin.setSize(len+1);
   strcpy(strin.getBase(), infile[row][col]);
   PerlRegularExpression pre;
   pre.sar(strin, "[\\\\/]x(?!x)", "", "g");
   pre.sar(strin, "[\\\\/](?!x)", "", "g");
   infile[row].setToken(col, strin.getBase());
}
Example #6
0
void printOutput(HumdrumFile& infile) {
	int i, j;
	string data;
	PerlRegularExpression pre;
	infile.printNonemptySegmentLabel(cout);
	for (i=0; i<infile.getNumLines(); i++) {
		if (infile[i].getType() && (E_humrec_data == 0)) {
			cout << infile[i].getLine() << "\n";
		} else {
			for (j=0; j<infile[i].getFieldCount(); j++) {
				if (strcmp(infile[i][j], ".") == 0) {
					if (parensQ) {
						cout << "(";
					}
					data = infile.getDotValue(i, j);

					if (charQ) {
						pre.sar(data, charString, "", "g");
					}

					if (xcharQ) {
						pre.sar(data, xcharString, "", "g");
					}

					if (data == "") {
						data = ".";
					}
					cout << data;
					if (parensQ) {
						cout << ")";
					}
				} else {
					cout << infile[i][j];
				}
				if (j < infile[i].getFieldCount() - 1) {
					cout << "\t";
				}
			}
			cout << "\n";
		}
	}
}
Example #7
0
void readEditWeights(const char* filename) {
   #ifndef OLDCPP
      ifstream weightfile(filename, ios::in);
   #else
      ifstream weightfile(filename, ios::in | ios::nocreate);
   #endif

   if (weightfile.eof()) {
      cerr << "Error opening weightfile file: " << filename << endl;
      exit(1);
   }

   PerlRegularExpression pre;
   PerlRegularExpression pre2;

   Array<char> storage;
   char buffer[1024] = {0};
   int strsize;

   weightfile.getline(buffer, 1024);
   while (!weightfile.eof()) {
      strsize = strlen(buffer);
      storage.setSize(strsize+1);
      strcpy(storage.getBase(), buffer);
      weightfile.getline(buffer, 1024);
      pre.sar(storage, "\\s*#.*", "", "");
      if (pre.search(storage, 
            "^\\s*(d1|d2|r1|r2|s0|s1|s2|s3)\\s+([\\d.+\\-]+)", "i")) {
         if (pre2.search(pre.getSubmatch(1), "D1", "i")) {
            weight_D1 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "D2", "i")) {
            weight_D2 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "R1", "i")) {
            weight_R1 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "R2", "i")) {
            weight_R2 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "S0", "i")) {
            weight_S0 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "S1", "i")) {
            weight_S1 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "S2", "i")) {
            weight_S2 = atof(pre.getSubmatch(2));
         } else if (pre2.search(pre.getSubmatch(1), "S3", "i")) {
            weight_S3 = atof(pre.getSubmatch(2));
         }
      }
   }

   weightfile.close();
}
Example #8
0
const char* MuseData::getPartName(char* buffer, int maxx) {
   buffer[0] = '\0';
   Array<char> output;
   int line = getPartNameIndex();
   if (line < 0) {
      return buffer;
   }
   PerlRegularExpression pre;
   output.setSize(strlen(data[line]->getLine())+1);
   strcpy(output.getBase(), data[line]->getLine());
   pre.sar(output, "^\\s+", "", "");
   pre.sar(output, "\\s+$", "", "");
   strncpy(buffer, output.getBase(), maxx);


   Array<char> instrument;
   instrument.setSize(strlen(buffer)+1);
   strcpy(instrument.getBase(), buffer);
   pre.sar(instrument, "^\\s*", "", "");
   pre.sar(instrument, "\\s*$", "", "");
   strcpy(buffer, instrument.getBase());

   return buffer;
}
Example #9
0
void printNotePositions(HumdrumFile& infile, 
		vector<vector<vector<int> > >& notepos) {

	PerlRegularExpression pre;
	string data;
	stringstream *pstream;


	int i, j, k;
	for (i=0; i<infile.getNumLines(); i++) {
		if (!(infile[i].isData() || infile[i].isLocalComment() ||
				infile[i].isMeasure() || infile[i].isInterpretation())) {
				cout << infile[i] << "\n";
				continue;
		}
		cout << infile[i] << "\t";
		if (infile[i].isMeasure()) {
				cout << infile[i][0] << "\n";
				continue;
		}
		if (infile[i].isLocalComment()) {
				cout << "!\n";
				continue;
		}
		if (infile[i].isInterpretation()) { 
				if (strncmp(infile[i][0], "**", 2) == 0) {
				cout << "**vpos";
				} else if (strcmp(infile[i][0], "*-") == 0) {
				cout << "*-";
				} else {
				cout << "*";
				}
				cout << "\n";
				continue;
		}
		pstream = new stringstream;
		for (j=0; j<infile[i].getFieldCount(); j++) {
				if (!infile[i].isExInterp(j, "**kern")) {
				continue;
				}
				if (strcmp(infile[i][j], ".") == 0) {
				// ignore null tokens
				continue;
				}
				if (strchr(infile[i][j], 'r') != NULL) {
				// ignore rests
				continue;
				}
				for (k=0; k<(int)notepos[i][j].size(); k++) {
				(*pstream) << notepos[i][j][k];
				if (k < (int)notepos[i][j].size()-1) {
					(*pstream) << " ";
				}
				}
				(*pstream) << " ";
		}
		(*pstream) << ends;
		data = pstream->str();
		pre.sar(data, "\\s+$", "", "");
		if (data.empty()) {
				pre.sar(data, "^\\s*$", ".");
		}
		cout << data;
		cout << "\n";
		delete pstream;
		pstream = NULL;
	}
}
Example #10
0
void printNotePositions(HumdrumFile& infile, 
      Array<Array<Array<int> > >& notepos) {

   PerlRegularExpression pre;
   Array<char> data;
   SSTREAM *pstream;


   int i, j, k;
   for (i=0; i<infile.getNumLines(); i++) {
      if (!(infile[i].isData() || infile[i].isLocalComment() ||
            infile[i].isMeasure() || infile[i].isInterpretation())) {
         cout << infile[i] << "\n";
         continue;
      }
      cout << infile[i] << "\t";
      if (infile[i].isMeasure()) {
         cout << infile[i][0] << "\n";
         continue;
      }
      if (infile[i].isLocalComment()) {
         cout << "!\n";
         continue;
      }
      if (infile[i].isInterpretation()) { 
         if (strncmp(infile[i][0], "**", 2) == 0) {
            cout << "**vpos";
         } else if (strcmp(infile[i][0], "*-") == 0) {
            cout << "*-";
         } else {
            cout << "*";
         }
         cout << "\n";
         continue;
      }
      pstream = new SSTREAM;
      for (j=0; j<infile[i].getFieldCount(); j++) {
         if (!infile[i].isExInterp(j, "**kern")) {
            continue;
         }
         if (strcmp(infile[i][j], ".") == 0) {
            // ignore null tokens
            continue;
         }
         if (strchr(infile[i][j], 'r') != NULL) {
            // ignore rests
            continue;
         }
         for (k=0; k<notepos[i][j].getSize(); k++) {
            (*pstream) << notepos[i][j][k];
            if (k < notepos[i][j].getSize()-1) {
               (*pstream) << " ";
            }
         }
         (*pstream) << " ";
      }
      (*pstream) << ends;
      data.setSize(strlen(pstream->CSTRING) + 1);
      strcpy(data.getBase(), pstream->CSTRING);
      pre.sar(data, "\\s+$", "", "");
      if (strlen(data.getBase()) == 0) {
         pre.sar(data, "^\\s*$", ".");
      }
      cout << data.getBase();
      cout << "\n";
      delete pstream;
      pstream = NULL;
   }
}
Example #11
0
int setNewDuration(HumdrumFile& infile, int line, int col, 
   RationalNumber& newdur, int order, int tiestate) {

   PerlRegularExpression pre;
   Array<char> token;
   token = infile[line][col];
   char buffer[1024] = {0};
   Convert::durationRToKernRhythm(buffer, newdur);
   pre.sar(token, "[\\d%.]+", buffer, "g");
   infile[line].setToken(col, token.getBase());
   if (strchr(infile[line][col], 'r') != NULL) {
      // don't care about ties for rests
      return 0;
   }

   if (order < 0) {
      tiestate = 0;
      // Starting note which will be tied to the next note.
      // If the note is the start or a continue of a tie, then
      // set tiestate to 1:
      if (pre.search(infile[line][col], "[_[]")) {
      }
      if (pre.search(infile[line][col], "[[]")) {
         // start of a tie, so don't alter that
         return 1;
      } else if (pre.search(infile[line][col], "_")) {
         // continuation of a tie, so don't alter that
         return 1;
      } else if (pre.search(infile[line][col], "[]]")) {
         // end of a tie so convert "]" to "_" and tell
         // second note to terminate the tie.
         pre.sar(token, "[]]", "_", "g");
         infile[line].setToken(col, token.getBase());
         return -1;
      } else {
         // Not in a tie group, so start one, and tell the
         // second note to terminate it.
         pre.sar(token, " ", " [", "g");
         pre.sar(token, "^", "[", "");
         infile[line].setToken(col, token.getBase());
         return -1;
      }
   } else if (order > 0) {
      // Ending note.  If tiestate == 1, then this note should 
      // continue a tie.  If tiestate == -1, then this note should
      // terminate a tie.
      pre.sar(token, "[_\\][]", "", "g");
      if (tiestate == 1) {
         // continue tie
         pre.sar(token, " ", "_ ", "g");
         pre.sar(token, "$", "_", "");
         infile[line].setToken(col, token.getBase());
         return 0;
      } else if (tiestate == -1) {
         // end tie
         pre.sar(token, " ", "] ", "g");
         pre.sar(token, "$", "]", "");
         infile[line].setToken(col, token.getBase());
         return 0;
      } else {
         cerr << "Error: should not get here" << endl;
         exit(1);
      }
   }

   cerr << "Error: should not get here 2" << endl;
   return 0;
}
Example #12
0
void cleanUpBeams(char* prebuffer, char* postbuffer, int level) {
   if (level < 1) {
      return;
   }

   int kcount1 = 0;
   int Kcount1 = 0;
   int Lcount1 = 0;
   int Jcount1 = 0;

   int kcount2 = 0;
   int Kcount2 = 0;
   int Lcount2 = 0;
   int Jcount2 = 0;

   int len1 = strlen(prebuffer);
   int len2 = strlen(postbuffer);

   int i;

   for (i=0; i<len1; i++) {
      switch (prebuffer[i]) {
         case 'k': kcount1++; break;
         case 'K': Kcount1++; break;
         case 'L': Lcount1++; break;
         case 'J': Jcount1++; break;
      }
   }

   for (i=0; i<len2; i++) {
      switch (postbuffer[i]) {
         case 'k': kcount2++; break;
         case 'K': Kcount2++; break;
         case 'L': Lcount2++; break;
         case 'J': Jcount2++; break;
      }
   }

   Array<char> prestring;
   Array<char> poststring;

   prestring.setSize(len1+1);
   strcpy(prestring.getBase(), prebuffer);

   poststring.setSize(len1+1);
   strcpy(poststring.getBase(), postbuffer);

   PerlRegularExpression pre;

   if ((level == 1) && (Lcount1 > 0)) {
      pre.sar(prestring, "L", "");
      level--;
   } else if ((level == 1) && (Jcount1 > 0)) {
      pre.sar(prestring, "J", "");
      level--;
   } else if ((level == 1) && (Lcount2 > 0)) {
      pre.sar(prestring, "L", "");
      level--;
   } else if ((level == 1) && (Jcount2 > 0)) {
      pre.sar(prestring, "J", "");
      level--;
   } else if ((level == 2) && (Lcount1 > 1)) {
      pre.sar(prestring, "L", "");
      pre.sar(prestring, "L", "");
      level -= 2;
   } else if ((level == 2) && (Jcount1 > 1)) {
      pre.sar(prestring, "J", "");
      pre.sar(prestring, "J", "");
      level -= 2;
   } else if ((level == 2) && (Lcount2 > 1)) {
      pre.sar(prestring, "L", "");
      pre.sar(prestring, "L", "");
      level -= 2;
   } else if ((level == 2) && (Jcount2 > 1)) {
      pre.sar(prestring, "J", "");
      pre.sar(prestring, "J", "");
      level -= 2;
   }

   // deal with k and K later...

   strcpy(prebuffer, prestring.getBase());
   strcpy(postbuffer, poststring.getBase());
}
Example #13
0
void printKernTokenLineDuration(HumdrumFile& infile, int line, int field) {
	RationalNumber notestartabsbeat; // starting absbeat of note
	RationalNumber noteendabsbeat;   // ending absbeat of note
	RationalNumber linedur;          // absbeat of current line
	RationalNumber notedur;          // duration of note
	int ii, jj;
	linedur = infile[line].getDurationR();
	string notebuffer;
	if (linedur == 0) {
		// don't bother with grace notes for now:
		cout << infile[line][field];
	}
	ii = line;
	jj = field;
	if (infile[line].isNullToken(field)) {
		ii = infile[line].getDotLine(field);
		jj = infile[line].getDotField(field);
	}
	PerlRegularExpression pre;
	RationalNumber linestartabsbeat = infile[line].getAbsBeatR();
	notestartabsbeat = infile[ii].getAbsBeatR();
	RationalNumber lineendabsbeat;
	char newdur[1024] = {0};
	lineendabsbeat = linestartabsbeat + linedur;
	notedur = Convert::kernToDurationR(infile[ii][jj]);
	if (notedur == linedur) {
		cout << infile[ii][jj];
		return;
	}
	noteendabsbeat = notestartabsbeat + notedur;
	Convert::durationToKernRhythm(newdur, linedur.getFloat());
	notebuffer = infile[ii][jj];
	pre.sar(notebuffer, "[\\d%.]+", newdur, "g");

	// handle tie structure:
	//   Chord notes are all presumed to be tied in the same way.  This
	//   may not be true, so to be fully generalized, keeping track
	//   of the tie states of notes in the chord should be done.

	// * If the original note duration is the same as the line duration
	//   just keep the original note (already taken care of above).

	// * If the note starts at this point, then add a "[" tie marker
	//   if there is not a "[" or "_" character already on the note(s)
	if ((notestartabsbeat == linestartabsbeat)
			&& (strchr(infile[ii][jj], '[') == NULL)
			&& (strchr(infile[ii][jj], '_') == NULL)) {
		pre.sar(notebuffer, " ", " [", "g");
		cout << "[" << notebuffer;
		return;
	}

	// * If the linenote ends on this line, add "]" unless the original
	//   note had "_".
	if (lineendabsbeat == noteendabsbeat) {
		if (strchr(infile[ii][jj], '_') != NULL) {
			cout << notebuffer;
		} else if (strchr(infile[ii][jj], '[') != NULL) {
			pre.sar(notebuffer, "\\[", "", "g");
			pre.sar(notebuffer, " ", "_ ", "g");
			cout << notebuffer << "_";
		} else {
			pre.sar(notebuffer, "\\[", "", "g");
			pre.sar(notebuffer, " ", "\\] ", "g");
			cout << notebuffer << "]";
		}
		return;
	}


	if (notebuffer.find('[') != std::string::npos) {
		cout << notebuffer;
	} else {
		pre.sar(notebuffer, " ", "_ ", "g");
		cout << notebuffer << "_";
	}
}
Example #14
0
ostream& printScoreInformation(ostream& out, HumdrumFile& infile) {
   int otl = -1;
   int opr = -1;
   int com = -1;
   int omd = -1;
   int yec = -1;
   int dataQ = 0;
   int i;
   char key[1024] = {0};

   PerlRegularExpression pre;

   for (i=0; i<infile.getNumLines(); i++) {
      if (!infile[i].isBibliographic()) {
         continue;
      }
      infile[i].getBibKey(key);
      if ((otl < 0) && pre.search("^OTL", key)) {
         otl = i; dataQ = 1; continue;
      }
      if ((opr < 0) && pre.search("^OPR", key)) {
         opr = i; dataQ = 1; continue;
      }
      if ((omd < 0) && pre.search("^OMD", key)) {
         omd = i; dataQ = 1; continue;
      }
      if ((com < 0) && pre.search("^COM", key)) {
         com = i; dataQ = 1; continue;
      }
      if ((yec < 0) && pre.search("^YEC", key)) {
         yec = i; dataQ = 1; continue;
      }
   }
 

   if (!dataQ) {
      return out;
   }
   
   indent(out, LEVEL++);
   out << ":catalog-info (" << endl;

   Array<char> value1;
   Array<char> value2;
  
   if (opr >= 0) {
      if (otl >= 0) {
         infile[opr].getBibValue(value1);
         infile[otl].getBibValue(value2);
         pre.sar(value1, "\"", "\'", "g");
         pre.sar(value2, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:title \"";
         out << value1;
         out << "\")" << endl;

         indent(out, LEVEL);
         out << "(:subtitle \"";
         out << value2;
         out << "\")" << endl;
      } else {
         infile[opr].getBibValue(value1);
         pre.sar(value1, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:title \"";
         out << value1;
         out << "\")" << endl;
      }
   } else if (otl >= 0) {
         infile[otl].getBibValue(value1);
         pre.sar(value1, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:title \"";
         out << value1;
         out << "\")" << endl;
   }

   if (com >= 0) {
         infile[com].getBibValue(value1);
         pre.sar(value1, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:composer \"";
         out << value1;
         out << "\")" << endl;
   }

   if (omd >= 0) {
         infile[omd].getBibValue(value1);
         pre.sar(value1, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:tempo-heading \"";
         out << value1;
         out << "\")" << endl;
   }

   if (yec >= 0) {
         infile[yec].getBibValue(value1);
         pre.sar(value1, "\"", "\'", "g");

         indent(out, LEVEL);
         out << "(:copyright \"";
         out << value1;
         out << "\")" << endl;
   }



   indent(out, --LEVEL);
   out << ")" << endl;

   return out;
}
Example #15
0
void processDynamicSpine(HumdrumFile& infile, int track) {
   Array<Array<Coord> > data;
   storeDynamSpine(data, infile, track);
   int i;
   int ii, jj;
   int crescX       = 0;  // interpreted crescendo (cresc. word)
   int decrescX     = 0;  // interpreted decrescendo (decresc. word)
   int crescy       = 0;  // hidden crescendo
   int decrescy     = 0;  // hidden decrescendo
   int crescState   = 0;  // active crescendo
   int decrescState = 0;  // active decrescendo
   char buffer[1024] = {0};
   Array<char> buf;
   PerlRegularExpression pre;

   int xx, yy;

   if (debugQ) {
      cerr << "DATA SIZE = " << data.getSize() << endl;
   }

   for (i=0; i<data.getSize(); i++) {
      ii = data[i][0].i;
      jj = data[i][0].j;

      if (debugQ) {
         cerr << "PROCESSING I = " << i << " " << infile[ii][jj] << endl;
      }
      if (crescState) {
         if (debugQ) {
            cerr << "\tACTIVE CRESC" << endl;
         }
         // if currently a crescendo, then either continue or end
         if (strcmp(infile[ii][jj], ".") == 0) {
            // convert "." to "(" to continue the crescendo
            if (debugQ) {
               cerr << "\tChanging . to (" << endl;
            }
            strcpy(buffer, "(");
            if (crescX) {
               strcat(buffer, "X");
            }
            if (crescy) {
               strcat(buffer, "yy");
            }
            infile[ii].changeField(jj, buffer);
         } else {
            // end the crescendo
            xx = data[i-1][0].i;
            yy = data[i-1][0].j;
            if (debugQ) {
               cerr << "GOT HERE " << infile[xx][yy] << endl;
            }
            if ((xx < 0) || (yy < 0)) {
               continue;
            }
            // this is a dynamic object of some sort so terminate
            // the crescendo on the previous item
            if (strchr(infile[xx][yy], '(') != NULL) {
               if (debugQ) {
                  cerr << "GOT HERE " << infile[xx][yy] << endl;
               }
               // replace the '(' found on the previous data line
               buf.setSize(strlen(infile[xx][yy])+1);
               strcpy(buf.getBase(), infile[xx][yy]);
               pre.sar(buf, "\\(", "[", "");  // should only apply to last 
               if (crescX) {
                  pre.sar(buf, "\\[", "[", "");
                  crescX = 0;
               }
               if (crescy) {
                  pre.sar(buf, "\\[", "[", "");
                  crescy = 0;
               }
               infile[xx].changeField(yy, buf.getBase());
               crescState = 0;
               if (debugQ) {
                  cerr << "DEACTIVATING CRESC 1" << endl;
               }
            } else {
               // there is something other than ( on the last line:
               // append " ["
               strcpy(buffer, infile[xx][yy]);
               strcat(buffer, " [");
               //if (crescy) { 
               //   strcat(buffer, "yy");
               //   crescy = 0;
               //} if (crescX) { 
               //   strcat(buffer, "X");
               //   crescX = 0;
               //}
               infile[xx].changeField(yy, buffer);
               crescState = 0;
               if (debugQ) {
                  cerr << "DEACTIVATING CRESC 2" << endl;
               }
            }
         }

      } else if (decrescState) {

         // if currently a decrescendo, then either continue or end
         if (strcmp(infile[ii][jj], ".") == 0) {
            // convert "." to "(" to continue the decrescendo
            strcpy(buffer, ")");
            if (decrescX) {
               strcat(buffer, "X");
            }
            if (decrescy) {
               strcat(buffer, "yy");
            }
            infile[ii].changeField(jj, buffer);
         } else {
            // end the decrescendo
            xx = data[i-1][0].i;
            yy = data[i-1][0].j;
            if ((xx < 0) || (yy < 0)) {
               continue;
            }
            // this is a dynamic object of some sort so terminate
            // the decrescendo on the previous item
            if (strchr(infile[xx][yy], ')') != NULL) {
               // replace the '(' found on the previous data line
               buf.setSize(strlen(infile[xx][yy])+1);
               strcpy(buf.getBase(), infile[xx][yy]);
               pre.sar(buf, "\\)", "]", "");  // should only apply to last 
               //if (decrescX) {
               //   pre.sar(buf, "\\]", "]X", "");
               //   decrescX = 0;
               //}
               //if (decrescy) {
               //   pre.sar(buf, "\\]", "]y", "");
               //   decrescy = 0;
               //}
               infile[xx].changeField(yy, buf.getBase());
               decrescState = 0;
            } else {
               // there is something other than ( on the last line:
               // append " ["
               strcpy(buffer, infile[xx][yy]);
               strcat(buffer, " ]");
               if (decrescy) { 
                  strcat(buffer, "yy");
                  decrescy = 0;
               } if (decrescX) { 
                  strcat(buffer, "X");
                  decrescX = 0;
               }
               infile[xx].changeField(yy, buffer);
               decrescState = 0;
            }
         }

      } 

      // search for < or > marker to initiate de/cresc.
      if (strchr(infile[ii][jj], '<')  != NULL) { crescState   = 1; }
      if (strchr(infile[ii][jj], '>')  != NULL) { decrescState = 1; }
      if (strstr(infile[ii][jj], "<X") != NULL) { crescX       = 1; }
      if (strstr(infile[ii][jj], ">X") != NULL) { decrescX     = 1; }
      if (strstr(infile[ii][jj], "<yy") != NULL) { crescy      = 1; }
      if (strstr(infile[ii][jj], ">yy") != NULL) { decrescy    = 1; }
   }


   // handle case where cresc/decresc ends data with nothing after it.
   if (crescState) {

      // end the crescendo
      xx = data.last()[0].i;
      yy = data.last()[0].j;
      if (debugQ) {
         cerr << "GOT HERE " << infile[xx][yy] << endl;
      }
      if ((xx < 0) || (yy < 0)) {
         return;
      }
      // this is a dynamic object of some sort so terminate
      // the crescendo on the previous item
      if (strchr(infile[xx][yy], '(') != NULL) {
         if (debugQ) {
            cerr << "GOT HERE " << infile[xx][yy] << endl;
         }
         // replace the '(' found on the previous data line
         buf.setSize(strlen(infile[xx][yy])+1);
         strcpy(buf.getBase(), infile[xx][yy]);
         pre.sar(buf, "\\(", "[", "");  // should only apply to last 
         if (crescX) {
            pre.sar(buf, "\\[", "[", "");
            crescX = 0;
         }
         if (crescy) {
            pre.sar(buf, "\\[", "[", "");
            crescy = 0;
         }
         infile[xx].changeField(yy, buf.getBase());
         crescState = 0;
         if (debugQ) {
            cerr << "DEACTIVATING CRESC 1" << endl;
         }
      }

   } else if (decrescState) {

      // end the decrescendo
      xx = data.last()[0].i;
      yy = data.last()[0].j;
      if (debugQ) {
         cerr << "GOT HERE " << infile[xx][yy] << endl;
      }
      if ((xx < 0) || (yy < 0)) {
         return;
      }
      // this is a dynamic object of some sort so terminate
      // the decrescendo on the previous item
      if (strchr(infile[xx][yy], ')') != NULL) {
         if (debugQ) {
            cerr << "GOT HERE " << infile[xx][yy] << endl;
         }
         // replace the '(' found on the previous data line
         buf.setSize(strlen(infile[xx][yy])+1);
         strcpy(buf.getBase(), infile[xx][yy]);
         pre.sar(buf, "\\)", "]", "");  // should only apply to last 
         if (decrescX) {
            pre.sar(buf, "\\]", "]", "");
            decrescX = 0;
         }
         if (decrescy) {
            pre.sar(buf, "\\]", "]", "");
            decrescy = 0;
         }
         infile[xx].changeField(yy, buf.getBase());
         decrescState = 0;
         if (debugQ) {
            cerr << "DEACTIVATING DECRESC 1" << endl;
         }
      }

   }

}