autoManipulation Sound_to_Manipulation (Sound me, double timeStep, double minimumPitch, double maximumPitch) { try { autoManipulation thee = Manipulation_create (my xmin, my xmax); thy sound = Sound_convertToMono (me); Vector_subtractMean (thy sound.get()); autoPitch pitch = Sound_to_Pitch (thy sound.get(), timeStep, minimumPitch, maximumPitch); thy pulses = Sound_Pitch_to_PointProcess_cc (thy sound.get(), pitch.get()); thy pitch = Pitch_to_PitchTier (pitch.get()); /* (DurationTier has been done at creation time) */ return thee; } catch (MelderError) { Melder_throw (me, U": not converted to Manipulation."); } }
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."); } }
Spectrogram Sound_to_Spectrogram_pitchDependent (Sound me, double analysisWidth, double dt, double f1_hz, double fmax_hz, double df_hz, double relative_bw, double minimumPitch, double maximumPitch) { try { double floor = 80, ceiling = 600; if (minimumPitch >= maximumPitch) { minimumPitch = floor; maximumPitch = ceiling; } if (minimumPitch <= 0) { minimumPitch = floor; } if (maximumPitch <= 0) { maximumPitch = ceiling; } autoPitch thee = Sound_to_Pitch (me, dt, minimumPitch, maximumPitch); autoSpectrogram ff = Sound_and_Pitch_to_Spectrogram (me, thee.peek(), analysisWidth, dt, f1_hz, fmax_hz, df_hz, relative_bw); return ff.transfer(); } catch (MelderError) { Melder_throw (me, ": no Spectrogram created."); } }
FormantFilter Sound_to_FormantFilter (Sound me, double analysisWidth, double dt, double f1_hz, double fmax_hz, double df_hz, double relative_bw, double minimumPitch, double maximumPitch) { try { double floor = 80, ceiling = 600; if (minimumPitch >= maximumPitch) { minimumPitch = floor; maximumPitch = ceiling; } if (minimumPitch <= 0) { minimumPitch = floor; } if (maximumPitch <= 0) { maximumPitch = ceiling; } autoPitch thee = Sound_to_Pitch (me, dt, minimumPitch, maximumPitch); autoFormantFilter ff = Sound_and_Pitch_to_FormantFilter (me, thee.peek(), analysisWidth, dt, f1_hz, fmax_hz, df_hz, relative_bw); return ff.transfer(); } catch (MelderError) { Melder_throw (me, U": no FormantFilter created."); } }