OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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:
41  C4SoundSystem();
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; // TODO: Add a hash map for sound lookup. Also add a global list for all running sound instances.
58  void ClearEffects();
59  C4SoundEffect* GetEffect(const char *szSound);
60  int32_t RemoveEffect(const char *szFilename);
61 };
62 
63 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);
64 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);
65 C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj);
66 void StopSoundEffect(const char *szSndName, C4Object *pObj);
67 void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel);
68 void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan);
69 void SoundPitch(const char *szSndName, C4Object *pObj, int32_t iPitch);
70 void SoundUpdate(C4SoundInstance *inst, int32_t iLevel, int32_t iPitch);
71 
72 #endif
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)
C4SoundEffect * GetFirstSound() const
Definition: C4SoundSystem.h:52
int32_t LoadEffects(C4Group &hGroup, const char *namespace_prefix, bool group_is_root)
const int32_t C4NearSoundRadius
Definition: C4SoundSystem.h:29
C4SoundEffect * GetEffect(const char *szSound)
const int32_t C4MaxSoundName
Definition: C4SoundSystem.h:27
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)
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
C4SoundInstance * GetNextInstance(C4SoundInstance *prev) const
void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan)
C4SoundInstance * GetSoundInstance(const char *szSndName, C4Object *pObj)
const int32_t C4MaxSoundInstances
Definition: C4SoundSystem.h:28
C4SoundEffect * FirstSound
Definition: C4SoundSystem.h:57
void SoundPitch(const char *szSndName, C4Object *pObj, int32_t iPitch)
const int32_t C4AudibilityRadius
Definition: C4SoundSystem.h:30
void StopSoundEffect(const char *szSndName, C4Object *pObj)
C4SoundInstance * GetFirstInstance() const
C4Group SoundFile
Definition: C4SoundSystem.h:56
const int32_t SoundUnloadTime
Definition: C4SoundSystem.h:32
const int32_t SoundMaxUnloadSize
Definition: C4SoundSystem.h:32
void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel)
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)
void ClearPointers(C4Object *pObj)
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
int32_t RemoveEffect(const char *szFilename)