当前位置: 首页>>代码示例>>C++>>正文


C++ SoundPtr类代码示例

本文整理汇总了C++中SoundPtr的典型用法代码示例。如果您正苦于以下问题:C++ SoundPtr类的具体用法?C++ SoundPtr怎么用?C++ SoundPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SoundPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StreamedSound

SoundPtr ALSubsystem::stream2D(String filename, bool startPaused)
{
  SoundPtr out;

  String ext = filename.substr(filename.find_last_of(".") + 1);

  if(mAudioLoaders.find(ext) != mAudioLoaders.end())
  {	
    try
    {
      AudioStream* stream = mAudioLoaders[ext]->streamSound(filename);
      out.bind(new StreamedSound(stream, getSource()));
      mActiveSounds.push_back(out);
      if(!startPaused)
        out->play();
    }
    catch(Exception e)
    {
      std::cout<<"Could not stream sound.\n";
    }
  }
  else
  {
    std::cout<<"Could not stream sound, no loader found.\n";
  }	

  return out;
}
开发者ID:sumanvyj,项目名称:phosbot,代码行数:28,代码来源:ALSubsystem.cpp

示例2: play

void play(const char* name, bool stream=false)
{
  // Only load streams if the backend supports it
  if(stream && !mg.canLoadStream)
    return;

  cout << "Playing " << name;
  if(stream) cout << " (from stream)";
  cout << "\n";

  SoundPtr snd;

  try
    {
      if(stream)
        snd = mg.load(StreamPtr(new FileStream(name)));
      else
        snd = mg.load(name);

      snd->play();

      while(snd->isPlaying())
        {
          usleep(10000);
          if(mg.needsUpdate) mg.update();
        }
    }
  catch(exception &e)
    {
      cout << "  ERROR: " << e.what() << "\n";
    }
}
开发者ID:am0s,项目名称:mangle,代码行数:32,代码来源:openal_sndfile_test.cpp

示例3: loadSound

SoundPtr ALSubsystem::play2D(String name, bool startPaused)
{
  SoundPtr out;

  if(mAudioBuffers.find(name) == mAudioBuffers.end())
  {
    loadSound(name);

    if(mAudioBuffers.find(name) == mAudioBuffers.end())
    {
      std::cout<<"Could not play sound, could not find or load audio.\n";
      return out;
    }
  }

  if(!hasSources())
  {
    std::cout<<"Could not play sound, no available sound sources.\n";
  }
  else
  {
    out.bind(new BufferedSound(getSource(), mAudioBuffers[name], mAudioData[name]));
    mActiveSounds.push_back(out);
    if(!startPaused)
      out->play();
  }

  return out;
}
开发者ID:sumanvyj,项目名称:phosbot,代码行数:29,代码来源:ALSubsystem.cpp

示例4: loadSound

SoundPtr ALSubsystem::play2D(String name, bool startPaused)
{
    SoundPtr out;

    if(mAudioBuffers.find(name) == mAudioBuffers.end())
    {
        loadSound(name);

        if(mAudioBuffers.find(name) == mAudioBuffers.end())
        {
            Logger::getPtr()->logMessage("Could not play sound, could not find or load audio.");
            return out;
        }
    }

    if(!hasSources())
    {
        Logger::getPtr()->logMessage("Could not play sound, no available sound sources.");
    }
    else
    {
        out.bind(new BufferedSound(getSource(), mAudioBuffers[name]));
        mActiveSounds.push_back(out);
        out->setGain(0.f, 1.f, 1.f);
        if(!startPaused)
            out->play();
    }

    return out;
}
开发者ID:67-6f-64,项目名称:OryxEngine,代码行数:30,代码来源:ALSubsystem.cpp

示例5: SoundPtr

SoundManager::SoundPtr SoundManager::Load(const std::string& locator) {
    std::string file;
    file = "content/sounds/" + locator;
    SoundPtr sound = SoundPtr(new sf::SoundBuffer());
    if(!sound->LoadFromFile(file))
        return SoundPtr();
    return sound;
}
开发者ID:skwee357,项目名称:TankSmasher,代码行数:8,代码来源:SoundManager.cpp

示例6: stopSound

 void SoundManager::stopSound(const std::string& soundId)
 {
     IDMap::iterator it = mLoopedSounds.find(soundId);
     if(it != mLoopedSounds.end())
     {
         SoundPtr snd = it->second.lock();
         if(snd) snd->stop();
         mLoopedSounds.erase(it);
     }
 }
