| 596 | } |
| 597 | |
| 598 | void 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 | |
| 642 | void SoundScene::AdvanceEnvSounds() |
| 643 | { |
no test coverage detected