OpenClonk
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

◆ GetSoundInstance()

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

Definition at line 283 of file C4SoundSystem.cpp.

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

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

Here is the call graph for this function:

◆ SoundLevel()

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

Definition at line 296 of file C4SoundSystem.cpp.

297 {
298  // Sound level zero? Stop
299  if (!iLevel) { StopSoundEffect(szSndName, pObj); return; }
300  // Find or create instance
301  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
302  if (!pInst) pInst = StartSoundEffect(szSndName, true, iLevel, pObj);
303  if (!pInst) return;
304  // Set volume
305  pInst->SetVolume(iLevel);
306  pInst->Execute();
307 }
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)

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

Here is the call graph for this function:

◆ SoundPan()

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

Definition at line 309 of file C4SoundSystem.cpp.

310 {
311  // Find instance
312  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
313  if (!pInst) return;
314  // Set pan
315  pInst->SetPan(iPan);
316  pInst->Execute();
317 }
void SetPan(int32_t inPan)

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

Here is the call graph for this function:

◆ SoundPitch()

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

Definition at line 319 of file C4SoundSystem.cpp.

320 {
321  // Find instance
322  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
323  if (!pInst) return;
324  // Set pitch
325  pInst->SetPitch(iPitch);
326  pInst->Execute();
327 }
void SetPitch(int32_t inPitch)

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

Here is the call graph for this function:

◆ SoundUpdate()

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

Definition at line 329 of file C4SoundSystem.cpp.

330 {
331  // Set sound data
332  pInst->SetVolume(iLevel);
333  pInst->SetPitch(iPitch);
334  // Ensure it's reflected in audio engine
335  pInst->Execute();
336 }

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

Here is the call graph for this function:

◆ StartSoundEffect()

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

Definition at line 263 of file C4SoundSystem.cpp.

264 {
265  // Sound check
266  if (!Config.Sound.RXSound) return nullptr;
267  // Start new
268  return Application.SoundSystem.NewEffect(szSndName, fLoop, iVolume, pObj, iCustomFalloffDistance, iPitch, modifier);
269 }
C4Config Config
Definition: C4Config.cpp:930
C4ConfigSound Sound
Definition: C4Config.h:258
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)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartSoundEffectAt()

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 271 of file C4SoundSystem.cpp.

272 {
273  // Sound check
274  if (!Config.Sound.RXSound) return nullptr;
275  // Create
276  C4SoundInstance *pInst = StartSoundEffect(szSndName, false, iVolume, nullptr, iCustomFallofDistance, iPitch, modifier);
277  // Set volume by position
278  if (pInst) pInst->SetVolumeByPos(iX, iY, iVolume);
279  // Return
280  return pInst;
281 }
void SetVolumeByPos(int32_t x, int32_t y, int32_t relative_volume=100)

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

Here is the call graph for this function:

◆ StopSoundEffect()

void StopSoundEffect ( const char *  szSndName,
C4Object pObj 
)

Definition at line 288 of file C4SoundSystem.cpp.

289 {
290  // Find instance
291  C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
292  if (!pInst) return;
293  // Stop
294  pInst->Stop();
295 }

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

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

Here is the call graph for this function:
Here is the caller graph for this function: