Пример #1
0
  void SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
  {
    float min, max;
    const std::string &file = lookup(soundId, volume, min, max);
    if (file != "")
    {
        SoundPtr snd = mgr->load(file);
        snd->setRepeat(loop);
        snd->setVolume(volume);
        snd->setRange(min,max);
        snd->setPitch(pitch);
        snd->setRelative(true);
        snd->play();

        if (loop)
        {
            // Only add the looping sound once
            IDMap::iterator it = mLoopedSounds.find(soundId);
            if(it == mLoopedSounds.end())
            {
                mLoopedSounds[soundId] = WSoundPtr(snd);
            }
        }
    }
  }
Пример #2
0
    // Add a sound to the list and play it
    void SoundManager::add(const std::string &file,
             MWWorld::Ptr ptr,
             const std::string &id,
             float volume, float pitch,
             float min, float max,
             bool loop, bool untracked)
    {
      try
        {
          SoundPtr snd = mgr->load(file);
          snd->setRepeat(loop);
          snd->setVolume(volume);
          snd->setPitch(pitch);
          snd->setRange(min,max);
          setPos(snd, ptr);
          snd->play();

          if (!untracked)
          {
            sounds[ptr][id] = WSoundPtr(snd);
          }
        }
      catch(...)
        {
          std::cout << "Error loading " << file << ", skipping.\n";
        }
    }
Пример #3
0
 void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
 {
   if(!mData) return;
   // Play and forget
   float min, max;
   const std::string &file = mData->lookup(soundId, volume, min, max);
   if(file != "")
     {
       SoundPtr snd = mData->mgr->load(file);
       snd->setVolume(volume);
       snd->setRange(min,max);
       snd->setPitch(pitch);
       snd->play();
     }
 }