/***************************************************************************
 *
 * softmix.h
 *
 ***************************************************************************
 *
 * high level interface to software mixing routines
 *
 ***************************************************************************/

#ifndef SOFTMIX_H_INCLUDED
#define SOFTMIX_H_INCLUDED

/*
 * includes
 */

/*
 * defines
 */

#define	BEN2S(x)	(logTable [ (unsigned  char)(x)      ])
#define	S2BEN(x)	(iLogTable[((unsigned short)(x)) >> 3])

/*
 * typedefs
 */

/*
 * structures
 */

struct resSample
{
	unsigned long flags;
	unsigned long length;
	unsigned long lpStart;
	unsigned long lpEnd;
	unsigned long freq;
	unsigned long fade;
	unsigned char data[1];
};

struct resSampleBlock
{
	unsigned long flags;
	unsigned long length;
	unsigned long lpStart;
	unsigned long lpEnd;
	unsigned long freq;
	unsigned long fade;
	unsigned long blockCount;
	unsigned long blockAlign;
	unsigned char data[1];
};

/*
 * globals
 */

extern signed short logTable[];
extern unsigned char iLogTable[];

/*
 * function prototypes
 */

extern int	SoftMixQuery(int *numChannels,int *mode,int *freq);
extern int	SoftMixOpen(int numChannels,int mode,int freq,int flags);
extern void	SoftMixClose(void);
extern int	SoftMixRegisterSample(char *sampleName);
extern int  	SoftMixRegisterSampleDirect(unsigned short *data,int len,int lpStart,int lpEnd,int freq);
extern int	SoftMixRegisterSampleByID(int id);
extern void	SoftMixUnRegisterSample(int sampleHandle);
extern void	SoftMixUnRegisterAll(void);
extern void	SoftMixQuerySample(int sampleHandle,struct sampleParms *s);
extern void	SoftMixUpdateSample(int sampleHandle,struct sampleParms *s);
extern void	SoftMixSetChannelSample(int channel,int sampleHandle);
extern void	SoftMixSetChannelFreq(int channel,int freq);
extern void	SoftMixSetChannelVol(int channel,int vol);
extern void	SoftMixSetChannelPan(int channel,int pan);
extern void	SoftMixSetChannelOffset(int channel,int offset);
extern int	SoftMixGetChannelOffset(int channel);
extern void	SoftMixSetChannelStatus(int channel,int status);
extern int	SoftMixGetChannelStatus(int channel);
extern int	SoftMixGetSampleCount(void);
extern void	SoftMixDoMix(signed long *mixBuf,unsigned long count);
extern void	SoftMixDoMixDown(signed long *mixBuf,unsigned char *dest,unsigned long count);
extern int	SoftMixReverbOpen(int size);
extern void	SoftMixReverbSetDepth(int d);
extern void	SoftMixReverbClose(void);
extern void	SoftMixUpdateSampleData(int sampleHandle,unsigned short *data,int len);

extern void	SoftMixSetCompressionHandler(struct resSample *(*ptr)(struct resSample *));
extern void	SoftMixSetTmpBuffer(unsigned char *buf,int len);

#endif

