VocalTract LPC_to_VocalTract (LPC me, double time, double length, int wakita) { VocalTract thee = NULL; struct structTube_Frame area_struct; Tube_Frame area = & area_struct; LPC_Frame lpc; long i, m, iframe = Sampled_xToIndex (me, time); if (iframe < 1) iframe = 1; if (iframe > my nx) iframe = my nx; memset (& area_struct, 0, sizeof(area_struct)); lpc = & my frame[iframe]; m = lpc -> nCoefficients; if (! Tube_Frame_init (area, m, length) || ! LPC_Frame_into_Tube_Frame_area (lpc, area)) goto end; thee = VocalTract_create (m, area -> length / m); if (thee == NULL) goto end; /* area[lips..glottis] (m^2) to VocalTract[glottis..lips] (m^2) */ for (i = 1; i <= m; i++) { thy z[1][i] = area -> c[m + 1 - i]; } if (wakita) { double wakita_length = LPC_Frame_getVTL_wakita (lpc, my samplingPeriod, length); if (wakita_length == NUMundefined) { Melder_warning1 (L"Vocal tract length could not be calculated.\nRelevant tract dimensions will be undefined."); thy xmax = thy x1 = thy dx = NUMundefined; } } end: Tube_Frame_destroy (area); return thee; }
static autoVocalTract LPC_Frame_to_VocalTract2 (LPC_Frame me, double length) { struct structTube_Frame area_struct = { 0 }; Tube_Frame area = & area_struct; try { long m = my nCoefficients; Tube_Frame_init (area, m, length); LPC_Frame_into_Tube_Frame_area (me, area); autoVocalTract thee = VocalTract_create (m, area -> length / m); // area[lips..glottis] (m^2) to VocalTract[glottis..lips] (m^2) for (long i = 1; i <= m; i++) { thy z[1][i] = area -> c[m + 1 - i]; } area -> destroy (); return thee; } catch (MelderError) { area -> destroy (); Melder_throw (U"No VocalTract created from LPC_Frame."); } }