Example #1
0
autoVocalTract Matrix_to_VocalTract (Matrix me) {
    try {
        autoVocalTract thee = VocalTract_create (my nx, my dx);
        NUMvector_copyElements (my z [1], thy z [1], 1, my nx);
        return thee;
    } catch (MelderError) {
        Melder_throw (me, U": not converted to VocalTract.");
    }
}
Example #2
0
autoVocalTract LPC_Frame_to_VocalTract (LPC_Frame me, double length) {
	try {
		long m = my nCoefficients;
		autoNUMvector<double> area (1, m + 1);
		NUMlpc_lpc_to_area (my a, m, area.peek());
		autoVocalTract thee = VocalTract_create (m, 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[m + 1 - i];
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (U"No VocalTract created from LPC_Frame.");
	}
}
Example #3
0
autoVocalTract VocalTract_createFromPhone (const char32 *phone) {
    try {
        int i = 0;
        for (;; i ++) {
            if (! theVocalTract::data [i]. phone)
                Melder_throw (U"Unknown phone ", phone);
            if (Melder_equ (theVocalTract::data [i]. phone, phone))
                break;
        }
        autoVocalTract me = VocalTract_create (theVocalTract::data [i]. numberOfSections, 0.005);
        for (int isection = 1; isection <= my nx; isection ++)
            my z [1] [isection] = theVocalTract::data [i]. area [isection - 1] * 0.0001;
        return me;
    } catch (MelderError) {
        Melder_throw (U"VocalTract not created from phone.");
    }
}
Example #4
0
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;
}
autoVocalTract VocalTractTier_to_VocalTract (VocalTractTier me, double time) {
	try {
		VocalTractPoint vtp = (VocalTractPoint) my d_vocalTracts -> item[1];
		long numberOfSections = vtp -> d_vocalTract -> nx;
		autoVocalTract thee = VocalTract_create (numberOfSections, vtp -> d_vocalTract -> dx);
		for (long isection = 1; isection <= numberOfSections; isection++) {
			autoRealTier section = RealTier_create (my xmin, my xmax);
			for (long i = 1; i <= my d_vocalTracts -> size; i++) {
				VocalTractPoint vtpi = (VocalTractPoint) my d_vocalTracts -> item[i];
				double areai = vtpi -> d_vocalTract -> z[1][isection];
				RealTier_addPoint (section.peek(), vtpi -> number, areai);
			}
			thy z[1][isection] = RealTier_getValueAtTime (section.peek(), time);
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (me, U": no VocalTract created.");
	}
}
Example #6
0
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.");
	}
}