Beispiel #1
0
bool
Ambient::update(Time deltaT)
{
  if(baseBuffer == NULL || base == NULL || baseChannel == -1) return false;

  if(isActive == false && currentVolume == 0 && targetVolume == 0) {
    checkFMODError(FSOUND_Stream_Stop(base));
    checkFMODError(FSOUND_Stream_Close(base));
    return false;
  }
  
  if(currentVolume != targetVolume) {
    float fadeStep = deltaT * 1.0 / MAGIC_FADE_TIME_SECONDS;
    if(fadeStep > abs(targetVolume - currentVolume))
      currentVolume = targetVolume;
    else if(currentVolume > targetVolume)
      currentVolume -= fadeStep;
    else
      currentVolume += fadeStep;
  }

  int channelVolume = clamp(static_cast<int>(currentVolume * MAGIC_AMBIENT_VOLUME * 255), 0, 255);
  checkFMODError(FSOUND_SetVolume(baseChannel, channelVolume));
                   
  runningTime -= deltaT;
  if(runningTime <= 0) {
    targetVolume = 0;
    runningTime = 0;
  }

  return true;
}
Beispiel #2
0
static inline VOID M_StopMusic(VOID)
{
	if (mod)
		FMUSIC_StopSong(mod);
	if (fsoundchannel != -1 && fmus && FSOUND_IsPlaying(fsoundchannel))
		FSOUND_Stream_Stop(fmus);
}
Beispiel #3
0
void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) {
	warning("STUB: FullpipeEngine::playTrack(var, %s, %d)", name, delayed);
#if 0
	stopSoundStream2();

	if (soundStream3)
		FSOUND_Stream_Stop(soundStream4);
#endif

	if (_musicLocal)
		stopAllSoundStreams();

	GameVar *var = sceneVar->getSubVarByName(name);

	memset(_sceneTracks, 0, sizeof(_sceneTracks));

	_numSceneTracks = 0;
	_sceneTrackHasSequence = false;

	if (!var)
		return;

	_musicGameVar = var;

	GameVar *tr = var->getSubVarByName("TRACKS");
	if (tr) {
		GameVar *sub = tr->_subVars;

		while (sub) {
			if (_musicAllowed & sub->_value.intValue) {
				Common::strlcpy(_sceneTracks[_numSceneTracks], sub->_varName, 260);

				_numSceneTracks++;
			}

			sub = sub->_nextVarObj;
		}
	}

	_musicMinDelay = var->getSubVarAsInt("MINDELAY");
	_musicMaxDelay = var->getSubVarAsInt("MAXDELAY");
	_musicLocal = var->getSubVarAsInt("LOCAL");

	GameVar *seq = var->getSubVarByName("SEQUENCE");

	if (seq) {
		_sceneTrackHasSequence = true;

		Common::strlcpy(_trackName, seq->_value.stringValue, 2600);
	}

	if (delayed) {
		if (_sceneTrackIsPlaying && _numSceneTracks == 1) {
			if (strcmp(_sceneTracksCurrentTrack, _sceneTracks[0]))
				stopAllSoundStreams();
		}

		_trackStartDelay = var->getSubVarAsInt("STARTDELAY");
	}
}
World::~World()
{
	if (mp3file)
	{
		FSOUND_Stream_Stop( mp3file );
		FSOUND_Stream_Close( mp3file );
	}
}
Beispiel #5
0
///////////////////////////////////////////////////////////////////////////////
//stopmusic will stop the currently playing song pointed to by CurrentSong. 
///////////////////////////////////////////////////////////////////////////////
int CSound::Stopmusic()
{

	FSOUND_Stream_Stop(CurrentSong);
	FSOUND_Stream_Close(CurrentSong);
	if (CurrentSong != NULL)
		CurrentSong = NULL;
	return 0;
}
Beispiel #6
0
void SoundSystem::stopMusic()
{
	if(musicStream)
	{
		FSOUND_Stream_Stop(musicStream);
		FSOUND_Stream_Close(musicStream);
		musicStream=0;
	}
}
Beispiel #7
0
	void LecteurAudio::appuiStop(bool etatBouton)
	{
		// On arrete les lecteurs des joueurs
		emettreCommande(arretMorceau);
		// On met le lecteur a l'arret
		arreter();
		// On arrete la lecture et on revient au debut du titre
		FSOUND_Stream_Stop(fluxAudio);
	}
