示例#1
0
std::vector<double> Verosimilitud::GetAreaVec(void)
{
	unsigned int area_indices[3]={0,0,0};
	Tensor* my_area = eff_area->GetArea(area_indices);
	double * areaarray = my_area->GetDataPointer();
	unsigned int arealen = my_area->GetDataLength();
	std::cout << "AREALEN: " << arealen << std::endl;
	std::vector<double> areavec(arealen,0);
	for (int i=0; i<arealen; i++)
	{
		areavec[i]=areaarray[i];
	}
	return areavec;
}
autoLPC VocalTractTier_to_LPC (VocalTractTier me, double timeStep) {
	try {
		if (my d_vocalTracts -> size == 0) {
			Melder_throw (U"Empty VocalTractTier");
		}
		long numberOfFrames = (long) floor ((my xmax - my xmin) / timeStep);
		VocalTractPoint vtp = (VocalTractPoint) my d_vocalTracts -> item[1];
		long numberOfSections = vtp -> d_vocalTract -> nx;
		double samplingPeriod = 1.0 / (1000.0 * numberOfSections);
		autoNUMmatrix<double> area (1, numberOfFrames, 1, numberOfSections + 1);
		autoNUMvector<double> areavec (1, numberOfSections + 1);
		autoLPC thee = LPC_create (my xmin, my xmax, numberOfFrames, timeStep, timeStep / 2, numberOfSections, samplingPeriod);
		// interpolate each section
		for (long isection = 1; isection <= numberOfSections; isection++) {
			autoRealTier sectioni = 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 (sectioni.peek(), vtpi -> number, areai);
			}
			for (long iframe = 1; iframe <= numberOfFrames; iframe++) {
				double time = thy x1 + (iframe - 1) * thy dx;
				area[iframe][isection] = RealTier_getValueAtTime (sectioni.peek(), time);
				area[iframe][numberOfSections + 1] = 0.0001; // normalisation is area[n+1] = 0.0001
			}
		}
		for (long iframe = 1; iframe <= numberOfFrames; iframe++) {
			LPC_Frame frame = &thy d_frames[iframe];
			LPC_Frame_init (frame, numberOfSections);
			for (long i = 1; i <= numberOfSections + 1; i++) {
				areavec[i] = area[iframe][numberOfSections + 1 - i];
			}
			NUMlpc_area_to_lpc (areavec.peek(), numberOfSections + 1, frame -> a);
			frame -> gain = 1e-6; // something
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (U": not converted to LPC.");
	}
}