MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SetEnvSound

Method SetEnvSound

engine/Poseidon/Audio/SoundScene.cpp:598–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598void SoundScene::SetEnvSound(const char* name, float volume)
599{
600 // see if sound can be reused
601 if (!name || !*name)
602 {
603 return; // no sound
604 }
605 char lowName[256];
606 snprintf(lowName, sizeof(lowName), "%s", (const char*)name);
607 strlwr(lowName);
608 int i;
609 for (i = 0; i < MaxEnvSounds; i++)
610 {
611 IWave* snd = _envSounds[i];
612 if (snd && !strcmp(snd->Name(), lowName))
613 {
614 snd->SetVolume(volume * EnvMagicConstant);
615 snd->SetAccommodation(_earAccommodation * _soundVolume);
616 // call play, this ensures streaming sounds are streaming
617 snd->Play();
618 _envSoundRenewed[i] = true;
619 return;
620 }
621 }
622 // no sound found, we have to set new
623 // there must be one free slot
624 for (i = 0; i < MaxEnvSounds; i++)
625 {
626 if (!_envSounds[i])
627 {
628 IWave* snd = GSoundsys->CreateWave(lowName, false);
629 if (snd)
630 {
631 snd->SetAccommodation(_earAccommodation * _soundVolume);
632 snd->SetVolume(volume * EnvMagicConstant);
633 snd->Play();
634 _envSounds[i] = snd;
635 _envSoundRenewed[i] = true;
636 }
637 break;
638 }
639 }
640}
641
642void SoundScene::AdvanceEnvSounds()
643{

Callers 1

PerformSoundMethod · 0.80

Calls 6

strlwrFunction · 0.50
NameMethod · 0.45
SetVolumeMethod · 0.45
SetAccommodationMethod · 0.45
PlayMethod · 0.45
CreateWaveMethod · 0.45

Tested by

no test coverage detected