Beispiel #8
0
void FullpipeEngine::setSceneMusicParameters(GameVar *gvar) {
	warning("STUB: FullpipeEngine::setSceneMusicParameters()");
#if 0
	stopSoundStream2();

	if (soundStream3)
		FSOUND_Stream_Stop(soundStream4);
#endif

	if (_musicLocal)
		stopAllSoundStreams();

	GameVar *var = gvar->getSubVarByName("MUSIC");

	memset(_sceneTracks, 0, sizeof(_sceneTracks));

	_numSceneTracks = 0;
	_sceneTrackHasSequence = false;

	if (!var)
		return;

	_musicGameVar = var;

	GameVar *tr = var->getSubVarByName("TRACKS");
	if (tr) {
		GameVar *sub = tr->_subVars;

		while (sub) {
			if (_musicAllowed & sub->_value.intValue) {
				Common::strlcpy(_sceneTracks[_numSceneTracks], sub->_varName, 260);

				_numSceneTracks++;
			}

			sub = sub->_nextVarObj;
		}
	}

	_musicMinDelay = var->getSubVarAsInt("MINDELAY");
	_musicMaxDelay = var->getSubVarAsInt("MAXDELAY");
	_musicLocal = var->getSubVarAsInt("LOCAL");

	GameVar *seq = var->getSubVarByName("SEQUENCE");

	if (seq) {
		_sceneTrackHasSequence = true;

		Common::strlcpy(_trackName, seq->_value.stringValue, 2600);
	}

	if (_musicLocal)
		stopAllSoundStreams();

	if (!_sceneTrackIsPlaying || _musicLocal)
		_trackStartDelay = var->getSubVarAsInt("STARTDELAY");
}
Beispiel #9
0
//===========================================================================
// DM_FModExtStop
//===========================================================================
void DM_FModExtStop(void)
{
	if(!ext_inited)
		return;
	//ext_playing = false;
	if(module)
		FMUSIC_StopSong(module);
	if(stream)
		FSOUND_Stream_Stop(stream);
}
void CAudioManager::StopStream(int id){
  if(m_bValidAudio == false)
    return;

  for(int i = 0; i < m_Stream.size(); i++){
    if(m_Stream[i].AudioID == id){
      FSOUND_Stream_Stop(m_Stream[i].handle);
    }
  }
}
void CMusicChannelFMod::updateWaitingForClose()
{
	std::list<FSOUND_STREAM*>::iterator	it= _WaitingForClose.begin();
	while (it != _WaitingForClose.end())
	{
		// try to stop, will fail if still loading
		bool ok = FSOUND_Stream_Stop(*it) != 0;
		if (ok) ok = FSOUND_Stream_Close(*it) !=0;
		// erase from list, or next
		if (ok) it = _WaitingForClose.erase(it);
		else ++it;
	}
}
Beispiel #12
0
	void LecteurAudio::joueurArretMorceau()
	{
		// Si aucun fichier audio n'est actuellement ouvert, on quitte la fonction
		if (!fluxAudio)
		{
			qWarning("Demande d'arret de lecture alors qu'aucun fichier n'est ouvert (joueurArretMorceau - LecteurAudio.cpp)");
			return;
		}
		
		// On met le lecteur a l'arret
		etatActuel = arret;
		// On arrete la lecture et on revient au debut du titre
		FSOUND_Stream_Stop(fluxAudio);
		// La lecture reprend depuis le debut
		joueurPositionTemps = 0;
	}
