/*
//////////////////////////////////////////////////////////////
//	SNDXD.C													//
//////////////////////////////////////////////////////////////
//	Module d'exploitation des samples PCM en 3D				//
//------------ version 2D (Dx2D, WinMM,..)-------------------------------
//////////////////////////////////////////////////////////////
*/
#include "SNDinc.h"
 
#ifndef NO_ACP_SOUND
 
#include "sndthrd.h"
 
#if defined(_DLL_COMPILATION_MODE) 
#include "snddll.h"
#endif
 
#include "sndres.h"
#include "sndxd.h"
#include "sndwave.h"
 
/*---- sample 3D*/
long SND_CALL SND_fn_lPlaySxdWave(tduRefRes res,SoundParam *par,long prio,SND_td_pfn_vSoundCallback fn_callback,long par_callback)
{
	SampleParam	par2D;
 
	SND_fn_vParam3Dto2D(par,&par2D);
 
	return SND_fn_lPlaySample(res,&par2D,prio,fn_callback,par_callback);
}
 
void SND_CALL SND_fn_vRemoveCallbackSxdWave(long voice)
{
}
 
SndBool SND_CALL SND_fn_bSetParamSxdWave(long voice,SoundParam *par)
{
	SampleParam par2D;
 
	SND_fn_vParam3Dto2D(par,&par2D);
 
	return SND_fn_bSetParamSample(voice,&par2D);
}
 
SndBool SND_CALL SND_fn_bTestIsPlayingSxdWave(long voice)
{
	return SND_fn_bTestIsPlayingSample(voice);
}
 
void SND_CALL SND_fn_vStopSxdWave(long voice)
{
	SND_fn_vStopSample(voice);
}
 
void SND_CALL SND_fn_vPauseSxdWave(long voice)
{
	SND_fn_vPauseSample(voice);
}
 
void SND_CALL SND_fn_vResumeSxdWave(long voice)
{
	SND_fn_vResumeSample(voice);
}
 
/*----- init generales*/
int SND_fn_iInitSxdWave(SND_tdstInitStruct *pInitStruct)
{
	return SND_fn_iInitSample(pInitStruct);
}
 
SndBool SND_fn_bTestInitSxdWave(void)
{
	return SND_fn_bTestInitSample();
}
 
void SND_fn_vDesInitSxdWave(void)
{
	SND_fn_vDesInitSample();
}
 
/*------------------------------------------------------------*/
/*      SetDopplerFactorSxdWave:change Doppler effect range*/
/*      Entree:new factor for Doppler effect (1.0=normal effect=physicallly realistic*/
/*				0.0=no doppler effect*/
/*      Sortie:neant*/
/*------------------------------------------------------------*/
void SND_fn_vSetDopplerFactorSxdWave(SndReal factor)
{
}
 
 
void SND_fn_vCreateMicroSxdWave(MicroParam* par,long idMicro)
{
    /*rien à faire en 2D (tout est fait par le SXD)*/
}
 
void SND_fn_vSetMicroParamSxdWave(long sxdId,MicroParam* par)
{
    /*rien à faire en 2D (tout est fait par le SXD)*/
}
 
void SND_fn_vDestroyMicroSxdWave(long sxdId)
{
    /*rien à faire en 2D (tout est fait par le SXD)*/
}
 
 
/*--------------------------------------------------*/
/*	SND_fnvConvertRsvDiskToMemSxd*/
/*	Entree:disk=bloxkResDisk à convertir*/
/*		mem=blockMemDisk à generer*/
/*		ptrBegin=adresse de stockage des donnees*/
/*	Retour:neant*/
/*------------------------------------------------*/
/*
void SND_fn_vConvertResDiskToMemSxdWave(tdstBlockResourceDisk *disk
						 ,tdstBlockResourceMem *mem
						 ,void* ptrBegin)
{
	    SND_fn_vConvertResDiskToMemSample(disk,mem,ptrBegin);
}
*/
 
/*--------------------------------------------------*/
/*	SND_fnvLoadRsvDisk*/
/*	Entree:disk=bloxkResDisk à convertir*/
/*		mem=blockMemDisk à generer*/
/*	Retour:neant*/
/*------------------------------------------------*/
/*
void SND_fn_vLoadResFromDiskSxdWave(tdstBlockResourceDisk* disk,tdstBlockResourceMem* mem)
{
	    SND_fn_vLoadResFromDiskSample(disk,mem);
}
*/
 
#if !defined(NO_ACP_SCRIPT) || defined(_DLL_COMPILATION_MODE)
/*this function must be defined in Script/Hybrid or DLL mode*/
SndBool SND_fn_bLoadResScriptSxdWave(tdstBlockResourceDisk* disk,tdstBlockResourceMem* mem)
{
	    return(SND_fn_bLoadResScriptSample(disk,mem));
}
#endif
 
