/*--------------------------------------------------------
FILE     CMdxTool.h

ROLE :   structure definition for main tool

LAST MODIFICATIONS:
      - J.Vibert - 21/01/98 - fading
      - J.Vibert - 21/01/98 - Main volume, incremental volume for MDX
      - D.Dumont - created
--------------------------------------------------------*/

#ifndef __CMDXTOOL_H__
#define __CMDXTOOL_H__

#include <objbase.h>

#ifdef INIT
#include <initguid.h>
#endif /* INIT */

#include "IMDXTool.h"


// {DA64DF80-8A6C-11d1-B197-006097BAFA72}
DEFINE_GUID(CMDXTool_CLSID, 
0xda64df80, 0x8a6c, 0x11d1, 0xb1, 0x97, 0x0, 0x60, 0x97, 0xba, 0xfa, 0x72);

typedef struct
{
IMDXTool Im;
int cRef;

WORD	m_wMuteFlag;
WORD	m_wVolFlag;
WORD	m_wUserTempo;
WORD	m_wActifTempo;
char    m_cMainVolume;
char    m_cFadeCoeff;  //0..127
char    m_cEndFadingVol;
long int m_lSlopeFading; // (dVol*10e6)/(dRt/1000)

char    m_cFading;     //boolean
REFERENCE_TIME m_rtEndFadingTime; //time when fading should end
char	m_vol[16];     //incremental volume
char	m_CurrVol[16]; //before mainVolume is applied, after incremental volume is applied
char	m_RefVol[16];  //before incremental volume is applied (modified by volume change msg)
void    ( _stdcall *pFadeCallback)(); //callback called when fading ends
} CMDXTool;

/*
Function prototypes, used to set up a VTable within
our class factory
*/
IMDXTool * fnpGetTool();
void fnvReleaseTool();

HRESULT _stdcall CMDXToolQueryInterface(IMDXTool *pIm, REFIID iid, void **ppv);
ULONG   _stdcall CMDXToolAddRef( IMDXTool *pIm);
ULONG   _stdcall CMDXToolRelease(IMDXTool *pIm);

HRESULT _stdcall CMDXToolInit(IMDXTool *pIm,IDirectMusicGraph* pGraph) ;
HRESULT _stdcall CMDXToolGetMsgDeliveryType(IMDXTool *pIm,DWORD* pdwDeliveryType ) ;
HRESULT _stdcall CMDXToolGetMediaTypeArraySize(IMDXTool *pIm,DWORD* pdwNumElements ) ;
HRESULT _stdcall CMDXToolGetMediaTypes(IMDXTool *pIm,DWORD** padwMediaTypes, DWORD dwNumElements) ;
HRESULT _stdcall CMDXToolProcessPMsg(IMDXTool *pIm,IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMsg) ;
HRESULT _stdcall CMDXToolFlush(IMDXTool *pIm,IDirectMusicPerformance* pPerf, DMUS_PMSG* pDMUS_PMSG, REFERENCE_TIME rt) ;

void	_stdcall SetUserTempo(IMDXTool *pIm,WORD wUserTempo);
void	_stdcall SetMuteFlag(IMDXTool *pIm,WORD wMuteFlag);
void	_stdcall SetVolFlag(IMDXTool *pIm,WORD wVolFlag);
void	_stdcall SetVolValue(IMDXTool *pIm,int iChannel,char newValue);
void	_stdcall SetMainVolValue(IMDXTool *pIm,char newValue);
char	_stdcall GetMainVolValue(IMDXTool *pIm);
char	_stdcall GetFadeCoeff(IMDXTool *pIm);

void    _stdcall DoFade(IMDXTool *pIm, IDirectMusicPerformance* pPerf, char cBeginVolValue, char cEndVolValue, DWORD dwTimeFade, void *pCallback);
void    _stdcall EndFade(IMDXTool *pIm);
char	_stdcall IsFading(IMDXTool *pIm);




#endif /*CMDXTool_H */

/* End of file CMDXTool.h */