Beispiel #13
0
static inline VOID M_FreeMusic(VOID)
{
	if (mod)
	{
		FMUSIC_StopSong(mod);
		FMUSIC_FreeSong(mod);
		mod = NULL;
	}
	if (fmus)
	{
		FSOUND_Stream_Stop(fmus);
		FSOUND_Stream_Close(fmus);
		fmus = NULL;
		fsoundchannel = -1;
	}
}
Beispiel #14
0
void StateLevel::handleEvents()
{
	if ( SDL_PollEvent(&event) )
	{
		if ( event.type == SDL_QUIT ) setNextGameState(0);

		if ( event.type == SDL_KEYUP )
		{
            if ( event.key.keysym.sym == SDLK_ESCAPE ) setNextGameState (2);
            if ( event.key.keysym.sym == SDLK_SPACE && ( (o_player.b_die == true) || (o_player.b_win == true )) ) b_go = true;
            if ( event.key.keysym.sym == SDLK_r ) b_restart = true;
		}
            if ( o_player.b_die == false && o_player.b_win == false ) o_player.handleEvents();

        if ( event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_m )
		{
		    if ( b_music == true )
		    {
		        FSOUND_Stream_Stop(song2);

		        b_music = false;
		    }

		    else if ( b_music == false )
		    {
		        FSOUND_Stream_Play( 1, song2 );
                FSOUND_Stream_SetLoopCount(song2,-1);

                b_music = true;

		    }

		}




	}

}
Beispiel #15
0
void StateMenu::handleEvents()
{
	if ( SDL_PollEvent(&event) )
	{

		if ( event.type == SDL_QUIT )
		{
			setNextGameState(0);
		}

		if ( event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_m )
		{
		    if ( b_music == true )
		    {
		        FSOUND_Stream_Stop(song2);

		        b_music = false;
		    }

		    else if ( b_music == false )
		    {
		        FSOUND_Stream_Play( 1, song2 );
                FSOUND_Stream_SetLoopCount(song2,-1);

                b_music = true;

		    }

		}

		if ( event.type == SDL_MOUSEBUTTONUP )
		{
			if ( event.button.button == SDL_BUTTON_LEFT )
			{
				int x,y;
				SDL_GetMouseState(&x,&y);

				Box mouse;
				mouse.x = (float)x;
				mouse.y = (float)y;
				mouse.w = 1;
				mouse.h = 1;

				if ( checkCollisionQuads( mouse, play ) )
				{
					setNextGameState(8);
				}

				else if ( checkCollisionQuads( mouse, select ) )
				{
					setNextGameState(5);
				}

				else if ( checkCollisionQuads( mouse, editor ) )
				{
					setNextGameState(4);
				}

				else if ( checkCollisionQuads( mouse, exit ) )
				{
					setNextGameState(0);
				}
			}
		}

	}

}
Beispiel #16
0
void Title::HandleEvents(GameEngine* game)
{
     /*la majorité du code de l'écran titre se trouve ici (mise à jour des images inclue)
     étant donné le fonctionnement de l'écran titre

     la méthode de gestion des évènements de l'exploration peut également s'appliquer, mais il faut
     penser à inclure des variables static de fonction et "simuler" la répétition des touches
     après un certain temps appuyé sur une des deux touches (haut/bas)

     Ce type de code devra être simulé lors des combats si la jauge ATB reste active
     pendant la gestion des commandes*/

     SDL_EnableKeyRepeat(400, 100);
     int tempsPrecedent = 0, tempsActuel = 0;
     FSOUND_Stream_Play(FSOUND_FREE, musique1);
     SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL);
     SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02);
     SDL_UpdateRect(game->screen, 0, 0, 0, 0);

     //SDL_EventState(SDL_KEYDOWN, SDL_IGNORE); //Désactive et annule les anciens évènements
     SDL_EventState(SDL_KEYDOWN, SDL_ENABLE); // Réactive les évènements

     while ( quit==false  && positionCurseur != 0 )

     {

           //Tant qu'il y a un événement
           while( SDL_WaitEvent( &game->event ) ) //////ON ATTEND QU'UN EVENEMENT SE DECLBNCHE POUR EXECUTER LES ACTIONS EN DESSOUS
           {
                  switch (game->event.type)
                  {
                         //A retirer lorsque phase de test terminée
                         case SDL_QUIT: //Si l'utilisateur a cliqué sur le X de la fenêtre

                                            //On quitte the programme
                                             quit = true;



                                            break;
                         case SDL_KEYDOWN:
                              switch (game->event.key.keysym.sym)
                              {
                                     case SDLK_DOWN:
                                           FSOUND_PlaySound(FSOUND_FREE, sonCurseurDeplacement);
                                           positionCurseur++;
                                           if ( positionCurseur > 2 )
                                           {
                                                positionCurseur = 1;
                                           }
                                           SDL_Delay(10);
                                           break;

                                     case SDLK_UP:
                                           FSOUND_PlaySound(FSOUND_FREE, sonCurseurDeplacement);
                                           positionCurseur--;
                                           if ( positionCurseur < 1 )
                                           {
                                                positionCurseur = 2;
                                           }
                                           break;
                                     case SDLK_RETURN:
                                          FSOUND_PlaySound(FSOUND_FREE, sonCurseurValider);
                                          FSOUND_Stream_Stop(musique1);
                                          positionCurseur = 0;
                                          break;
                                    default:;

                              }


                  }

                  if (positionCurseur == 0 && quit==false )
                  {
                                 for (int i = 0 ; i <= 255 ; i+=24) // transition noir
                                 {
                                 alpha = i;
                                 SDL_SetAlpha(fondu, SDL_SRCALPHA, alpha);
                                 SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL);
                                 SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02);
                                 SDL_BlitSurface(fondu, NULL, SDL_GetVideoSurface(), NULL);

                                 SDL_UpdateRect(game->screen, 0, 0, 0, 0);

                                 tempsPrecedent = tempsActuel;

                                 while( tempsActuel - tempsPrecedent < 1000 / FRAMES_PER_SECOND )
                                 {
                                  tempsActuel = SDL_GetTicks();
                                 }

                                  }

                                 alpha = 255;
                                 SDL_SetAlpha(fondu, SDL_SRCALPHA, alpha);
                                 SDL_BlitSurface(fondu, NULL, SDL_GetVideoSurface(), NULL);
                                 SDL_UpdateRect(game->screen, 0, 0, 0, 0);
                                 break;

                  }

                  if ( positionCurseur == 1 && quit==false )
                  {
                  image02.x = 300;
                  image02.y = 515;
                  }
                  if ( positionCurseur == 2 && quit==false)
                  {
                  image02.x = 300;
                  image02.y = 539;
                  }
                  if ( positionCurseur != 0 && quit==false)
                  {
                  SDL_BlitSurface(image1,NULL,SDL_GetVideoSurface(),NULL);
                  SDL_BlitSurface(image2,NULL,SDL_GetVideoSurface(),&image02);
                  SDL_UpdateRect(game->screen, 0, 0, 0, 0);
                  }
                  break;
           }


     }
     game->Quit();



}
/**	Stop the stream
 *
 *	@returns	boolean true or false, depending on whether the stream stopped successfully or not
 */