SndBool SND_fn_bLoadResBinarySxdWave(tdstBlockResourceDisk* disk,tdstBlockResourceMem* mem,char *pDataBloc)
{
	    return(SND_fn_bLoadResBinarySample(disk,mem,pDataBloc));
}
 
void	SND_fn_vConvertResDiskToMemSxdWave(tdstBlockResourceDisk *disk,tdstBlockResourceMem *mem,void* ptrBegin)
{
	SND_fn_vConvertResDiskToMemSample(disk,mem,ptrBegin);
}
 
 
/*--------------------------------------------------*/
/*	SND_fnvUnLoadRsvDisk*/
/*	Entree:mem=blockMemDisk à liberer*/
/*	Retour:neant*/
/*------------------------------------------------*/
void SND_fn_vUnLoadResSxdWave(tdstBlockResourceMem* mem)
{
    SND_fn_vUnLoadResSample(mem);
}
 
/*---------------------------------------------------------*/
/*      IsResLoadedSample: teste si une ressource est operationnelle*/
/*      Entree:blockmem valide*/
/*      Sortie:TRUE si SndPlay acceptable*/
/*---------------------------------------------------------*/
SndBool SND_fn_bIsResLoadedSxdWave(tdstBlockResourceMem *mem)
{
    return SND_fn_bIsResLoadedSample(mem);
}
 
/*
void SND_fn_vSetResUnloadedSxdWave(tdstBlockResourceMem *pResMem)
{
    SND_fn_vSetResUnloadedSample(pResMem);
}
*/
#ifndef DISABLE_BUFFER_CLIENT
/*/------------------------------- buffer clients*/
/*----------------------------------------------------------------------*/
/*  Gestion des buffers clients*/
/*----------------------------------------------------------------------*/
long SND_fn_lCreateNewBufferSxdWave(unsigned long nb_samples,unsigned short uwResolution,unsigned short uwNbChannels,unsigned long ulFreq,SoundParam* par,td_pfn_vRefreshBufferClient callback,long user_id)
{
	SampleParam	par2D,*ptr_par2D;
 
	if (par!=NULL)
    {
        SND_fn_vParam3Dto2D(par,&par2D);
        ptr_par2D=&par2D;
    }
    else
        ptr_par2D=&C_SAMPLEPARAM_NEUTRE;
 
    return SND_fn_lCreateNewBufferSample(nb_samples,uwResolution,uwNbChannels,ulFreq,ptr_par2D,callback,user_id);
}
 
void SND_fn_vSetParamBufferSxdWave(long id_buffer,SoundParam *par)
{
	SampleParam	par2D,*ptr_par2D;
 
	if (par!=NULL)
    {
        SND_fn_vParam3Dto2D(par,&par2D);
        ptr_par2D=&par2D;
    }
    else
        ptr_par2D=NULL;
 
    SND_fn_vSetParamBufferSample(id_buffer,ptr_par2D);
}
 
void SND_fn_vDeleteBufferSxdWave(long id_buffer)
{
	/*very important: DeleteBuffer may be called from any streaming client Callback ->critical section is needed*/
    SND_fn_vEnterCriticalSectionThreadSnd();
 
    SND_fn_vDeleteBufferSample(id_buffer);
 
    SND_fn_vQuitCriticalSectionThreadSnd();
}
 
void SND_fn_vPauseBufferSxdWave(long id_buffer)
{
    SND_fn_vPauseBufferSample(id_buffer);
}
 
void SND_fn_vResumeBufferSxdWave(long id_buffer)
{
    SND_fn_vResumeBufferSample(id_buffer);
}
 
void* SND_fn_pvGetPtrBufferSxdWave(long id_buffer)
{
    return SND_fn_pvGetPtrBufferSample(id_buffer);
}
 
SndReal SND_fn_rGetPosBufferSxdWave(long id_buffer)
{
	return SND_fn_rGetPosBufferSample(id_buffer);
}
 
long SND_fn_lCreateNewBufferExSxdWave(SND_tdstFormat* pformat,SND_tdstCallback* pCallback,SoundParam* par3D,long user_id)
{
	SampleParam	par2D,*p_par2D;
 
	if (par3D)
	{
		SND_fn_vParam3Dto2D(par3D,&par2D);
		p_par2D=&par2D;
	}
	else
		p_par2D=&C_SAMPLEPARAM_NEUTRE;
 
	return SND_fn_lCreateNewBufferExSample(pformat,pCallback,p_par2D,user_id);
}
 
long SND_fn_lGetPosBufferExSxdWave(long id_buffer)
{
	return SND_fn_lGetPosBufferExSample(id_buffer);
}
 
long SND_fn_lPushBufferExSxdWave(long id_buffer,SND_tdstStackBuffer* pStack)
{
	return SND_fn_lPushBufferExSample(id_buffer,pStack);
}
 