开发者ID:werdanith,项目名称:openmw,代码行数:10,代码来源:soundmanager.cpp

示例7: makeControll

void PlayerBehavior::update( ) {
	//何もしなかったら待機
	_player_state = PLAYER_STATE_WAIT;
	
	CONTROLL controll = makeControll( );

	walk( controll );
	attack( controll );
	AppPtr app = App::getTask( );

	if ( _parent->getStatus( ).hp <= 0 ) {
		_player_state = PLAYER_STATE_DEAD;
		SoundPtr sound = Sound::getTask( );
		sound->playSE( Sound::SE_GAME_OVER );
		ClientPtr client = Client::getTask( );
		SERVERDATA data;
		data.command = COMMAND_STATUS_POS;
		data.value[ 0 ] = _player_id;
		data.value[ 1 ] = 0;
		data.value[ 2 ] = 0;
		client->send( data );

		if ( _controll ) {
			app->setState( App::STATE_DEAD );
		}
	} else {
		PlayerPtr player = std::dynamic_pointer_cast< Player >( _parent );
		player->addSP( 1 );
	}
	_before_state = _player_state;
	PlayerPtr player = std::dynamic_pointer_cast< Player >( _parent );
	int sp = player->getSP( );
	//AdventurePtr adventure = app->getAdventure( );
	if ( ( !_is_tutorial_sence ) && ( sp == Player::FULL_SP_NUM ) && _controll ) {
		//adventure->set( Adventure::TYPE_COMMON_TUTORIAL_3 );
		_is_tutorial_sence = true;
	}
	for ( int i = PLAYER_ETUDE_RED; i <= PLAYER_ETUDE_BLUE; i++ ) {
		Vector pos = _parent->getPos( ) - app->getPlayer( i )->getPos( );
		if ( !_is_conntact_minotaur && 
			( _player_id < PLAYER_ETUDE_RED ) && 
			( pos.getLength( ) < CONNTACT_MINOTAUR_LENGTH ) &&
			_controll ) {
			//adventure->set( Adventure::TYPE_COMMON_CYCLOPS_CONTACT );
			//adventure->set( Adventure::TYPE_COMMON_AFTER_MINOTAUR_ENTRY );
			_is_conntact_minotaur = true;
		}
	}
	_keep_pos = _parent->getPos( );
}
开发者ID:tcagame,项目名称:Attraction2016,代码行数:50,代码来源:PlayerBehavior.cpp

示例8: playSound

 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();
     }
 }
开发者ID:StableOrbital,项目名称:openmw,代码行数:15,代码来源:soundmanager.cpp

示例9: HealthAttribute

/** 
 * Initializes the bee's attributes 
 * 
 * 
 * @return bool
 */
bool Bee::DoExtraInits()
{
	if (!GameCharacter::DoExtraInits())
	{
		return false;
	}

	// add a health attribute
	HealthAttributePtr health = NiNew HealthAttribute(this);
	m_fMaxHealth = ConfigurationManager::Get()->bee_initialHealth;
	health->Reset(m_fMaxHealth);
	AddAttribute(GameCharacter::ATTR_HEALTH, (CharacterAttribute*)health);
	// add an armor attribute
	AddAttribute(GameCharacter::ATTR_ARMOR, NiNew ArmorAttribute(this));
	// add a damage attribute
	DamageAttribute* dmg = NiNew DamageAttribute(this);
	dmg->Reset(ConfigurationManager::Get()->bee_damage);
	AddAttribute(GameCharacter::ATTR_DAMAGE, dmg);
	// add an FSMBeeAIControl
	AddAttribute(GameCharacter::ATTR_CONTROLLER, NiNew FSMBeeAIControl(this));
	// set initial position
	m_pActor->setGlobalPosition(GameManager::Get()->
		GetQueen()->GetActor()->getGlobalPosition() - NxVec3(50.0, 0.0, 0.0));

	SoundPtr sound = ResourceManager::Get()->GetSound(
		ResourceManager::RES_SOUND_BEE, this);
	if (sound)
	{
		AddAttribute(GameCharacter::ATTR_SOUND_DEFAULT, (CharacterAttribute*)sound);
		sound->Play();
	}

	AddAttribute(GameCharacter::ATTR_SOUND_1, (CharacterAttribute*) ResourceManager::Get()->GetSound(
		ResourceManager::RES_SOUND_BEE_AWAITING, this));

	AddAttribute(GameCharacter::ATTR_SOUND_2, (CharacterAttribute*) ResourceManager::Get()->GetSound(
		ResourceManager::RES_SOUND_BEE_DYING, this));

	// set dampings
	m_pActor->setLinearDamping(8.0f);
	m_pActor->setAngularDamping(8.0f);

	
	

	return true;
}
开发者ID:aadarshasubedi,项目名称:beesiege,代码行数:53,代码来源:Bee.cpp

