#ifndef _CSOUND_H_
#define _CSOUND_H_

// DODELAT : funkci LOAD, a odchytani errors, construktory, const

#pragma comment(lib, "fmodvc.lib") 
#include <fmod347/fmod.h>

#include <VECTOR>
#include "../GLDef.h"
#include "../App/engineH.h"

typedef unsigned int SOUND_TYP;

const int SOUND_TYP_SONG	= 0;
const int SOUND_TYP_SAMPLE	= 1;
const int SOUND_TYP_STREAM	= 2;


struct TSoundData
{
	int				typ;
	unsigned int	id;
	FSOUND_SAMPLE	*sample;
	FSOUND_STREAM	*stream;
	FMUSIC_MODULE	*song;
	int				iChannel;
	bool			bPause;
	UCHAR			volume;
};

class C_SOUND_0
{
private :
	bool					_init; // 1-vpohode, 0-nee
	std::vector<TSoundData>	_vData;
	std::string				_sError;
	int						_iMaxChannels;
	unsigned int			_id;
	bool					_startPauseId;
	UCHAR					_volumeAll;

	void					_SetError(std::string text);
	std::string				_GetPripona(std::string name);
	
public :
	C_SOUND_0();
	~C_SOUND_0();

public :
	bool		Init();
	void		End(); // automaticky se vola v destruktoru
	int			Load(std::string fileName);
	int			LoadSong(std::string fileName);
	int			LoadSample2d(std::string fileName);
	int			LoadStream(std::string fileName);
	
	int			LoadSample3d(std::string fileName);
	void		PlayLoop3d(SOUND_TYP id);

	void		Play(SOUND_TYP id);
	bool		PlayLoop(SOUND_TYP id);
	void		Play3d(SOUND_TYP id);
	void		SetAttributes3DId(SOUND_TYP id, float pos[3], float vel[3]);

	void		SetSFXVolume(unsigned char vol);
	void		SetVolumeId(SOUND_TYP id, unsigned char vol);
	void		SetVolumeAll(unsigned char vol);
	void		PauseId(SOUND_TYP id, bool b);
	void		PauseAll( bool b );
	bool		GetPauseId(SOUND_TYP id);
	void		SetStopId(SOUND_TYP id);
	void		SetStopAll( );
	std::string GetErrorString();
	void		SetStartPauseId( bool pause ) {_startPauseId = pause;}

};

#endif //_CSOUND_H_