Exemplo n.º 1
0
void SoundSystem::Play3D(Sound3D* media){
	if(Instance().CheckSoundPlaying(media)){//if playing
		ISound* temp = Instance().currPlayingLoopedSounds[media];
		if(!temp->getIsPaused()){
			temp->setPlayPosition(0.0f);//set back to beginning
		}
		temp->setIsLooped(false);
		temp->setSoundStopEventReceiver (Instance().sndEndReceiver,media);
		temp->setVolume(media->volume);
		temp->setMinDistance(media->minSoundDist);
		temp->setMaxDistance(FLT_MAX); // max attenuation distance
		temp->setIsPaused(false);
	}else{
		//creates a new sound instance
         ISound* temp = Instance().soundEngine->play3D(media->mySoundSource,vec3df(media->GetSoundPosition()[x],media->GetSoundPosition()[y],media->GetSoundPosition()[z]),false,false,true);
		
		//ISound* temp = Instance().soundEngine->play3D(media->mySoundSource,media->GetPosition(),false,true);
		Instance().currPlayingLoopedSounds.insert(std::pair<Sound*,ISound*>(media,temp));
		temp->setSoundStopEventReceiver(Instance().sndEndReceiver,media);
		temp->setVolume(media->volume);
		temp->setMinDistance(media->minSoundDist);
		temp->setMaxDistance(FLT_MAX); // max attenuation distance
		temp->setIsPaused(false);
		
	}
}
Exemplo n.º 2
0
void SoundSystem::Play2DLooped(Sound2D* media){

	if(Instance().CheckSoundPlaying(media)){//if currently playing
		ISound* temp =Instance().currPlayingLoopedSounds[media]; 
		if(!temp->getIsPaused()){//if not paused... start from beginning
			temp->setPlayPosition(0.0f);//set back to beginning
		}
		temp->setIsLooped(true);
		temp->setSoundStopEventReceiver (Instance().sndEndedUsrReceiver,media);
		temp->setVolume(media->volume);
		temp->setIsPaused(false);
	}else{
		//creates a new sound instance
		ISound* temp = Instance().soundEngine->play2D(media->mySoundSource,true,false,true);
		Instance().currPlayingLoopedSounds.insert(std::pair<Sound*,ISound*>(media,temp));
		temp->setSoundStopEventReceiver(Instance().sndEndedUsrReceiver,media);
		temp->setVolume(media->volume);
		temp->setIsPaused(false);
	}

}