forked from Mirrors/openclonk
Remove implementation details from C4SoundSystem.h
This eliminates the need to include Audio toolkit headers from there.issue1247
parent
69f8ca27ec
commit
86842da9bd
|
@ -17,6 +17,7 @@
|
|||
#define INC_C4SoundLoaders
|
||||
|
||||
#include <vector>
|
||||
#include <C4SoundIncludes.h>
|
||||
#include <C4SoundSystem.h>
|
||||
|
||||
namespace C4SoundLoaders
|
||||
|
|
|
@ -26,12 +26,70 @@
|
|||
#include <C4Config.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4Viewport.h>
|
||||
#include <C4SoundIncludes.h>
|
||||
#include <C4SoundLoaders.h>
|
||||
|
||||
#if AUDIO_TK == AUDIO_TK_SDL_MIXER
|
||||
#define USE_RWOPS
|
||||
#include <SDL_mixer.h>
|
||||
#endif
|
||||
class C4SoundEffect
|
||||
{
|
||||
friend class C4SoundInstance;
|
||||
public:
|
||||
C4SoundEffect();
|
||||
~C4SoundEffect();
|
||||
public:
|
||||
char Name[C4MaxSoundName+1];
|
||||
int32_t Instances;
|
||||
int32_t SampleRate, Length;
|
||||
C4SoundHandle pSample;
|
||||
C4SoundInstance *FirstInst;
|
||||
C4SoundEffect *Next;
|
||||
public:
|
||||
void Clear();
|
||||
bool Load(const char *szFileName, C4Group &hGroup);
|
||||
bool Load(BYTE *pData, size_t iDataLen, bool fRaw=false); // load directly from memory
|
||||
void Execute();
|
||||
C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0);
|
||||
C4SoundInstance *GetInstance(C4Object *pObj);
|
||||
void ClearPointers(C4Object *pObj);
|
||||
int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad); // local
|
||||
int32_t GetStartedInstanceCount(); // global
|
||||
protected:
|
||||
void AddInst(C4SoundInstance *pInst);
|
||||
void RemoveInst(C4SoundInstance *pInst);
|
||||
};
|
||||
|
||||
class C4SoundInstance
|
||||
{
|
||||
friend class C4SoundEffect;
|
||||
protected:
|
||||
C4SoundInstance();
|
||||
public:
|
||||
~C4SoundInstance();
|
||||
protected:
|
||||
C4SoundEffect *pEffect;
|
||||
int32_t iVolume, iPan, iChannel;
|
||||
C4TimeMilliseconds tStarted;
|
||||
int32_t iNearInstanceMax;
|
||||
bool fLooping;
|
||||
C4Object *pObj;
|
||||
int32_t iFalloffDistance;
|
||||
C4SoundInstance *pNext;
|
||||
public:
|
||||
C4Object *getObj() const { return pObj; }
|
||||
bool isStarted() const { return iChannel != -1; }
|
||||
void Clear();
|
||||
bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0);
|
||||
bool CheckStart();
|
||||
bool Start();
|
||||
bool Stop();
|
||||
bool Playing();
|
||||
void Execute();
|
||||
void SetVolume(int32_t inVolume) { iVolume = inVolume; }
|
||||
void SetPan(int32_t inPan) { iPan = inPan; }
|
||||
void SetVolumeByPos(int32_t x, int32_t y);
|
||||
void SetObj(C4Object *pnObj) { pObj = pnObj; }
|
||||
void ClearPointers(C4Object *pObj);
|
||||
bool Inside(int32_t iX, int32_t iY, int32_t iRad);
|
||||
};
|
||||
|
||||
using namespace C4SoundLoaders;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define INC_C4SoundSystem
|
||||
|
||||
#include <C4Group.h>
|
||||
#include <C4SoundIncludes.h>
|
||||
|
||||
const int32_t
|
||||
C4MaxSoundName=100,
|
||||
|
@ -29,73 +28,11 @@ const int32_t
|
|||
C4NearSoundRadius=50,
|
||||
C4AudibilityRadius=700;
|
||||
|
||||
class C4Object;
|
||||
class C4SoundInstance;
|
||||
|
||||
class C4SoundEffect
|
||||
{
|
||||
friend class C4SoundInstance;
|
||||
public:
|
||||
C4SoundEffect();
|
||||
~C4SoundEffect();
|
||||
public:
|
||||
char Name[C4MaxSoundName+1];
|
||||
int32_t Instances;
|
||||
int32_t SampleRate, Length;
|
||||
C4SoundHandle pSample;
|
||||
C4SoundInstance *FirstInst;
|
||||
C4SoundEffect *Next;
|
||||
public:
|
||||
void Clear();
|
||||
bool Load(const char *szFileName, C4Group &hGroup);
|
||||
bool Load(BYTE *pData, size_t iDataLen, bool fRaw=false); // load directly from memory
|
||||
void Execute();
|
||||
C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0);
|
||||
C4SoundInstance *GetInstance(C4Object *pObj);
|
||||
void ClearPointers(C4Object *pObj);
|
||||
int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad); // local
|
||||
int32_t GetStartedInstanceCount(); // global
|
||||
protected:
|
||||
void AddInst(C4SoundInstance *pInst);
|
||||
void RemoveInst(C4SoundInstance *pInst);
|
||||
};
|
||||
|
||||
class C4SoundInstance
|
||||
{
|
||||
friend class C4SoundEffect;
|
||||
protected:
|
||||
C4SoundInstance();
|
||||
public:
|
||||
~C4SoundInstance();
|
||||
protected:
|
||||
C4SoundEffect *pEffect;
|
||||
int32_t iVolume, iPan, iChannel;
|
||||
C4TimeMilliseconds tStarted;
|
||||
int32_t iNearInstanceMax;
|
||||
bool fLooping;
|
||||
C4Object *pObj;
|
||||
int32_t iFalloffDistance;
|
||||
C4SoundInstance *pNext;
|
||||
public:
|
||||
C4Object *getObj() const { return pObj; }
|
||||
bool isStarted() const { return iChannel != -1; }
|
||||
void Clear();
|
||||
bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0);
|
||||
bool CheckStart();
|
||||
bool Start();
|
||||
bool Stop();
|
||||
bool Playing();
|
||||
void Execute();
|
||||
void SetVolume(int32_t inVolume) { iVolume = inVolume; }
|
||||
void SetPan(int32_t inPan) { iPan = inPan; }
|
||||
void SetVolumeByPos(int32_t x, int32_t y);
|
||||
void SetObj(C4Object *pnObj) { pObj = pnObj; }
|
||||
void ClearPointers(C4Object *pObj);
|
||||
bool Inside(int32_t iX, int32_t iY, int32_t iRad);
|
||||
};
|
||||
|
||||
const int32_t SoundUnloadTime=60, SoundMaxUnloadSize=100000;
|
||||
|
||||
class C4SoundInstance;
|
||||
class C4SoundEffect;
|
||||
|
||||
class C4SoundSystem
|
||||
{
|
||||
public:
|
||||
|
@ -116,9 +53,9 @@ protected:
|
|||
int32_t RemoveEffect(const char *szFilename);
|
||||
};
|
||||
|
||||
class C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj=NULL, int32_t iCustomFalloffDistance=0);
|
||||
class C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance=0);
|
||||
class C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj);
|
||||
C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj=NULL, int32_t iCustomFalloffDistance=0);
|
||||
C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance=0);
|
||||
C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj);
|
||||
void StopSoundEffect(const char *szSndName, C4Object *pObj);
|
||||
void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel);
|
||||
void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan);
|
||||
|
|
Loading…
Reference in New Issue