#if !defined(__LipsSync_H__)
#define __LipsSync_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#ifdef D_USE_LIPSYNC
 
#include "GAM/Header.h"
 
#include "HDL.h"
 
#define MAX_NUM_CHAN_SYN	10
#define LARGE_NUMBER		30000
#define NO_LIPS				-1000
#define NO_PHONEME			12			/* Cf 'N'-'A' = 13 ('N' for None)*/
 
typedef struct tdstLipsSynchroEvent_
{
	unsigned char ucPhoneme;
	unsigned char ucIntensity;
	unsigned char ucExpression;
} tdstLipsSynchroEvent;
 
typedef struct tdstDialText_
{
	long lFrameNumber;
	MTH_tdxReal xPosX,xPosY;
} tdstDialText;
 
typedef struct tdstActing_
{
	long lFrameNumber;
	tdxHandleToState hNewState;
} tdstActing;
 
typedef struct tdstLipsSynchroTable_
{
	long lNumberOfFrames;
	long lSpeed;
	struct tdstLipsSynchroEvent_ *p_stTable;
	SND_tdxHandleToSoundEvent p_stSndEvent;
	SND_tdxHandleToSoundEvent p_stSndEventStop;
	long lSoundHandle;
	unsigned char ucChannelAffected[MAX_NUM_CHAN_SYN];
	unsigned char ucNumberOfChannelAffected;
	int iIndex;			/* Index in the global array of superimposed texts*/
	long lNumberOfTexts;
	struct tdstDialText_ *p_stDialTexts;
	long lNumberOfActings;
	struct tdstActing_ *p_stActing;
} tdstLipsSynchroTable;
 
typedef struct tdstLipsSynchroBinTable_
{
	char szSectionName[255];
	tdstLipsSynchroTable *p_stLSTable;
} tdstLipsSynchroBinTable;
 
struct tdstDialText_ *fn_xAllocateDialTexts(long lNbTexts);
struct tdstActing_ *fn_xAllocateActing(long lNbActing);
 
extern CPA_EXPORT tdstLipsSynchroEvent *fn_xAllocateLipsSynchroEvents(long lNbEvents);
extern CPA_EXPORT tdxHandleOfLipsSynchroTable fn_xAllocateLipsSynchroTable();
extern CPA_EXPORT tdstLipsSynchroBinTable *fn_xAllocateLipsSynchroBinTable(long lNbElts);
extern CPA_EXPORT void fn_vLSSetSpeed(tdxHandleOfLipsSynchroTable hLSTable,long lSpeed);
extern CPA_EXPORT void fn_vLSSetSound(tdxHandleOfLipsSynchroTable hLSTable,SND_tdxHandleToSoundEvent);
extern CPA_EXPORT SND_tdxHandleToSoundEvent fn_xLSGetSound(tdxHandleOfLipsSynchroTable hLSTable);
 
extern CPA_EXPORT void fn_vLSSetPhoneme(tdxHandleOfLipsSynchroTable hLSTable,int iIndex,unsigned char ucPhoneme);
extern CPA_EXPORT void fn_vLSSetIntensity(tdxHandleOfLipsSynchroTable hLSTable,int iIndex,unsigned char ucIntensity);
extern CPA_EXPORT void fn_vLSSetExpression(tdxHandleOfLipsSynchroTable hLSTable,int iIndex,unsigned char ucExpression);
extern CPA_EXPORT long fn_lLSGetSpeed(tdxHandleOfLipsSynchroTable hLSTable);
extern CPA_EXPORT long fn_lLSGetNumberOfFrame(tdxHandleOfLipsSynchroTable hLSTable);
extern CPA_EXPORT unsigned char fn_ucLSGetPhoneme(tdxHandleOfLipsSynchroTable hLSTable,int iIndex);
extern CPA_EXPORT unsigned char fn_ucLSGetIntensity(tdxHandleOfLipsSynchroTable hLSTable,int iIndex);
extern CPA_EXPORT unsigned char fn_ucLSGetExpression(tdxHandleOfLipsSynchroTable hLSTable,int iIndex);
extern CPA_EXPORT void fn_vSetSoundHandle(tdxHandleOfLipsSynchroTable hLSTable,long handle);
extern CPA_EXPORT long fn_lGetSoundHandle(tdxHandleOfLipsSynchroTable hLSTable);
 
extern CPA_EXPORT void fn_vPlayLipsSynch(HIE_tdxHandleToSuperObject hSOM);
extern CPA_EXPORT short fn_vGetLipsSynchObject(HIE_tdxHandleToSuperObject hSOM,short);
 
extern CPA_EXPORT void fn_vLSAddChannelSync(tdxHandleOfLipsSynchroTable hLSTable,unsigned char);
extern CPA_EXPORT void fn_vLSResetChannelSync(tdxHandleOfLipsSynchroTable hLSTable);
 
extern CPA_EXPORT void fn_vStartLipsSynchro(HIE_tdxHandleToSuperObject hSOM,tdxHandleOfLipsSynchroTable hLipsTable);
extern CPA_EXPORT void fn_vStopLipsSynchro(HIE_tdxHandleToSuperObject hSOM);
extern CPA_EXPORT BOOL fn_bIsDiscussionOver(HIE_tdxHandleToSuperObject hSOM);
 
#endif /*D_USE_LIPSYNC*/
 
 
#endif /* __LipsSync_H__ */
