/* Art_Speaker_to_VocalTract.c */
/* Paul Boersma, May 9, 1994 */

#include "VocalTract.h"
#include "Delta.h"
#include "Speaker_to_Delta.h"
#include "Art_Speaker_Delta.h"
#include "Art_Speaker_to_VocalTract.h"

Any Art_Speaker_to_VocalTract (Any art, Any speaker)
{
	VocalTract thee = NULL;
	long isection;
	float area [300];
	int numberOfSections;
	double sectionLength = 0.001;   /* One millimetre. */
	Delta delta = NULL;

	delta = Speaker_to_Delta (speaker); if (! delta) goto end;
	Art_Speaker_intoDelta (art, speaker, delta);
	numberOfSections = 0;
	for (isection = 1; isection <= 27; isection ++)
	{
		Delta_Tube tube = delta -> tube + 37 + isection;
		int numberOfConstantSections = floor (tube -> Dxeq / sectionLength + 0.5);
		double constantArea = tube -> Dyeq * tube -> Dzeq;
		int jsection; for (jsection = 1; jsection <= numberOfConstantSections; jsection ++)
			area [++ numberOfSections] = constantArea;
	}
	thee = VocalTract_create (numberOfSections, sectionLength); if (! thee) goto end;
	for (isection = 1; isection <= numberOfSections; isection ++)
		thy z [1] [isection] = area [isection];

end:
	forget (delta);
	return thee;
}

/* End of file Art_Speaker_to_VocalTract.c */
