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."); } }
autoPitchTier PitchTier_AnyTier_to_PitchTier (PitchTier pitch, AnyTier tier) { try { SortedSetOfDouble points = tier -> points; if (pitch -> points -> size == 0) Melder_throw (U"No pitch points."); /* * 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 = RealTier_getValueAtTime (pitch, time); RealTier_addPoint (thee.peek(), time, frequency); } return thee; } catch (MelderError) { Melder_throw (pitch, U" & ", tier, U": not converted to PitchTier."); } }
PitchTier PitchTier_PointProcess_to_PitchTier (PitchTier me, PointProcess pp) { try { if (my points -> size == 0) Melder_throw ("No pitch points."); autoPitchTier thee = PitchTier_create (pp -> xmin, pp -> xmax); for (long i = 1; i <= pp -> nt; i ++) { double time = pp -> t [i]; double value = RealTier_getValueAtTime (me, time); RealTier_addPoint (thee.peek(), time, value); } return thee.transfer(); } catch (MelderError) { Melder_throw (me, " & ", pp, ": not converted to PitchTier."); } }
PitchTier PointProcess_to_PitchTier (PointProcess me, double maximumInterval) { try { autoPitchTier thee = PitchTier_create (my xmin, my xmax); for (long i = 1; i < my nt; i ++) { double interval = my t [i + 1] - my t [i]; if (interval <= maximumInterval) { RealTier_addPoint (thee.peek(), my t [i] + 0.5 * interval, 1.0 / interval); } } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": not converted to PitchTier."); } }
Sound FormantGrid_to_Sound (FormantGrid me, double samplingFrequency, double tStart, double f0Start, double tMid, double f0Mid, double tEnd, double f0End, double adaptFactor, double maximumPeriod, double openPhase, double collisionPhase, double power1, double power2) { try { autoPitchTier pitch = PitchTier_create (my xmin, my xmax); RealTier_addPoint (pitch.peek(), my xmin + tStart * (my xmax - my xmin), f0Start); RealTier_addPoint (pitch.peek(), my xmin + tMid * (my xmax - my xmin), f0Mid); RealTier_addPoint (pitch.peek(), my xmax - (1.0 - tEnd) * (my xmax - my xmin), f0End); autoSound thee = PitchTier_to_Sound_phonation (pitch.peek(), samplingFrequency, adaptFactor, maximumPeriod, openPhase, collisionPhase, power1, power2, false); Sound_FormantGrid_filter_inline (thee.peek(), me); return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": not converted to Sound."); } }
autoPitchTier Pitch_to_PitchTier (Pitch me) { try { autoPitchTier thee = PitchTier_create (my xmin, my xmax); for (long i = 1; i <= my nx; i ++) { double frequency = my frame [i]. candidate [1]. frequency; /* * Count only voiced frames. */ if (frequency > 0.0 && frequency < my ceiling) { double time = Sampled_indexToX (me, i); RealTier_addPoint (thee.get(), time, frequency); } } return thee; } catch (MelderError) { Melder_throw (me, U": not converted to PitchTier."); } }
Sound FormantGrid_to_Sound (FormantGrid me, double samplingFrequency, double tStart, double f0Start, double tMid, double f0Mid, double tEnd, double f0End, double adaptFactor, double maximumPeriod, double openPhase, double collisionPhase, double power1, double power2) { PitchTier pitch = NULL; Sound thee = NULL; pitch = PitchTier_create (my xmin, my xmax); cherror RealTier_addPoint (pitch, my xmin + tStart * (my xmax - my xmin), f0Start); cherror RealTier_addPoint (pitch, my xmin + tMid * (my xmax - my xmin), f0Mid); cherror RealTier_addPoint (pitch, my xmax - (1.0 - tEnd) * (my xmax - my xmin), f0End); cherror thee = PitchTier_to_Sound_phonation (pitch, samplingFrequency, adaptFactor, maximumPeriod, openPhase, collisionPhase, power1, power2, false); cherror Sound_FormantGrid_filter_inline (thee, me); end: forget (pitch); iferror forget (thee); return thee; }