bool FMODStreamBuffer::Stop(void)
{
	if(FSOUND_Stream_Stop(m_stream) == 1) return true;

	return false;
}
 void Stop()
 {
     if (m) FSOUND_Stream_Stop( m );
 }
Beispiel #19
0
int main(int argc, char ** argv)
{
    int finp = 0,first = 1;
    SDL_Surface * menu = NULL;
    SDL_Surface * ecran = NULL;
    SDL_Rect position_menu;
    SDL_Event event;
    FSOUND_STREAM * musique = NULL;
    
    SDL_Init(SDL_INIT_VIDEO);
    TTF_Init();
    FSOUND_Init(44100,32,0);
    
    ecran = SDL_SetVideoMode(800,800,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
    
    if(ecran == NULL)
       exit(EXIT_FAILURE);
    SDL_WM_SetCaption("Prozet zz1",NULL);
    
    menu = IMG_Load("./dessin/menu.jpg");
    if(menu == NULL)
       exit(EXIT_FAILURE);
    
    position_menu.x = 0;
    position_menu.y = 0;
        
    musique = FSOUND_Stream_Open("./son/jourdefoot.mp3",0,0,0);
    if(musique == NULL)
       exit(EXIT_FAILURE);
    while(finp == 0)
    {
       if(first == 1)
       {
          SDL_BlitSurface(menu,NULL,ecran,&position_menu);
          SDL_Flip(ecran);
          FSOUND_Stream_Play(FSOUND_FREE,musique);
	  first = 0;
       }
       SDL_WaitEvent(&event);
       switch(event.type)
       {
          case SDL_QUIT:
	               finp = 1;
	               break;
	  case SDL_MOUSEBUTTONDOWN:
	               if(event.button.button == SDL_BUTTON_LEFT)
		       {
		          if(event.button.x >= 250 && event.button.x <= 550)
			  {
			     if(event.button.y >= 300 && event.button.y <= 400)
			     {
			        FSOUND_Stream_Stop(musique);
				mode_solo(ecran);
				first = 1;
			     }
			     else
			     {
			        if(event.button.y >= 450 && event.button.y <= 550)
				{
			           FSOUND_Stream_Stop(musique);
				   mode_local_serveur(ecran);
				   first = 1;
				}
				else
				{
				   if(event.button.y >= 600 && event.button.y <= 700)
				   {
			              FSOUND_Stream_Stop(musique);
				      mode_local_client(ecran);
				      first = 1;
				   }
				}
			     }
			  }
		       }
		       break;
       }
       
    }
    
    FSOUND_Stream_Stop(musique);
    FSOUND_Stream_Close(musique);
    FSOUND_Close();
    SDL_FreeSurface(menu);
    SDL_FreeSurface(ecran);
    TTF_Quit();
    SDL_Quit();
    return(EXIT_SUCCESS);
      
}
void World::stopMusic()
{
	FSOUND_Stream_Stop( mp3file );
}
Beispiel #21
0
void MusicStream::stop() {
    if (playing && (music != NULL)) {
        FSOUND_Stream_Stop(music);
        playing = false;
    }
}