Use this on "YOUR OWN RISK"!!!
Will be continued!!!
About
FMOD
Custom data types
Custom class Sound Manager
Use FMOD in your own game
Last versio :3.6
FMOD, FMOD is the fastest, most powerful
and easiest to use sound system on Windows, Linux, and Windows CE
there is, and now Macintosh, PS2 & XBox!. FMOD supports 3d
sound, midi, mods, mp3, ogg vorbis, wma, aiff, recording,
obstruction/occlusion, cd playback, mmx, internet streaming, dsp
effects, spectrum analysis, user created samples and streams,
synchronization support, ASIO, EAX 2&3, C/C++/VB/Delphi/MASM
and more. FMOD is not only the best cross platform audio engine
for your needs, but it is the best audio engine available on each
platform.
file: fmod site
Classes:SDI_LSR,SDI_Sample2d,SDI_Sample3d class SDI_LSR//loaded sound record
{
public:
SDI_LSR();
~SDI_LSR();
void Stop();
void Play(float*pos=NULL,float*vel=NULL,bool loop=false);
bool SetFileName(char*fn);
char*name; int m_id; int m_onchanel; unsigned int m_loop;
};
class SDI_Sample2d:public SDI_LSR
{
public:
SDI_Sample2d(){m_pts=NULL;}
~SDI_Sample2d(){FSOUND_Sample_Free(m_pts);}
FSOUND_SAMPLE*m_pts;
};
class SDI_Sample3d:public SDI_LSR
{
public:
SDI_Sample3d(){m_pts=NULL;}
~SDI_Sample3d(){FSOUND_Sample_Free(m_pts);}
FSOUND_SAMPLE*m_pts; float m_pos[3]; float m_vel[3];
};
class SDI_Sound_Man
{
public: //here init class functors
SDI_Sound_Man(int mixrate,int maxhc=32);
~SDI_Sound_Man();
bool Init(int soundsystype,int driver);
void ShutDown();
void Update();//all
//here sounds functors
bool Play2d(int id,int onchanel=-1,bool looped=false);
bool Play3d(int id,float*pos,float*vel,int onchanel=-1,bool looped=false);
void Stop(int id=-1);//-1=all sounds
SDI_LSR* Load2d(int id,char*failname,int tochanel=1,bool syssound=false);
SDI_LSR* Load3d(int id,char*failname,int tochanel=2,bool syssound=false);
void Unload2d(int id=-1);//-1=all 2dsounds
void Unload3d(int id=-1);//-1=all 3dsounds
//here add listener functors
void SDI_Listener3D_Attributes(float *pos,float *vel=NULL, bool usevelosity=false);
private:
bool m_fmodok;
bool m_driversuportHD;
int m_chanel2d,m_chanel3d;
int m_mixrate;
int SDI_CMaxS,//count sounds in game
SDI_CMaxHC,//count hardware 3d chanels
SDI_CMaxSC;//count software 2d chanels
//posible
int SDI_MaxS,//maximum sounds in game
SDI_MaxHC,//maximum hardware 3d chanels
SDI_MaxSC;//maximum software 2d chanels
float m_listenert;
float m_listenerlastpos[3];
float m_listenervel[3];
};
Create only one instance of:
#include "SDI_Sound_BFM.h"
SDI_Sound_Man *gv_soundmanager=NULL;
Then in some place of your initializations allocate new object:
gv_soundmanager=new SDI_Sound_Man(44100,32);
if(gv_soundmanager)
{
if(!gv_soundmanager->Init(1,1))
{
gv_console.SetMsgToCons("log","Sound FMOD initialization failed:Will run out any sounds\n");
} else
{
gv_console.SetMsgToCons("log","FMOD Init Ok\n");
gv_soundmanager->Load2d(1,"data/sys/sounds/thunder&rain.wav",1,true);
gv_soundmanager->Load2d(2,"data/sys/sounds/JailDoor.wav",0,true);
gv_soundmanager->Load2d(3,"data/sys/sounds/SpaceHatch.wav",0,true);
gv_soundmanager->Load3d(4,"data/sys/sounds/HighVoltage.wav",2,true);
gv_soundmanager->Play2d(1,1,true);
gv_soundmanager.Play3d(4,NULL,NULL,2,true);
}
}
Then in WinMain function each loop after or before rendering do:
if(gv_soundmanager)gv_soundmanager->Update();
That all - see source files :)
file:SDI_FMOD_OP.zip