示例10: lookup

  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);
            }
        }
    }
  }
开发者ID:werdanith,项目名称:openmw,代码行数:25,代码来源:soundmanager.cpp

示例11: s

void Audio::playSFX(const std::string &filename, bool relative, const cml::vector2f &pos, float attenuation, float min_dist)
{
    if(sounds.empty())
        for(int i = 0; i < 32; i++)
        {
            SoundPtr s(new sf::Sound());
            s->SetVolume(60.0f);
            sounds.push_back(s);
        }


    SoundPtr s;

    for(unsigned int i = 0; i < sounds.size(); i++)
        if(sounds[i]->GetStatus() == sf::Sound::Stopped)
            s = sounds[i];

    if(!s)
    {
        warning("too many sounds");
        return;
    }

    SoundBufferPtr sb = getSoundBuffer(filename);
    s->SetRelativeToListener(relative);
    s->SetPosition(pos[0], pos[1], 0.0f);
    s->SetAttenuation(attenuation);
    s->SetMinDistance(min_dist);
    s->SetBuffer(*(sb.get()));
    s->Play();
}
开发者ID:citizen-erased,项目名称:asteroids,代码行数:31,代码来源:audio.cpp

示例12: clearAll

    // Clears all the sub-elements of a given iterator, and then
    // removes it from 'sounds'.
    void clearAll(PtrMap::iterator it)
    {
      IDMap::iterator sit = it->second.begin();

      while(sit != it->second.end())
        {
          // Get sound pointer, if any
          SoundPtr snd = sit->second.lock();

          // Stop the sound
          if(snd) snd->stop();

          sit++;
        }

      // Remove the ptr reference
      sounds.erase(it);
    }
开发者ID:StableOrbital,项目名称:openmw,代码行数:20,代码来源:soundmanager.cpp

示例13: setPos

// Set the position on a sound based on a Ptr.
static void setPos(SoundPtr &snd, const MWWorld::Ptr ref)
{
  // Get sound position from the reference
  const float *pos = ref.getCellRef().pos.pos;

  // Move the sound, converting from MW coordinates to Ogre
  // coordinates.
  snd->setPos(pos[0], pos[2], -pos[1]);
}
开发者ID:StableOrbital,项目名称:openmw,代码行数:10,代码来源:soundmanager.cpp

示例14: EnsureComma

SoundPtr ResourceConfig::SafeReadSound(StringParser &theVal)
{
	theVal.SkipWhitespace();
	
	SoundDescriptor aDesc;
	std::string aName;
	if(theVal.GetChar()=='(')
	{
		theVal.IncrementPos();
		theVal.ReadString(aName); EnsureComma(theVal);
		int aFlags = 0;
		while(true)
		{
			std::string aFlagStr;
			theVal.ReadString(aFlagStr,true);
			if(aFlagStr.empty())
				break;

			if(stricmp(aFlagStr.c_str(),"Preload")==0)
				aFlags |= SoundFlag_Preload;
			else if(stricmp(aFlagStr.c_str(),"Music")==0)
				aFlags |= SoundFlag_Music;
			else if(stricmp(aFlagStr.c_str(),"Muted")==0)
				aFlags |= SoundFlag_Muted;
			else 
				throw ConfigObjectException("Unknown sound flag: " + aFlagStr);
		}

		aDesc.SetSoundFlags(aFlags,true);
		EnsureCloseParen(theVal);
	}
	else
		theVal.ReadString(aName);

	aDesc.mFilePath = ComponentConfig::GetResourceFile(aName);

	SoundPtr aSound = WindowManager::GetDefaultWindowManager()->DecodeSound(aDesc);
	if(aSound.get()==NULL)
		throw ConfigObjectException("Failed to decode sound: " + aDesc.mFilePath);

	return aSound;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:42,代码来源:ResourceConfig.cpp

示例15: setPos

    // 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";
        }
    }
开发者ID:werdanith,项目名称:openmw,代码行数:28,代码来源:soundmanager.cpp


注:本文中的SoundPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。