Game Development Reference
In-Depth Information
public:
SoundProcess(
shared_ptr<ResHandle> soundResource,
int typeOfSound=PROC_SOUNDFX,
int volume=100,
bool looping=false);
virtual ~SoundProcess();
virtual void VOnUpdate(const int deltaMilliseconds);
virtual void VOnInitialize();
virtual void VKill();
virtual void VTogglePause();
void
Play(const int volume, const bool looping);
void
Stop();
void
SetVolume(int volume);
int
GetVolume();
int
GetLengthMilli();
bool
IsSoundValid() { return m_SoundResource!=NULL; }
bool
IsPlaying();
bool
IsLooping() { return m_AudioBuffer->VIsLooping(); }
float
GetProgress();
protected:
SoundProcess(); //Disable Default Construction
void InitializeVolume();
void Replay() { m_bInitialUpdate = true; };
shared_ptr<ResHandle> m_SoundResource;
shared_ptr<IAudioBuffer> m_AudioBuffer;
int
m_Volume;
bool
m_isLooping;
};
This class provides a single object that manages individual sounds. Many of the
methods are re-implementations of some
IAudioBuffer
methods, and while this
isn
t the best C++ design, it can make things a little easier in your code.
As you might expect, the parameters to initialize this object are a
ResHandle
and
initial sound settings. One parameter needs a little explanation,
typeOfSound
.
Every process has a type, and sound processes use this to distinguish themselves
'