#endif /* DISABLE_BUFFER_CLIENT*/
/*--------------------------------------------------
relache-reprise a chaud des drives
---------------------------------------------------------*/
void SND_fn_vReleaseDriverSxdWave(void)
{
	SND_fn_vReleaseDriverSample();
}
 
void SND_fn_vRestoreDriverSxdWave(void)
{
	SND_fn_vRestoreDriverSample();
}
 
void SND_fn_vForceReleaseDriverSxdWave(void)
{
	SND_fn_vForceReleaseDriverSample();
}
 
void SND_fn_vForceRestoreDriverSxdWave(void)
{
	SND_fn_vForceRestoreDriverSample();
}
 
/*---------------------------------------------------------*/
/*	GetPos: retourne la position "theorique" de la ressource*/
/*			exprime en seconde depuis le debut*/
/*			different du temps absolu (car pitch, derive..)*/
/*	Entree: voie concernee*/
/*	Sortie: temps en S (SndReal)*/
/*----------------------------------------------------------*/
SndReal SND_CALL SND_fn_rGetPosSxdWave(long voie)
{
	return SND_fn_rGetPosSample(voie);
}
 
/*---------------------------------------------------------*/
/*	GetLength: retourne la duree "theorique" de la ressource*/
/*			exprime en seconde (constant pour une ressource donnee)*/
/*	Entree: voie concernee*/
/*	Sortie: duree en S (SndReal)*/
/*----------------------------------------------------------*/
SndReal SND_CALL SND_fn_rGetLengthSxdWave(long voie)
{
	return SND_fn_rGetLengthSample(voie);
}
 
/*---------------------------------------------------------*/
/*	GetTargetLabel: retourne le label designant la tareget*/
/*	Entree: name=nom cible*/
/*		nb_char=taille maxi de la cible*/
/*----------------------------------------------------------*/
void SND_fn_vGetTargetLabelSxdWave(char* name,int nb_char)
{
	SND_fn_vGetTargetLabelSample(name,nb_char);
}
 
void SND_fn_vSetupTargetSxdWave(void)
{
	SND_fn_vSetupTargetSample();
}
 
SndBool SND_fn_bCanSetupTargetSxdWave(void)
{
	return SND_fn_bCanSetupTargetSample();
}
 
void SND_fn_vSetReverseStereoSxdWave(SndBool active)
{
	SND_fn_vSetReverseSample(active);
}
 
SndBool	SND_fn_bGetReverseStereoSxdWave(void)
{
	return SND_fn_bGetReverseSample();
}
 
void SND_fn_vSetEffectSxdWave(long num)
{
	SND_fn_vSetEffectSample(num);
}
 
void SND_fn_vSetSoundVolumeSxdWave(unsigned char vol)
{
	SND_fn_vSetSoundVolumeSample(vol);
}
 
unsigned char SND_fn_ucGetSoundVolumeSxdWave(void)
{
	return SND_fn_ucGetSoundVolumeSample();
}
 
/*-------------------------------------------------*/
/* Fonction de synchro moteur*/
/*-------------------------------------------------*/
void SND_fn_vSynchroSxdWave()
{
	SND_fn_vSynchroSample();
}
 
void SND_fn_vSetDefaultRollOffSxdWave(RollOffParam* rolloff)
{
	/*nothing to do in this version*/
}
 
SndBool SND_fn_bCheckVersionResourceSxdWave(tdstBlockResourceDisk* disk)
{
	return TRUE;
}
 
/*change the user's choice for NbVoiceWished*/
void SND_fn_vSetNbVoiceWishedSxdWave(long nb)
{
	SND_fn_vSetNbVoiceWishedSample(nb);
}
 
/*get the user's choice for NbVoiceWished*/
long SND_fn_lGetNbVoiceWishedSxdWave()
{
	return SND_fn_lGetNbVoiceWishedSample();
}
 
/*get the recommended number of voice (isn't influed by NbWished voice)*/
/*to reinitalize the user's choice to the best value of voice,*/
/*	 call SND_fn_vSetNbVoiceWishedSxdWave(SND_fn_lGetNbVoiceOptimumSxdWave())*/
long SND_fn_lGetNbVoiceOptimumSxdWave()
{
	return SND_fn_lGetNbVoiceOptimumSample();
}
 
SndBool SND_fn_bIsResourceLoopingSxdWave(tduRefRes res)
{
	return SND_fn_bIsResourceLoopingSample(res);
}
 
SndBool SND_fn_b3DOneShootShouldBeConvertedSxdWave()
{
	return FALSE;
}

SndBool  SND_fn_bSetResourceStaticVolumeSxdWave(tdstBlockResourceMem* pstRes,unsigned char ucVolume)
{
	return SND_fn_bSetResourceStaticVolumeSample(pstRes,ucVolume);
}
 
#endif
/* NO_ACP_SOUND*/
 
