src/GridSlice.cpp
HTp GridSlice::createRecipTokenFromDuration(HumNum duration) {
	duration /= 4;  // convert to quarter note units.
	HTp token;
	string str;
	HumNum dotdur;
	if (duration.getNumerator() == 0) {
		// if the GridSlice is at the end of a measure, the
		// time between the starttime/endtime of the GridSlice should
		// be subtracted from the endtime of the current GridMeasure.
		token = new HumdrumToken("g");
		return token;
	} else if (duration.getNumerator() == 1) {
		token = new HumdrumToken(to_string(duration.getDenominator()));
		return token;
	} else if (duration.getNumerator() % 3 == 0) {
		dotdur = ((duration * 2) / 3);
		if (dotdur.getNumerator() == 1) {
			token = new HumdrumToken(to_string(dotdur.getDenominator()) + ".");
			return token;
		}
	}

	// try to fit to two dots here

	// try to fit to three dots here

	str = to_string(duration.getDenominator()) + "%" +
	         to_string(duration.getNumerator());
	token = new HumdrumToken(str);
	return token;
}
//////////////////////////////
//
// GridSlice::createRecipTokenFromDuration --  Will not be able to
//   distinguish between triplet notes and dotted normal equivalents,
//   this can be changed later by checking neighboring durations in the
//   list for the presence of triplets.
//
:createRecipTokenFromDuration --  Will not be able to
distinguish between triplet notes and dotted normal equivalents,
this can be changed later by checking neighboring durations in the
list for the presence of triplets.
: createRecipTokenFromDuration -- Will not be able to distinguish between triplet notes and dotted normal equivalents this can be changed later by checking neighboring durations in the list for the presence of triplets .
HTp GridSlice::createRecipTokenFromDuration(HumNum duration) {
	duration /= 4;  
	HTp token;
	string str;
	HumNum dotdur;
	if (duration.getNumerator() == 0) {
		token = new HumdrumToken("g");
		return token;
	} else if (duration.getNumerator() == 1) {
		token = new HumdrumToken(to_string(duration.getDenominator()));
		return token;
	} else if (duration.getNumerator() % 3 == 0) {
		dotdur = ((duration * 2) / 3);
		if (dotdur.getNumerator() == 1) {
			token = new HumdrumToken(to_string(dotdur.getDenominator()) + ".");
			return token;
		}
	}
	str = to_string(duration.getDenominator()) + "%" +
	         to_string(duration.getNumerator());
	token = new HumdrumToken(str);
	return token;
}
HTp GridSlice :: createRecipTokenFromDuration ( HumNum duration ) { duration /= 4 ; HTp token ; string str ; HumNum dotdur ; if ( duration . getNumerator ( ) == 0 ) { token = new HumdrumToken ( " " ) ; return token ; } else if ( duration . getNumerator ( ) == 1 ) { token = new HumdrumToken ( to_string ( duration . getDenominator ( ) ) ) ; return token ; } else if ( duration . getNumerator ( ) % 3 == 0 ) { dotdur = ( ( duration * 2 ) / 3 ) ; if ( dotdur . getNumerator ( ) == 1 ) { token = new HumdrumToken ( to_string ( dotdur . getDenominator ( ) ) + " " ) ; return token ; } } str = to_string ( duration . getDenominator ( ) ) + " " + to_string ( duration . getNumerator ( ) ) ; token = new HumdrumToken ( str ) ; return token ; }
GridSlice::createRecipTokenFromDuration --  Will not be able to
distinguish between triplet notes and dotted normal equivalents,
this can be changed later by checking neighboring durations in the
list for the presence of triplets.
GridSlice :: createRecipTokenFromDuration -- Will not be able to distinguish between triplet notes and dotted normal equivalents this can be changed later by checking neighboring durations in the list for the presence of triplets .
// convert to quarter note units. // if the GridSlice is at the end of a measure, the // time between the starttime/endtime of the GridSlice should // be subtracted from the endtime of the current GridMeasure. // try to fit to two dots here // try to fit to three dots here