autoPitchTier Pitch_AnyTier_to_PitchTier (Pitch pitch, AnyTier tier, int checkMethod) {
	try {
		SortedSetOfDouble points = tier -> points;
		if (checkMethod == 2) {
			autoPitchTier temp = Pitch_to_PitchTier (pitch);
			autoPitchTier thee = PitchTier_AnyTier_to_PitchTier (temp.peek(), tier);
			return thee.transfer();
		}

		/*
		 * Result's domain is a union of both domains.
		 */
		autoPitchTier thee = PitchTier_create (
			pitch -> xmin < tier -> xmin ? pitch -> xmin : tier -> xmin,
			pitch -> xmax > tier -> xmax ? pitch -> xmax : tier -> xmax);

		/*
		 * Copy pitch's frequencies at tier's points to the resulting PitchTier.
		 */
		for (long ipoint = 1; ipoint <= points -> size; ipoint ++) {
			AnyPoint point = (AnyPoint) points -> item [ipoint];
			double time = point -> number;
			double frequency = Pitch_getValueAtTime (pitch, time, kPitch_unit_HERTZ, Pitch_LINEAR);
			if (frequency == NUMundefined && checkMethod)
				Melder_throw (U"No periodicity at time ", time, U" seconds.");
			RealTier_addPoint (thee.peek(), time, frequency);
		}

		return thee;
	} catch (MelderError) {
		Melder_throw (pitch, U" & ", tier, U": not converted to PitchTier.");
	}
}
Example #2
0
autoManipulation Manipulation_AnyTier_to_Manipulation (Manipulation me, AnyTier tier) {
	try {
		if (! my pitch) Melder_throw (U"Missing pitch manipulation.");
		autoManipulation result = Data_copy (me);
		result -> pitch = PitchTier_AnyTier_to_PitchTier (my pitch.get(), tier);
		return result;
	} catch (MelderError) {
		Melder_throw (me, U": not converted.");
	}
}