OpenClonk
C4SoundSystem.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Handles the sound bank and plays effects */
19 
20 #ifndef INC_C4SoundSystem
21 #define INC_C4SoundSystem
22 
23 #include "c4group/C4Group.h"
25 
26 const int32_t
31 
32 const int32_t SoundUnloadTime=60, SoundMaxUnloadSize=100000;
33 
34 class C4SoundInstance;
35 class C4SoundEffect;
36 class C4SoundModifier;
37 
39 {
40 public:
43  void Clear();
44  void Execute();
45  int32_t LoadEffects(C4Group &hGroup, const char *namespace_prefix, bool group_is_root);
46  C4SoundInstance *NewEffect(const char *szSound, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr);
47  C4SoundInstance *FindInstance(const char *szSound, C4Object *pObj);
50  bool Init();
51  void ClearPointers(C4Object *pObj);
52  C4SoundEffect *GetFirstSound() const { return FirstSound; }
53 
55 protected:
57  C4SoundEffect *FirstSound{nullptr}; // TODO: Add a hash map for sound lookup. Also add a global list for all running sound instances.
58  bool initialized{false};
59  void ClearEffects();
60  C4SoundEffect* GetEffect(const char *szSound);
61  int32_t RemoveEffect(const char *szFilename);
62 };
63 
64 C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr);
65 C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr);
66 C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj);
67 void StopSoundEffect(const char *szSndName, C4Object *pObj);
68 void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel);
69 void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan);
70 void SoundPitch(const char *szSndName, C4Object *pObj, int32_t iPitch);
71 void SoundUpdate(C4SoundInstance *inst, int32_t iLevel, int32_t iPitch);
72 
73 #endif
const int32_t C4AudibilityRadius
Definition: C4SoundSystem.h:30
C4SoundInstance * StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume=100, int32_t iCustomFallofDistance=0, int32_t iPitch=0, C4SoundModifier *modifier=nullptr)
Definition: stub-handle.cpp:41
void SoundUpdate(C4SoundInstance *inst, int32_t iLevel, int32_t iPitch)
void StopSoundEffect(const char *szSndName, C4Object *pObj)
C4SoundInstance * GetSoundInstance(const char *szSndName, C4Object *pObj)
void SoundPitch(const char *szSndName, C4Object *pObj, int32_t iPitch)
const int32_t C4MaxSoundInstances
Definition: C4SoundSystem.h:28
void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan)
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop=false, int32_t iVolume=100, C4Object *pObj=nullptr, int32_t iCustomFalloffDistance=0, int32_t iPitch=0, C4SoundModifier *modifier=nullptr)
const int32_t C4NearSoundRadius
Definition: C4SoundSystem.h:29
const int32_t SoundUnloadTime
Definition: C4SoundSystem.h:32
void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel)
const int32_t SoundMaxUnloadSize
Definition: C4SoundSystem.h:32
const int32_t C4MaxSoundName
Definition: C4SoundSystem.h:27
int32_t RemoveEffect(const char *szFilename)
C4Group SoundFile
Definition: C4SoundSystem.h:56
C4SoundEffect * FirstSound
Definition: C4SoundSystem.h:57
C4SoundEffect * GetFirstSound() const
Definition: C4SoundSystem.h:52
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4SoundInstance * GetFirstInstance() const
C4SoundInstance * GetNextInstance(C4SoundInstance *prev) const
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
void ClearPointers(C4Object *pObj)
int32_t LoadEffects(C4Group &hGroup, const char *namespace_prefix, bool group_is_root)
C4SoundEffect * GetEffect(const char *szSound)
C4SoundInstance * NewEffect(const char *szSound, bool fLoop=false, int32_t iVolume=100, C4Object *pObj=nullptr, int32_t iCustomFalloffDistance=0, int32_t iPitch=0, C4SoundModifier *modifier=nullptr)