Beispiel #1
0
void processRecords(HumdrumFile& infile, HumdrumFile& outfile) {
   infile.analyzeRhythm();
   char buffer[10000] = {0};

   int style;
   double duration;
   style = styles.extract();
   duration = durations.extract();

   double currbeat = 0;

   double targetbeat = 0;
   int lastline = 0;
   double currdur;
   int state = 0;

   for (int i=0; i<infile.getNumLines(); i++) {
      if (options.getBoolean("debug")) {
         cout << "processing line " << (i+1) << " of input ..." << endl;
      }

      if (infile[i].getType() != E_humrec_data) {
         outfile.appendLine(infile[i]);
         continue;
      }
 
      state = 0;
      currbeat = infile[i].getAbsBeat();
      currdur = infile[i].getDuration();
      while ((currbeat+currdur > targetbeat) || 
            (fabs(currbeat-targetbeat) < 0.001)) {

         if (fabs(currbeat - targetbeat) < 0.0001) {
            createDataLine(buffer, infile, i, duration, style);
            outfile.appendLine(buffer);
            styles.insert(style);
            durations.insert(duration);
            style = styles.extract();
            duration = durations.extract();
            targetbeat += duration;
         } else if (currbeat+currdur > targetbeat) {
            if (state == 1) {
               createDataLine(buffer, infile, lastline, duration, style);
            } else {
               createDataLine(buffer, infile, i, duration, style);
            }
            outfile.appendLine(buffer);
            styles.insert(style);
            durations.insert(duration);
            style = styles.extract();
            duration = durations.extract();
            targetbeat += duration;
         } else {
            break;
         }
      }

      lastline = i;

   }
}
Beispiel #2
0
void GridSlice::transferTokens(HumdrumFile& outfile, bool recip) {
	HTp token;
	HumdrumLine* line = new HumdrumLine;
	GridVoice* voice;
	string empty = ".";

	if (recip) {
		if (isNoteSlice()) {
			token = createRecipTokenFromDuration(getDuration());
		} else if (isClefSlice()) {
			token = new HumdrumToken("*");
			empty = "*";
		} else if (isMeasureSlice()) {
			voice = this->at(0)->at(0)->at(0);
			token = new HumdrumToken((string)*voice->getToken());
//ggg
			empty = (string)*token;
		} else if (isInterpretationSlice()) {
			token = new HumdrumToken("*");
			empty = "*";
		} else {
			token = new HumdrumToken("55");
			empty = "!z";
		}
		line->appendToken(token);
	}

	// extract the Tokens from each part/staff
	int p; // part index
	int s; // staff index
	int v; // voice index

	for (p=(int)size()-1; p>=0; p--) {

		GridPart& part = *this->at(p);
		for (s=(int)part.size()-1; s>=0; s--) {
			GridStaff& staff = *part.at(s);
			if (staff.size() == 0) {
				// fix this later.  For now if there are no notes
				// on the staff, add a null token.  Fix so that
				// all open voices are given null tokens.
				token = new HumdrumToken(empty);
				line->appendToken(token);
			} else {
				for (v=0; v<(int)staff.size(); v++) {
					if (staff.at(v) && staff.at(v)->getToken()) {
						line->appendToken(staff.at(v)->getToken());
						staff.at(v)->forgetToken();
					} else if (!staff.at(v)) {
						token = new HumdrumToken(".z");
						line->appendToken(token);
					} else {
						token = new HumdrumToken(".b");
						line->appendToken(token);
					}
				}

			}
			int maxvcount = getVerseCount(p, s);
			int maxhcount = getHarmonyCount(p, s);
			transferSides(*line, staff, empty, maxvcount, maxhcount);
		}
		int maxhcount = getHarmonyCount(p);
		int maxvcount = getVerseCount(p, -1);
		transferSides(*line, part, empty, maxvcount, maxhcount);
	}

	outfile.appendLine(line);
}