OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4SoundSystem.cpp File Reference
Include dependency graph for C4SoundSystem.cpp:

Go to the source code of this file.

Functions

C4SoundInstanceStartSoundEffect (const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
 
C4SoundInstanceStartSoundEffectAt (const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume, int32_t iCustomFallofDistance, int32_t iPitch, C4SoundModifier *modifier)
 
C4SoundInstanceGetSoundInstance (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)
 
void SoundPitch (const char *szSndName, C4Object *pObj, int32_t iPitch)
 
void SoundUpdate (C4SoundInstance *pInst, int32_t iLevel, int32_t iPitch)
 

Function Documentation

C4SoundInstance* GetSoundInstance ( const char *  szSndName,
C4Object pObj 
)

Definition at line 281 of file C4SoundSystem.cpp.

References Application, C4SoundSystem::FindInstance(), and C4Application::SoundSystem.

282 {
283  return Application.SoundSystem.FindInstance(szSndName, pObj);
284 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

void SoundLevel ( const char *  szSndName,
C4Object pObj,
int32_t  iLevel 
)

Definition at line 294 of file C4SoundSystem.cpp.

References Application, C4SoundInstance::Execute(), C4SoundSystem::FindInstance(), C4SoundInstance::SetVolume(), C4Application::SoundSystem, StartSoundEffect(), and StopSoundEffect().

295 {
296  // Sound level zero? Stop
297  if (!iLevel) { StopSoundEffect(szSndName, pObj); return; }
298  // Find or create instance
299  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
300  if (!pInst) pInst = StartSoundEffect(szSndName, true, iLevel, pObj);
301  if (!pInst) return;
302  // Set volume
303  pInst->SetVolume(iLevel);
304  pInst->Execute();
305 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void StopSoundEffect(const char *szSndName, C4Object *pObj)
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
void SetVolume(int32_t inVolume)
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

void SoundPan ( const char *  szSndName,
C4Object pObj,
int32_t  iPan 
)

Definition at line 307 of file C4SoundSystem.cpp.

References Application, C4SoundInstance::Execute(), C4SoundSystem::FindInstance(), C4SoundInstance::SetPan(), and C4Application::SoundSystem.

308 {
309  // Find instance
310  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
311  if (!pInst) return;
312  // Set pan
313  pInst->SetPan(iPan);
314  pInst->Execute();
315 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void SetPan(int32_t inPan)
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

void SoundPitch ( const char *  szSndName,
C4Object pObj,
int32_t  iPitch 
)

Definition at line 317 of file C4SoundSystem.cpp.

References Application, C4SoundInstance::Execute(), C4SoundSystem::FindInstance(), C4SoundInstance::SetPitch(), and C4Application::SoundSystem.

318 {
319  // Find instance
320  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
321  if (!pInst) return;
322  // Set pitch
323  pInst->SetPitch(iPitch);
324  pInst->Execute();
325 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
void SetPitch(int32_t inPitch)
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

void SoundUpdate ( C4SoundInstance pInst,
int32_t  iLevel,
int32_t  iPitch 
)

Definition at line 327 of file C4SoundSystem.cpp.

References C4SoundInstance::Execute(), C4SoundInstance::SetPitch(), and C4SoundInstance::SetVolume().

328 {
329  // Set sound data
330  pInst->SetVolume(iLevel);
331  pInst->SetPitch(iPitch);
332  // Ensure it's reflected in audio engine
333  pInst->Execute();
334 }
void SetPitch(int32_t inPitch)
void SetVolume(int32_t inVolume)

Here is the call graph for this function:

C4SoundInstance* StartSoundEffect ( const char *  szSndName,
bool  fLoop,
int32_t  iVolume,
C4Object pObj,
int32_t  iCustomFalloffDistance,
int32_t  iPitch,
C4SoundModifier modifier 
)

Definition at line 261 of file C4SoundSystem.cpp.

References Application, Config, C4SoundSystem::NewEffect(), C4ConfigSound::RXSound, C4Config::Sound, and C4Application::SoundSystem.

Referenced by C4ViewportList::CloseViewport(), C4ControlEMMoveObject::CreateObject(), C4ViewportList::CreateViewport(), C4Object::DirectComContents(), C4Player::DoWealth(), C4Player::Eliminate(), C4Object::ExecLife(), C4GUI::GUISound(), C4GameLobby::MainDlg::OnCountdownPacket(), C4GameLobby::MainDlg::OnError(), C4Object::Promote(), C4Game::QuickSave(), C4Object::SetAction(), C4Player::SetHostility(), SoundLevel(), StartSoundEffectAt(), and C4Player::Surrender().

262 {
263  // Sound check
264  if (!Config.Sound.RXSound) return nullptr;
265  // Start new
266  return Application.SoundSystem.NewEffect(szSndName, fLoop, iVolume, pObj, iCustomFalloffDistance, iPitch, modifier);
267 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4Config Config
Definition: C4Config.cpp:833
int32_t RXSound
Definition: C4Config.h:126
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)
C4ConfigSound Sound
Definition: C4Config.h:254
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

C4SoundInstance* StartSoundEffectAt ( const char *  szSndName,
int32_t  iX,
int32_t  iY,
int32_t  iVolume,
int32_t  iCustomFallofDistance,
int32_t  iPitch,
C4SoundModifier modifier 
)

Definition at line 269 of file C4SoundSystem.cpp.

References Config, C4ConfigSound::RXSound, C4SoundInstance::SetVolumeByPos(), C4Config::Sound, and StartSoundEffect().

270 {
271  // Sound check
272  if (!Config.Sound.RXSound) return nullptr;
273  // Create
274  C4SoundInstance *pInst = StartSoundEffect(szSndName, false, iVolume, nullptr, iCustomFallofDistance, iPitch, modifier);
275  // Set volume by position
276  if (pInst) pInst->SetVolumeByPos(iX, iY);
277  // Return
278  return pInst;
279 }
C4Config Config
Definition: C4Config.cpp:833
int32_t RXSound
Definition: C4Config.h:126
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4ConfigSound Sound
Definition: C4Config.h:254
void SetVolumeByPos(int32_t x, int32_t y)

Here is the call graph for this function:

void StopSoundEffect ( const char *  szSndName,
C4Object pObj 
)

Definition at line 286 of file C4SoundSystem.cpp.

References Application, C4SoundSystem::FindInstance(), C4Application::SoundSystem, and C4SoundInstance::Stop().

Referenced by C4Object::SetAction(), and SoundLevel().

287 {
288  // Find instance
289  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
290  if (!pInst) return;
291  // Stop
292  pInst->Stop();
293 }
C4SoundSystem SoundSystem
Definition: C4Application.h:42
C4SoundInstance * FindInstance(const char *szSound, C4Object *pObj)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function: