#ifndef FMOD_WRAPPER_H
#define FMOD_WRAPPER_H
#include <windows.h>
/**
 * FMOD wrapper based on Put Put Cars' code.
 * Used to be able to move the fmod dll everywhere
 */
#define FMOD_WRAPPER(type, name, params) type (__stdcall *FWRAPPER_##name)params
class FMODWrapper
{
public:
	int Init();
	void DeInit();
	// Edited by Pcjoe
	FMOD_WRAPPER(signed char, Init, (int mixrate, int maxsoftwarechannels, unsigned int flags));
	FMOD_WRAPPER(void, Close, ());
	FMOD_WRAPPER(float, GetVersion, ());
	FMOD_WRAPPER(int, GetError, ());
	FMOD_WRAPPER(signed char, SetPaused, (int channel, signed char paused));
	FMOD_WRAPPER(FSOUND_STREAM *, Stream_Open, (const char *name_or_data, unsigned int mode, int offset, int length));
	FMOD_WRAPPER(signed char, Stream_SetEndCallback, (FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata));
	FMOD_WRAPPER(int, Stream_Play, (int channel, FSOUND_STREAM *stream));
	FMOD_WRAPPER(signed char, SetPan, (int channel, int pan));
	FMOD_WRAPPER(signed char, Stream_Stop, (FSOUND_STREAM *stream));
	FMOD_WRAPPER(signed char, Stream_Close, (FSOUND_STREAM *stream));
	FMOD_WRAPPER(int, Stream_GetTime, (FSOUND_STREAM *stream));

	// added by Pcjoe
	FMOD_WRAPPER(signed char, SetVolumeAbsolute, (int channel, int vol));
	// 3D
	FMOD_WRAPPER(void, 3D_Listener_SetAttributes, (const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz));
	FMOD_WRAPPER(signed char, 3D_SetAttributes, (int channel, const float *pos, const float *vel));
	FMOD_WRAPPER(signed char, 3D_SetMinMaxDistance, (int channel, float min, float max));
	FMOD_WRAPPER(void, Update, ());
	// Samples
	FMOD_WRAPPER(FSOUND_SAMPLE *, Sample_Load, (int index, const char *name_or_data, unsigned int inputmode, int offset,	int length));
	FMOD_WRAPPER(void , Sample_Free, (FSOUND_SAMPLE *sptr));
	FMOD_WRAPPER(const char *, Sample_GetName, (FSOUND_SAMPLE *sptr));
	FMOD_WRAPPER(int, PlaySound, (int channel,FSOUND_SAMPLE *sptr));
	FMOD_WRAPPER(signed char, StopSound, (int channel));
	FMOD_WRAPPER(FSOUND_SAMPLE *, GetCurrentSample, (int channel));
	FMOD_WRAPPER(signed char, IsPlaying, (int channel));
	// Streams
	FMOD_WRAPPER(int, Stream_GetLengthMs, (FSOUND_STREAM *stream));
	FMOD_WRAPPER(signed char, Stream_SetTime, (FSOUND_STREAM *stream, int ms));

	// Is Loaded
	bool isLoaded( void ) { return m_bLoaded; }
private:
	HINSTANCE	m_hFMod;
	bool		m_bLoaded;
};
#endif