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


C++ SoundManager类代码示例

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


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

示例1: GetSceneNode

/**
*  @brief
*    Loads/reloads the sound
*/
void SNMSound::Load()
{
	// Destroy currently used sound source
	Source *pSS = static_cast<Source*>(m_pSoundSourceHandler->GetResource());
	if (pSS)
		delete pSS;

	// Get the PL sound container this scene node is in
	SceneContainer *pContainer = GetSceneNode().GetContainer();
	while (pContainer && !pContainer->IsInstanceOf("PLSound::SCSound"))
		pContainer = pContainer->GetContainer();
	if (pContainer) {
		SoundManager *pSoundManager = static_cast<SCSound*>(pContainer)->GetSoundManager();
		if (pSoundManager) {
			Source *pSoundSource = pSoundManager->CreateSoundSource(pSoundManager->CreateSoundBuffer(m_sSound, (GetFlags() & Stream) != 0));
			m_pSoundSourceHandler->SetResource(pSoundSource);
			pSoundSource->SetAttribute(Source::Position, GetSceneNode().GetTransform().GetPosition());
			pSoundSource->SetVolume(m_fVolume);
			pSoundSource->Set2D((GetFlags() & No3D) != 0);
			pSoundSource->SetLooping(!(GetFlags() & NoLoop));
			pSoundSource->SetPitch(m_fPitch);
			pSoundSource->SetReferenceDistance(m_fReferenceDistance);
			pSoundSource->SetMaxDistance(m_fMaxDistance);
			pSoundSource->SetRolloffFactor(m_fRolloffFactor);
			OnPosition();
			if (!(GetFlags() & NoStartPlayback))
				pSoundSource->Play();
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:34,代码来源:SNMSound.cpp

示例2: WorkWithSound

void WorkWithSound(std::string msg,ALshort **input_audio,ALshort **output_audio)
{
    SoundManager s;
    while (1) {
        s.input(input_audio,output_audio);
	//s.output();
    }
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例3: main

int main( int argc, char *args[] ) {
    bool quit = false;
    ScreenManager *screenManager = new ScreenManager();
    SoundManager *soundManager = new SoundManager();


    if ( init() == false ) {
        return 1;
    }

    if ( load_files() == false ) {
        return 1;
    }

    while ( quit == false ) {
        while ( SDL_PollEvent( &event ) ) {

            if ( event.type == SDL_KEYDOWN ) {
                switch ( event.key.keysym.sym ) {
                    case SDLK_RETURN:
                        handle_return_key();
                        break;
                    default:
                        ;
                }
            }

            if ( event.type == SDL_QUIT ) {
                quit = true;
            }
        }


        startScreen = screenManager->load_image( "../ScreenManager/Images/test.png" );

        if ( soundManager->play_music( "../beat.wav" ) ) {
            return 1;
        }

        screenManager->apply_surface( 0, 0, startScreen, screen);


        if ( gameStart ) {
            //apply the gameScreen surface
        } else {
            //apply the startScreen surface
        }

        //Update the screen
        if ( SDL_Flip( screen ) == -1 ) {
            return 1;
        }
    }

    clean_up();
    return 0;
}
开发者ID:Ebadly,项目名称:2D-Side-Scroller,代码行数:57,代码来源:main.cpp

示例4: playSound

void SkillData::playSound() {
	SoundManager *soundManager = SoundManager::getInstance();

	if(!sound.empty()) {
		std::string diretorioSound = std::string("sfx/");
		diretorioSound.append(sound.c_str());
		soundManager->playSound(diretorioSound, 1);
	}
}
开发者ID:slumki,项目名称:Gameka,代码行数:9,代码来源:SkillData.cpp

示例5: AudioTest1

void AudioTest1() {

	return;

	SoundManager* soundManager = CreateSoundManager();

	for(int i = 0; i < 100000; i++ )
	SharedPtr<Sound> sound = soundManager->createSound("content/ptrs.wav");



	//sound->removeSmartPtr
}
开发者ID:GlebGuschin,项目名称:RealEngine,代码行数:13,代码来源:AudioTests.cpp

示例6: loadCacheSoundsCallback

void loadCacheSoundsCallback (const std::string &filename, intptr_t param)
{
	SoundManager *sm;
	sm = (SoundManager*)param;
	if (!sm->enabled)
	{
		//sm->erorr();
		debugLog("Disabled: Won't Load Sample ["+filename+"]");
		return;
	}
	if (fileType==".ogg")
	{
		debugLog("trying to load sound " + filename);
		sm->loadSoundIntoBank(filename, "", "");
	}
}
开发者ID:AquariaOSE,项目名称:Aquaria,代码行数:16,代码来源:SoundManager.cpp

示例7: b2Min

void GameObj::move(SoundManager &sm) {

	if(!moveSpecial(sm)) {

		if(body) {
			// Gradual speed increase for objects with a max velocity set  // (Bullets should have max Vel ZERO) // this logic will need updating!
			if(goSettings.getVelocityMax()) {
				b2Vec2 vel = body->GetLinearVelocity();
				vel.x = b2Min( vel.x + 0.1f,  goSettings.getVelocityMax() );
				body->SetLinearVelocity( vel );
			}

			t_move.Calculate_Ellapsed_Time();
			if(t_move.TotalTime() >= TIMER_SOUND_MOVE) {
				SoundManager::Sounds soundID;
				switch(goSettings.getTypeID()) {
					case Settings::OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MOVE; break;
					case Settings::OBJ_ID_STONEWALL: soundID = sm.SND_STONEWALL_MOVE; break;
		//			case settings.OBJ_T_DOG: soundID = sm.SND_DOG_MELEE; break;
		//			case settings.OBJ_T_SPEARMAN: soundID = sm.SND_SPEARMAN_MELEE; break;
		//			case settings.OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MELEE; break;
					default: soundID = sm.SND_DOG_MOVE; break;
				}
				sm.playSound(soundSourceID, soundID, body->GetPosition());
				t_move.Reset(0.0);
			}
		}	
	}
}
开发者ID:lansdon,项目名称:Fortress2D,代码行数:29,代码来源:GameObj.cpp

示例8: getArmor

void GameObj::damage(int amount, SoundManager &sm) {
	// Process incoming damage
	if(getArmor() > amount)
		return;				// armor negates all damage
	else amount -= getArmor();
	setHP(getHP() - amount);

	// SFX
	t_damaged.Calculate_Ellapsed_Time();
	if(t_damaged.TotalTime() >= TIMER_SOUND_DAMAGED) {
		SoundManager::Sounds soundID;
		switch(goSettings.getTypeID()) {
			case Settings::OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_DAMAGED; break;
			case Settings::OBJ_ID_STONEWALL: soundID = sm.SND_STONEWALL_DAMAGED; break;
	//			case settings.OBJ_T_DOG: soundID = sm.SND_DOG_MELEE; break;
	//			case settings.OBJ_T_SPEARMAN: soundID = sm.SND_SPEARMAN_MELEE; break;
	//			case settings.OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MELEE; break;
			default: soundID = sm.SND_ARCHER_DAMAGED; break;
		}
		sm.playSound(soundSourceID, soundID, body->GetPosition());
		t_damaged.Reset(0.0);
	}

	// Special Behavior (defined in derived classes)
	damageSpecial(amount, sm);

	// Death sequence
	if(getHP() < 0) {
		death(sm);
	}
}
开发者ID:lansdon,项目名称:Fortress2D,代码行数:31,代码来源:GameObj.cpp

示例9: attack

void GameObj::attack(GameObj *enemy, SoundManager &sm) {
//	if(enemy->isAlive()) {
		// SFX
		t_melee.Calculate_Ellapsed_Time();
		if(t_melee.TotalTime() >= TIMER_SOUND_MELEE) {
			SoundManager::Sounds soundID;
			switch(goSettings.getTypeID()) {
				case Settings::OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MELEE; break;
				case Settings::OBJ_ID_STONEWALL: soundID = sm.SND_STONEWALL_MELEE; break;
	//			case settings.OBJ_T_DOG: soundID = sm.SND_DOG_MELEE; break;
	//			case settings.OBJ_T_SPEARMAN: soundID = sm.SND_SPEARMAN_MELEE; break;
	//			case settings.OBJ_ID_ARCHER: soundID = sm.SND_ARCHER_MELEE; break;
				default: soundID = sm.SND_ARCHER_DAMAGED; break;
			}
			sm.playSound(soundSourceID, soundID, body->GetPosition());
			t_melee.Reset(0.0);
		}

		// DAMAGE ENEMY
		enemy->damage(goSettings.getDamage(), sm);

		// Special Behavior (defined in derived classes)
		attackSpecial(enemy, sm);
//	}
}
开发者ID:lansdon,项目名称:Fortress2D,代码行数:25,代码来源:GameObj.cpp

示例10: BMP

//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{

        PBMP bContext = new BMP();
        bContext->Width = ClientWidth;
        bContext->Height = ClientHeight;
        context = new FastBitmap(bContext);
        rm = new RenderManager();
        rm->setContext(context,Canvas,ClientWidth, ClientHeight, clWhite);
        DoubleBuffered=true;
        gm = new GameManager();
        gm->setRenderManager(rm);
        SpriteFabric *sf = SpriteFabric::getInstance();
        sc = 0;
        map = 0;
        SoundManager * sm = SoundManager::getInstance();
        sm->init(Button1);

        UserStats::getInstance()->loadFromFile("config/autoexec.txt");

}
开发者ID:SpaceWind,项目名称:elo2kbuilder,代码行数:22,代码来源:main.cpp

示例11: update

void PPAD::update(std::vector<std::vector<int>> &colMap, Rock& rock, SoundManager& sound) {
    if (plateBound.intersects(rock.getBounds())) {
        plate.setTextureRect(sf::IntRect(32, 32, mSize.x, mSize.y));
        if (!opened) {
            open(colMap);
            sound.playSound(1);
            opened = true;
        }
    } else if (!opened) {
        colMap[posD.y][posD.x] = 1;
    }
}
开发者ID:Ludusamo,项目名称:LudumDare28,代码行数:12,代码来源:PPAD.cpp

示例12: update

void ConverseSpeech::update()
{
 TownsSound sound;
 SoundManager *sm = Game::get_game()->get_sound_manager();

 if(!sm->is_audio_enabled() || !sm->is_speech_enabled())
   return;

 if(!list.empty())
   {
    if(sm->isSoundPLaying(handle) == false)
     {
    	list.pop_front();
    	if(!list.empty())
    	{
    	    sound = list.front();
        	handle = sm->playTownsSound(sound.filename, sound.sample_num);
    	}
     }
   }
}
开发者ID:nuvie,项目名称:nuvie,代码行数:21,代码来源:ConverseSpeech.cpp

示例13: IndieLib

/*
==================
Main
==================
*/
int IndieLib()
{
    //Sets the working path as the 'exe' directory. All resource paths are relative to this directory
	if (!WorkingPathSetup::setWorkingPathFromExe(NULL)) {
		std::cout<<"\nUnable to Set the working path !";
	}
	
	SoundManager * mSm = SoundManager::instance();

	// ----- IndieLib intialization -----

	CIndieLib *mI = CIndieLib::instance();
	if (!mI->init()) return 0;		

	Game * mGame = new Game();
	bool quit = false;

	while (!quit && !mI->_input->quit())
	{
		// ----- Input update ----
		Sleep(10); // Take it easy, computer
		mI->_input->update();
		quit = mGame->run();

		// ----- Render  -----
		mI->_render->beginScene();
		mI->_render->clearViewPort(0, 0, 0);
		mI->_entity2dManager->renderEntities2d();
		//mI->_entity2dManager->renderCollisionAreas(255, 0, 0, 255);
		mI->_render->endScene();	
	}

	// ----- Free -----
	mSm->shutdown();
	mI->end();

	return 0;
}
开发者ID:trotskey,项目名称:Hokuhou,代码行数:43,代码来源:Tutorial08.cpp

示例14: main

int main ()
{
  printf ("EmitterAutoDelete test.\n");

  try
  {
    scene_graph::Scene scene;
    SoundManager       manager ("OpenAL", "*");
    ListenerPtr        listener (scene_graph::Listener::Create ());

    listener->BindToParent (scene.Root ());

    manager.LoadSoundLibrary (library_file);

    ScenePlayer scene_player;

    scene_player.SetListener (listener.get ());

    scene_player.SetManager (&manager);

    ((Node*)play_sound ("declaration2", scene).get ())->RegisterEventHandler (NodeEvent_AfterDestroy, xtl::bind (&Application::Exit, 0));

    Application::Run ();
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n",exception.what ());
  }
  catch (...)
  {
    printf ("unknown exception\n");
  }

  printf ("exit\n");

  return Application::GetExitCode ();
}
开发者ID:untgames,项目名称:funner,代码行数:37,代码来源:emitter_auto_delete.cpp

示例15: SoundTest

	SoundTest()
	{
		//soundManager = new SoundManager();
		//soundManager->connectToServer("localhost",57120);
		
		// More concise method of above two lines
		soundManager = new SoundManager("localhost",57120);

		soundManager->showDebugInfo(true);

		// Get default sound environment
		env = soundManager->getSoundEnvironment();

		
		while( !soundManager->isSoundServerRunning() )
		{
			soundManager->startSoundServer();
		}

		// Load sound assets
		//env->setAssetDirectory("menu_sounds");

		showMenuSound = env->loadSoundFromFile("showMenuSound","menu_sounds/menu_load.wav");
		hideMenuSound = env->loadSoundFromFile("hideMenuSound","menu_sounds/menu_closed.wav");
		scrollMenuSound = env->loadSoundFromFile("scrollMenuSound","menu_sounds/menu_scroll.wav");
		selectMenuSound = env->loadSoundFromFile("selectMenuSound","menu_sounds/menu_select.wav");
		soundLoop = env->loadSoundFromFile("mus","Omega4Relay.wav");

		SoundInstance* soundInstance = new SoundInstance(showMenuSound);
		soundInstance->setReverb( 1.0, 1.0 );
		soundInstance->setVolume(1.0);
		soundInstance->setPosition( Vector3f(0,1,0) );
		soundInstance->play();

		rewindingSoundInstance = new SoundInstance(showMenuSound);
	}
开发者ID:OKaluza,项目名称:omicron,代码行数:36,代码来源:soundtest.cpp


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