static autoSound synthesize_overlapAdd (Manipulation me) { if (! my duration || my duration -> points.size == 0) return synthesize_overlapAdd_nodur (me); try { if (! my sound) Melder_throw (U"Missing original sound."); if (! my pulses) Melder_throw (U"Missing pulses analysis."); if (! my pitch) Melder_throw (U"Missing pitch manipulation."); return Sound_Point_Pitch_Duration_to_Sound (my sound.get(), my pulses.get(), my pitch.get(), my duration.get(), MAX_T); } catch (MelderError) { Melder_throw (me, U": overlap-add synthesis not performed."); } }
Sound Sound_lengthen_overlapAdd (Sound me, double fmin, double fmax, double factor) { try { if (my ny > 1) Melder_throw (U"Overlap-add works only on mono sounds."); autoSound sound = Data_copy (me); Vector_subtractMean (sound.peek()); autoPitch pitch = Sound_to_Pitch (sound.peek(), 0.8 / fmin, fmin, fmax); autoPointProcess pulses = Sound_Pitch_to_PointProcess_cc (sound.peek(), pitch.peek()); autoPitchTier pitchTier = Pitch_to_PitchTier (pitch.peek()); autoDurationTier duration = DurationTier_create (my xmin, my xmax); RealTier_addPoint (duration.peek(), 0.5 * (my xmin + my xmax), factor); autoSound thee = Sound_Point_Pitch_Duration_to_Sound (sound.peek(), pulses.peek(), pitchTier.peek(), duration.peek(), 1.5 / fmin); return thee.transfer(); } catch (MelderError) { Melder_throw (me, U": not lengthened."); } }