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


C++ SoundInstance类代码示例

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


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

示例1: StopAllSounds

void SoundSystem::StopAllSounds( SoundObjectId _id, char *_eventName )
{
    for( int i = 0; i < m_sounds.Size(); ++i )
    {
        if( m_sounds.ValidIndex(i) )
        {
            SoundInstance *instance = m_sounds[i];
            
            if( instance->m_objId == _id )
            {                    
                if( !_eventName || stricmp(instance->m_eventName, _eventName) == 0 )
                {
                    if( instance->IsPlaying() )
                    {
                        instance->BeginRelease(true);
                    }
                    else
                    {
                        ShutdownSound( instance );
                    }
                }
            }
        }
    }
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:25,代码来源:soundsystem.cpp

示例2: START_PROFILE

void SoundSystem::TriggerEvent( SoundObjectId _objId, char *_eventName )
{
    if( !m_channels ) return;

	START_PROFILE("TriggerEvent");
    
    char *objectType = m_interface->GetObjectType(_objId);
    if( objectType )
    {
        SoundEventBlueprint *seb = m_blueprints.GetBlueprint(objectType);
        if( seb )
        {
            for( int i = 0; i < seb->m_events.Size(); ++i )
            {
                SoundInstanceBlueprint *sib = seb->m_events[i];
                if( stricmp( sib->m_eventName, _eventName ) == 0 )
                {
                    Vector3<float> pos, vel;
                    m_interface->GetObjectPosition( _objId, pos, vel );

                    SoundInstance *instance = new SoundInstance();
                    instance->Copy( sib->m_instance );
                    instance->m_objIds.PutData( _objId );
                    instance->m_pos = pos;
                    instance->m_vel = vel;
                    bool success = InitialiseSound  ( instance );                
                    if( !success ) ShutdownSound    ( instance );                
                }
            }
        }
    }

	END_PROFILE("TriggerEvent");
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:34,代码来源:soundsystem.cpp

示例3: TEST_VERIFY

void SoundTest::PlayStopEffect(PerfFuncData * data)
{
    SoundInstance * clickInst = sndClick->Play();
    TEST_VERIFY(clickInst->GetState() == SoundInstance::STATE_PLAYING);
    
    sndClick->Stop();
    TEST_VERIFY(clickInst->GetState() == SoundInstance::STATE_FORCED_STOPPED);
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例4: play

	virtual SoundInstanceId play(SoundResource* sr, bool loop, float volume, const Vector3& pos)
	{
		SoundInstance instance;
		instance.create(sr, pos);
		SoundInstanceId id = id_array::create(m_playing_sounds, instance);
		id_array::get(m_playing_sounds, id).m_id = id;
		instance.play(loop, volume);
		return id;
	}
开发者ID:wibbe,项目名称:crown,代码行数:9,代码来源:sound_world_al.cpp

示例5: setVolume

    void SoundPlayer::setVolume(float v)
    {
        _volume = v;
        for (playingSounds::iterator i = _sounds.begin(); i != _sounds.end(); ++i)
        {
            SoundInstance* s = (*i).get();
            s->setVolume(v);
        }

    }
开发者ID:zmeyc,项目名称:oxygine-sound,代码行数:10,代码来源:SoundPlayer.cpp

示例6: getEngine

void Button::playPressedSound()
{
	if(getEngine()->getSoundEnvironment() != NULL)
	{
		if(SystemManager::settingExists("config/sound"))
		{
			Sound* sound = getEngine()->getSoundEnvironment()->getSound("selectMenuSound");
			if( sound != NULL )
			{
				SoundInstance* inst = new SoundInstance(sound);
				inst->setLocalPosition( getContainer()->get3dSettings().position );
				inst->play();
			}
		}
	}
}
开发者ID:a011095,项目名称:omegalib,代码行数:16,代码来源:Button.cpp

示例7: PropagateBlueprints

void SoundSystem::PropagateBlueprints( bool _forceRestart )
{
    for( int i = m_sounds.Size() - 1; i >= 0; --i )
    {
        if( m_sounds.ValidIndex(i) )
        {
            SoundInstance *instance = m_sounds[i];

			if( instance->IsPlayable() )
			{
				instance->PropagateBlueprints( _forceRestart );
			}
			else
			{
				ShutdownSound( instance );
			}
        }
    }
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:19,代码来源:soundsystem.cpp

示例8: initialize

	virtual void initialize()
	{
		env = getEngine()->getSoundEnvironment();
		env->setAssetDirectory("/Users/evldemo/sounds/");
		
		// All sound files should be in .wav format
		// For positional sounds, file should be mono.
		// Rest of important sound code is in handleEvent()
		sound = env->loadSoundFromFile("beep", "/menu_sounds/menu_select.wav");
		music = env->loadSoundFromFile("music", "/music/filmic.wav");
		sound1 = env->loadSoundFromFile("tricorder", "/arthur/TOS-tricorder.wav");

		// playStereo() is for ambient music.
		// Currently available functions:
		//	 setVolume(float) - amplitude from (0.0 - 1.0)
		//	 setLoop(bool)
		//	 stop() - this means this instance is finished and a new
		//			  sound instance will need to be created to play
		SoundInstance* musicInst = new SoundInstance(music);
		musicInst->setVolume(0.2f);
		musicInst->playStereo();

		changeCubeColor = false;
	}
开发者ID:drspiff,项目名称:omegalib,代码行数:24,代码来源:omegaSound.cpp

示例9: SoundInstance

void SoundSystem::TriggerDuplicateSound ( SoundInstance *_instance )
{
    SoundInstance *newInstance = new SoundInstance();
    newInstance->Copy( _instance );
    newInstance->m_parent = _instance->m_parent;
    newInstance->m_pos = _instance->m_pos;
    newInstance->m_vel = _instance->m_vel;

    for( int i = 0; i < _instance->m_objIds.Size(); ++i )
    {
        SoundObjectId id = *_instance->m_objIds.GetPointer(i);
        newInstance->m_objIds.PutData( id );
    }

    bool success = InitialiseSound( newInstance );
    if( success && newInstance->m_positionType == SoundInstance::TypeInEditor )
    {
        m_editorInstanceId = newInstance->m_id;        
    }
    else if( !success )
    {
        ShutdownSound( newInstance);
    }
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:24,代码来源:soundsystem.cpp

示例10: 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

示例11: while

bool SoundSystem::SoundLibraryMainCallback( unsigned int _channel, signed short *_data, 
									        unsigned int _numSamples, int *_silenceRemaining )
{
    if( !g_soundSystem ) return false;

	SoundInstanceId soundId = g_soundSystem->m_channels[_channel];
    SoundInstance *instance = g_soundSystem->GetSoundInstance( soundId );
    bool stereo = g_soundSystem->IsMusicChannel(_channel);
    
    if( instance && instance->m_soundSampleHandle )
    {
		//
        // Fill the space with sample data

        float relFreq = g_soundLibrary3d->GetChannelRelFreq(_channel);
		int numSamplesWritten = instance->m_soundSampleHandle->Read( _data, _numSamples, stereo, relFreq);

        if( numSamplesWritten < _numSamples )
        {
            signed short *loopStart = _data + numSamplesWritten;
            unsigned int numSamplesRemaining = _numSamples - numSamplesWritten;
            
            if( instance->m_loopType == SoundInstance::Looped ||
                instance->m_loopType == SoundInstance::LoopedADSR )
            {
                while( numSamplesRemaining > 0 )
                {
                    bool looped = instance->AdvanceLoop();
                    if( looped )
                    {
                        unsigned int numWritten = instance->m_soundSampleHandle->Read( loopStart, numSamplesRemaining, stereo , relFreq);
                        loopStart += numWritten;
                        numSamplesRemaining -= numWritten;
                    }
                    else
                    {
                        g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
                        numSamplesRemaining = 0;
                    }
                }
            }
            else if( instance->m_loopType == SoundInstance::SinglePlay)
            {
                if( numSamplesWritten > 0 )
                {
                    // The sound just came to an end, so write a whole buffers worth of silence
                    g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
                    *_silenceRemaining = g_soundLibrary3d->GetChannelBufSize(_channel) - numSamplesRemaining;
                }
                else
                {
                    // The sound came to an end and now we are writing silence
                    g_soundLibrary3d->WriteSilence( loopStart, numSamplesRemaining );
                    *_silenceRemaining -= numSamplesRemaining;
                    if( *_silenceRemaining <= 0 )
                    {
                        instance->BeginRelease(false);
                    }
                }
            }
        }

		return true;
    }
    else
    {
        g_soundLibrary3d->WriteSilence( _data, _numSamples );
		return false;
    }
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:70,代码来源:soundsystem.cpp

示例12: SoundInstance

void HelloApplication::handleEvent(const Event& evt)
{
	if(evt.getServiceType() == Service::Wand)
	{
				
		xPos = evt.getPosition().x();
		yPos = evt.getPosition().y();
		zPos = evt.getPosition().z();
		
		if( soundLoopInst != NULL )
			soundLoopInst->setPosition( evt.getPosition() );
	
		if( evt.getType() == Event::Down )
		{
			if( evt.getFlags() == Event::Button3 ) // Wand cross button
			{
				// playStereo() is for ambient music.
				// Currently available functions:
				//	 setVolume(float) - amplitude from (0.0 - 1.0)
				//	 setLoop(bool)
				//	 stop() - this means this instance is finished and a new
				//			  sound instance will need to be created to play
				SoundInstance* musicInst = new SoundInstance(music);
				musicInst->setVolume(0.2f);
				musicInst->playStereo();
			}
			else if( evt.getFlags() == Event::Button5 ) // Wand L1
			{
				env->getSoundManager()->stopAllSounds();
			}
			else if( evt.getFlags() == Event::ButtonLeft ) // DPad
			{
				SoundInstance* soundInst = new SoundInstance(sound);
				soundInst->setPosition( evt.getPosition() );
				soundInst->play();
				changeCubeColor = true;
			}
			else if( evt.getFlags() == Event::ButtonRight ) // DPad
			{
				if( soundLoopInst != NULL || !soundLoopInst->isPlaying() )
				{
					// Positional sounds use play()
					// Currently available functions:
					//	 stop() - this means this instance is finished and a new
					//			  sound instance will need to be created to play
					//	 setPosition(Vector3f) 
					//	 setVolume(float) - amplitude from (0.0 - 1.0)
					//	 setLoop(bool)
					//	 setMix(float) - wetness of sound (0.0 - 1.0)
					//	 setReverb(float) - room size / reverb amount (0.0 - 1.0)
					//	 setWidth(int) - number of speakers to spread sound across (1-20)
					//			This will eventually be replaced with a sound radius
					soundLoopInst = new SoundInstance(sound1);
					soundLoopInst->setPosition( evt.getPosition() );
					soundLoopInst->setLoop(true);
					soundLoopInst->setVolume(0.2f);
					soundLoopInst->setWidth(3);
					soundLoopInst->play();
				}
				else if( soundLoopInst != NULL )
				{
					soundLoopInst->stop();
				}
				
				changeCubeColor = true;
			}
			else
			{
				SoundInstance* soundInst = new SoundInstance(sound);
				soundInst->setPosition( evt.getPosition() );
				soundInst->setRoomSize(1.0);
				soundInst->setWetness(1.0);
				//soundInst->setVolume(0.5);
				soundInst->play();
				changeCubeColor = true;
			}
			
			
		}
		else if( evt.getType() == Event::Up )
		{
			changeCubeColor = false;
		}
	}
}
开发者ID:drspiff,项目名称:omegalib,代码行数:85,代码来源:omegaSound.cpp

示例13: _onSoundAboutDone

 void SoundPlayer::_onSoundAboutDone(void* sound_instance, Channel* channel, const sound_desc& desc)
 {
     SoundInstance* t = (SoundInstance*)sound_instance;
     t->aboutDone();
 }
开发者ID:zmeyc,项目名称:oxygine-sound,代码行数:5,代码来源:SoundPlayer.cpp

示例14: _onSoundDone

 void SoundPlayer::_onSoundDone(void* sound_instance, Channel* channel, const sound_desc& desc)
 {
     SoundInstance* t = (SoundInstance*)sound_instance;
     t->finished();
 }
开发者ID:zmeyc,项目名称:oxygine-sound,代码行数:5,代码来源:SoundPlayer.cpp

示例15: handleEvent

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Checks the type of event. If a valid event, creates an event packet and returns true. Else return false.
	virtual bool handleEvent(const Event& evt)
	{
		
		float leftRightAnalog;
		float upDownAnalog;
		float zeroTolerence = 0.008f;
		float xPos;
		float yPos;
		float zPos;

		switch(evt.getServiceType())
		{
			case Service::Wand:
				leftRightAnalog = evt.getExtraDataFloat(0);
				upDownAnalog = evt.getExtraDataFloat(1);

				volume = evt.getExtraDataFloat(4);
				
				if( soundLoopInstance != NULL )
				{
					soundLoopInstance->setVolume(volume);
				}

				if( evt.getType() == Event::Down ){

					if( evt.getFlags() & Event::Button3){ // Cross
						
						soundLoopInstance->setEnvironmentSound( true );
						soundLoopInstance->setLoop( true );
						
						soundLoopInstance->playStereo();
					}
					if( evt.getFlags() & Event::Button2){ // Circle
						soundLoopInstance->stop();
					}
					
					if( evt.getFlags() & Event::Button5){ // L1
						soundLoopInstance = new SoundInstance(soundLoop);
					}

					if( evt.getFlags() & Event::ButtonRight){
						
						rewindingSoundInstance->setPosition( Vector3f(leftRightAnalog,1,0) );
						rewindingSoundInstance->setReverb( upDownAnalog, upDownAnalog );
						rewindingSoundInstance->play();
					}
					if( evt.getFlags() & Event::ButtonLeft){
						SoundInstance* soundInstance = new SoundInstance(hideMenuSound);
						soundInstance->setPosition( Vector3f(leftRightAnalog,1,0) );
						soundInstance->setReverb( upDownAnalog, upDownAnalog );
						soundInstance->play();
					}
					if( evt.getFlags() & Event::ButtonUp){
						SoundInstance* soundInstance = new SoundInstance(selectMenuSound);
						soundInstance->setPosition( Vector3f(leftRightAnalog,1,0) );
						soundInstance->setReverb( upDownAnalog, upDownAnalog );
						soundInstance->play();
					}
					if( evt.getFlags() & Event::ButtonDown){
						SoundInstance* soundInstance = new SoundInstance(scrollMenuSound);
						soundInstance->setPosition( Vector3f(leftRightAnalog,1,0) );
						soundInstance->setReverb( upDownAnalog, upDownAnalog );
						soundInstance->play();
					}
					//printf("%d \n", evt.getFlags() );
				}
				
				if( (leftRightAnalog > zeroTolerence || leftRightAnalog < -zeroTolerence) &&
					(upDownAnalog > zeroTolerence || upDownAnalog < -zeroTolerence)
					){
					position[0] = leftRightAnalog;
					position[1] = upDownAnalog;
					printf("Analog Stick: %f %f\n", position[0], position[1]);
				}
				if( volume > 0 )
					printf("Analog Trigger (L2): %f\n", volume);
				return true;
				break;

			case Service::Mocap:
				//if( evt.getSourceId() == 0 )
				//	soundManager->setListenerPosition( evt.getPosition() );
				//env->setListenerPosition( Vector3f(0,0,0) );
				//else if( instanceCreated && evt.getSourceId() == 1 )
				//	soundInstance->setPosition( evt.getPosition() );
				//printf("ID: %d Pos: %f %f %f\n", evt.getSourceId(), evt.getPosition(0), evt.getPosition(1), evt.getPosition(2) );
				break;
		}
		
		return false;
	}
开发者ID:OKaluza,项目名称:omicron,代码行数:93,代码来源:soundtest.cpp


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