Exemplo n.º 1
0
void		fmode(void)
{
  FMOD_SYSTEM	*system;
  FMOD_SOUND	*musique;
  FMOD_CHANNEL	*channel;
  FMOD_RESULT	resultat;
  char		*str;

  str = "./graphic/Martin Garrix - Animals.mp3";
  FMOD_System_Create(&system);
  FMOD_System_Init(system, 2, FMOD_INIT_NORMAL, NULL);
  resultat = FMOD_System_CreateSound(system, str, FMOD_SOFTWARE
				     | FMOD_2D | FMOD_CREATESTREAM, 0, &musique);
  if (resultat != FMOD_OK)
    {
      my_printf(2, "Cannot find ");
      my_printf(2, "%s", str);
      my_printf(2, ", put this file next to the executable 'corewar'");
      write(2, "\n", 1);
    }
  else
    {
      FMOD_Sound_SetLoopCount(musique, -1);
      FMOD_System_GetChannel(system, 9, &channel);
      FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL);
    }
}
Exemplo n.º 2
0
void 	CubeAnim::update()
{
  FMOD_System_GetChannel(system, 0, &canal);
  FMOD_Channel_GetSpectrum(canal, spectre, TAILLE_SPECTRE, 0, FMOD_DSP_FFT_WINDOW_RECT);
  for (size_t i = 0; i < _objects.size(); ++i)
    _objects[i]->translate(vec3(0, getEquation(i), 0));
}
Exemplo n.º 3
0
void MOD_Start (char *name, qboolean midi, qboolean loop, qboolean notify, qboolean resume)
{
	char	file[MAX_QPATH];
	FMOD_CREATESOUNDEXINFO exinfo;

	if(SND_Initialised == false)
		return;

	if(SND_MusicChannel.inuse == true)
		FMOD_MusicStop();

	if(strlen(name) == 0)
		return;

	if(SND_FOpen(name, midi, resume) == true)
	{
		memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
		exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
		exinfo.length = SND_File.length;

		result = FMOD_System_CreateSound(fmod_system, (const char *)SND_File.data, FMOD_HARDWARE | FMOD_OPENMEMORY | FMOD_2D, &exinfo, &fmod_music);
		FMOD_ERROR(result, true, false);

		if(loop == true)
		{
			SND_MusicChannel.looping = true;
			result = FMOD_Sound_SetMode(fmod_music, FMOD_LOOP_NORMAL);
			FMOD_ERROR(result, true, false);
		}
		else
		{
			SND_MusicChannel.looping = false;
			result = FMOD_Sound_SetMode(fmod_music, FMOD_LOOP_OFF);
			FMOD_ERROR(result, true, false);
		}

		strcpy(file, SND_File.filename);
		SND_FClose();
	}


	if(!fmod_music)
	{
		Con_Printf("Couldn't open stream %s\n", file);
		return;
	}
	else
	{
		if(notify == true)
			Con_Printf("Playing: %s...\n", file);
	}

	result = FMOD_System_GetChannel(fmod_system, 0, &SND_MusicChannel.channel);
	FMOD_ERROR(result, true, false);

	result = FMOD_System_PlaySound(fmod_system, FMOD_CHANNEL_REUSE, fmod_music, 0, &SND_MusicChannel.channel);
    FMOD_ERROR(result, true, false);

	SND_MusicChannel.inuse = true;
}
Exemplo n.º 4
0
void I_StopSound(INT32 handle)
{
	FMOD_CHANNEL *chan;
	FMR(FMOD_System_GetChannel(fsys, handle, &chan));
	if (music_stream && chan == music_channel)
		return;
	FMR(FMOD_Channel_Stop(chan));
}
Exemplo n.º 5
0
 bool  CubeAnim::loadSound(const std::string &path)
 {
   resultat = FMOD_System_CreateSound(system, path.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &musique);
   if (resultat != FMOD_OK)
   {
     std::cout << "Impossible to open the audio file" << std::endl;
     return (false);
   }
   FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL); 
   FMOD_System_GetChannel(system, 0, &canal);
   return (true);
 }
Exemplo n.º 6
0
MAX_FMOD_CHANNEL * bmx_FMOD_System_GetChannel(FMOD_SYSTEM *system, int channelId) {
	MAX_FMOD_CHANNEL * channel = new MAX_FMOD_CHANNEL();
	
	FMOD_RESULT result = FMOD_System_GetChannel(system, channelId, &channel->channel);
	
	if (result) {
		delete channel;
		return 0;
	}
	
	return channel;
}
Exemplo n.º 7
0
F_CALLBACK FMOD_RESULT Audio::sonStoppe(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2) {
	int nb;
	FMOD_Channel_GetIndex(channel, &nb);
	
	FMOD_CHANNEL *c;
	FMOD_System_GetChannel(_systeme, nb, &c);
	
	if(c != _canalMusique) {
		Audio::_canaux[nb] = 0;
	}
			
	return FMOD_OK;
}
Exemplo n.º 8
0
// seems to never be called on an invalid channel (calls I_SoundIsPlaying first?)
// so I'm not gonna worry about it.
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
{
	FMOD_CHANNEL *chan;
	FMOD_SOUND *sound;
	float frequency;

	FMR(FMOD_System_GetChannel(fsys, handle, &chan));
	FMR(FMOD_Channel_SetVolume(chan, (vol / 255.0) * (sfx_volume / 31.0)));
	FMR(FMOD_Channel_SetPan(chan, (sep - 128) / 127.0));

	FMR(FMOD_Channel_GetCurrentSound(chan, &sound));
	FMR(FMOD_Sound_GetDefaults(sound, &frequency, NULL, NULL, NULL));
	FMR(FMOD_Channel_SetFrequency(chan, (pitch / 128.0) * frequency));

	//FMR(FMOD_Channel_SetPriority(chan, 1 + ((0xff-vol)>>1))); // automatic priority 1 - 128 based on volume (priority 0 is music)
}
Exemplo n.º 9
0
void    MY_FMOD::play(std::string const &str)
{
  //if (str == NULL)
  //str = "battle.mp3";
  FMOD_System_Create(&system);
  FMOD_System_Init(system, 2, FMOD_INIT_NORMAL, NULL);
  //FMOD_Sound_SetLoopCount(musique, -1);
  resultat = FMOD_System_CreateSound(system, str.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &musique);
  if (resultat != FMOD_OK)
    {
      std::cerr << "Cannot find " << str << std::endl;
      return;
    }
  FMOD_System_GetChannel(system, 9, &channel);
  FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL);
}
Exemplo n.º 10
0
void Audio::stop(){
    if(System == NULL)
        return;

    int n;
    FMOD_System_GetChannelsPlaying(System, &n);

    QList<FMOD_CHANNEL *> channels;
    for(int i=0; i<n; i++){
        FMOD_CHANNEL *channel;
        FMOD_RESULT result = FMOD_System_GetChannel(System, i, &channel);
        if(result == FMOD_OK)
            channels << channel;
    }

    foreach(FMOD_CHANNEL *channel, channels){
        FMOD_Channel_Stop(channel);
    }
Exemplo n.º 11
0
boolean I_SoundIsPlaying(INT32 handle)
{
	FMOD_CHANNEL *chan;
	FMOD_BOOL playing;
	FMOD_RESULT e;
	FMR(FMOD_System_GetChannel(fsys, handle, &chan));
	if (music_stream && chan == music_channel)
		return false;
	e = FMOD_Channel_IsPlaying(chan, &playing);
	switch(e)
	{
	case FMOD_ERR_INVALID_HANDLE: // Sound effect finished.
	case FMOD_ERR_CHANNEL_STOLEN: // Sound effect interrupted. -- technically impossible due to GetChannel by handle. :(
		return false; // therefore, it's not playing anymore.
	default:
		FMR(e);
		break;
	}
	return (boolean)playing;
}
Exemplo n.º 12
0
void CDA_Start (int track, qboolean loop, qboolean notify)
{
#ifdef UQE_FMOD_CDAUDIO

	if (SND_InitialisedCD == false)
		return;

	if(SND_MusicChannel.inuse == true)
		FMOD_MusicStop();

	if(loop == true)
	{
		SND_MusicChannel.looping = true;
		result = FMOD_Sound_SetMode(fmod_musicCD, FMOD_LOOP_NORMAL);
		FMOD_ERROR(result, true, false);
	}
	else
	{
		SND_MusicChannel.looping = false;
		result = FMOD_Sound_SetMode(fmod_musicCD, FMOD_LOOP_OFF);
		FMOD_ERROR(result, true, false);
	}

	// fmod track numbers starts at zero
	result = FMOD_Sound_GetSubSound(fmod_musicCD, track-1, &fmod_musicCD_subsound);
	FMOD_ERROR(result, notify, false);

	result = FMOD_System_GetChannel(fmod_system, 0, &SND_MusicChannel.channel);
	FMOD_ERROR(result, true, false);

	result = FMOD_System_PlaySound(fmod_system, FMOD_CHANNEL_REUSE, fmod_musicCD_subsound, FALSE, &SND_MusicChannel.channel);
    FMOD_ERROR(result, notify, false);


	SND_MusicChannel.inuse = true;

#else
	CDAudio_Play((byte)track, loop);
#endif
}
Exemplo n.º 13
0
FMOD_CHANNEL *SoundEngine::getChannel(unsigned int idChannel)
{
    FMOD_CHANNEL *channel;
    FMOD_System_GetChannel(system, idChannel, &channel);
    return channel;
}
Exemplo n.º 14
0
// Plays the previously loaded sound file
void SoundManager::playMusic()
{
	FMOD_System_PlaySound(mSystem, FMOD_CHANNEL_FREE, mMusic, 0, NULL);
	FMOD_System_GetChannel(mSystem, 0, &mChannel);
}
Exemplo n.º 15
0
int LancerJeu(gpointer *pData)
{
    /* Cette fonction va appeler les fonctions d'initialisations de la SDL et lancer le jeu ou l'éditeur */

    SDL_Renderer *pMoteurRendu = NULL;  //Pointeurs sur le moteur de rendu
    SDL_Window *pFenetre = NULL;        //Pointeur sur la fenêtre
    FMOD_CHANNEL *channelEnCours = NULL;    //Pour le contrôle des différents canaux audios

    Sprite images[50] = {{NULL}, {0,0}};   //Tableau des images (textures + positions)
    TTF_Font *polices[10] = {NULL};		//Tableau des polices

    Options *pOptions = NULL;	//Pointeur sur une structure Options

    FILE *pFichierErreur = fopen("ressources/ErreursLog.txt", "a");        //Pointeur sur le fichier d'erreurs

    SDL_Surface *surf = NULL;	//Pointeur sur une surface
    SDL_Texture *pEcranChargement = NULL;	//Pointeur sur une texture pour l'écran de chargement

    Animation anim[10];	//Tableau de structures Animation

    int erreur=0;	//Code d'erreur

    Joueur *pJoueur = (Joueur *)g_slist_nth_data((GSList*)pData, 6);	//On récupère le pointeur vers la structure Joueur dans la liste chaînée
    Sons *pSons = (Sons*)g_slist_nth_data((GSList*)pData, 4);		//De même avec celui vers la structure Sons
    FMOD_SYSTEM *pMoteurSon = (FMOD_SYSTEM *)g_slist_nth_data((GSList*)pData, 3);	//De même avec celui vers la structure FMOD_SYSTEM

    if(pFichierErreur == NULL)	//Vérification
    {
        exit(EXIT_FAILURE);
    }

    /* On lit les options et on remplit la structure */
    pOptions = DefinirOptions();

    Initialisation(&pMoteurRendu, pFichierErreur, &pFenetre, pOptions);     //Initialisation des principaux éléments (SDL, fenêtre, moteur de rendu)

    FMOD_System_GetChannel(pMoteurSon, M_MENU, &channelEnCours);	//On met en pause la musique du menu
    FMOD_Channel_SetPaused(channelEnCours, true);

    if(BMusique)	//S'il y a de la musique
    {
        FMOD_System_PlaySound(pMoteurSon, M_LOAD, pSons->music[M_LOAD], true, NULL);        // On lit la musique de chargement
        FMOD_System_GetChannel(pMoteurSon, M_LOAD, &channelEnCours);
        FMOD_Channel_SetVolume(channelEnCours, (float)(Volume/100.0));
        FMOD_Channel_SetPaused(channelEnCours, false);
    }

    /* On charge l'image de chargement et on vérifie */
    surf = IMG_Load("ressources/img/load.png");

    if (surf == NULL)
    {
        fprintf(pFichierErreur, "Erreur: impossible d'ouvrir le fichier ressources/img/load.png");
        exit(EXIT_FAILURE);
    }

    /* On transforme la surface en texture pour l'affichage et on libère la mémoire occupée par la surface */
    pEcranChargement = SDL_CreateTextureFromSurface(pMoteurRendu, surf);
    SDL_FreeSurface(surf);

    SDL_ShowCursor(false);	//On masque le curseur pendant le jeu (on affichera un curseur personnalisé dans l'éditeur)

    /* On efface l'écran et on colle l'image de chargement */
    SDL_SetRenderDrawColor(pMoteurRendu, 0, 0, 0, SDL_ALPHA_OPAQUE);
    SDL_RenderClear(pMoteurRendu);
    SDL_RenderCopy(pMoteurRendu, pEcranChargement, NULL, NULL);
    SDL_RenderPresent(pMoteurRendu);

    SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);   //Désactivation des événements dont on a pas besoin.
    SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);

    SDL_DisableScreenSaver();       //Désactivation de l'écran de veille.

    erreur = Chargements(images, pMoteurRendu, polices, anim);	//On charge tout !

    /* Traitement des éventuelles erreurs */
    if(erreur == 1)
    {
        fprintf(pFichierErreur, "Erreur lors du chargement des images. Veuillez vérifier ressources\\img\\... \n");
        exit(EXIT_FAILURE);
    }
    else if (erreur == 2)
    {
        fprintf(pFichierErreur, "Erreur lors du chargement des polices. Veuillez vérifier ressources\\fonts\\... \n");
        exit(EXIT_FAILURE);
    }
    else if (erreur == 3)
    {
        fprintf(pFichierErreur, "Erreur lors du chargement des animations. Veuillez vérifier ressources\\anim\\... \n");
        exit(EXIT_FAILURE);
    }

    if (BMusique)
    {
        FMOD_System_GetChannel(pMoteurSon, M_LOAD, &channelEnCours);	//On arrête la musique du chargement
        FMOD_Channel_SetPaused(channelEnCours, true);

        FMOD_Sound_SetLoopCount(pSons->music[M_JEU], -1);      // On active la lecture en boucle

        FMOD_System_PlaySound(pMoteurSon, M_JEU, pSons->music[M_JEU], true, NULL);        // On lit la musique du jeu
        FMOD_System_GetChannel(pMoteurSon, M_JEU, &channelEnCours);
        FMOD_Channel_SetVolume(channelEnCours, (float)(Volume/100.0));
        FMOD_Channel_SetPaused(channelEnCours, false);
    }

    /* On regarde si on a appelé la fonction en mode jeu ou en mode éditeur */
    if (pJoueur->mode == MODE_CAMPAGNE)
    {
        InitialiserInfos(pOptions, pJoueur);	//On définit les infos sur la partie en cours
        erreur = BouclePrincipale(pJoueur, images, anim, pMoteurRendu, pMoteurSon, pSons, polices);    //Boucle du jeu

        if(erreur == JEU_FIN_ERREUR_CHARGEMENT)
        {
            MessageInformations("Erreur lors du chargement d'un niveau, consultez le fichier erreurs.txt", polices, pMoteurRendu, NULL);
        }

        SauverMySql(pJoueur);	//On sauvegarde l'avancée du joueur
    }
    else if(pJoueur->mode == MODE_PERSO)
    {
        InitialiserInfos(pOptions, pJoueur);	//On définit les infos sur la partie en cours
        erreur = BouclePrincipale(pJoueur, images, anim, pMoteurRendu, pMoteurSon, pSons, polices);    //Boucle du jeu

        if(erreur == JEU_FIN_ERREUR_CHARGEMENT)
        {
            MessageInformations("Erreur lors du chargement d'un niveau, consultez le fichier erreurs.txt", polices, pMoteurRendu, NULL);
        }
    }
    else if (pJoueur->mode == MODE_EDITEUR)
    {
        erreur = Editeur(pMoteurRendu, images, pMoteurSon, pSons, polices, pJoueur);	//On lance la boucle de l'éditeur

        if(erreur == JEU_FIN_ERREUR_CHARGEMENT)
        {
            MessageInformations("Erreur lors du chargement d'un niveau, consultez le fichier erreurs.txt", polices, pMoteurRendu, NULL);
        }
    }

    /* Libération de la mémoire */
    LibererMemoire(pMoteurRendu, images, anim, polices, pFenetre, pOptions);

    fclose(pFichierErreur);	//On ferme le fichier d'erreur

    return 0;
}
Exemplo n.º 16
0
int main(int argc, char *argv[])
{
	int att = 1, motion_state = 0, status = STOP;
	float volume;

	SDL_Event event;
	SDL_Surface *ecran = NULL, *fond = NULL, *play = NULL, *stop = NULL, *pause = NULL, *volumeup = NULL, *volumedown = NULL, *spectrum = NULL;
	SDL_Surface *iplay = NULL, *ipause = NULL, *istop = NULL, *ivolup = NULL, *ivoldo = NULL;

	SDL_Rect pos_fond, pos_spect, pos_play, pos_pause, pos_stop, pos_volumeup, pos_volumedown;

	printf("Démarrage de Freqalyzer\n");

	FMOD_SYSTEM *system;
	FMOD_SOUND *sound;
	FMOD_CHANNEL *channel=0;
	FMOD_RESULT result;
	FMOD_BOOL state;
	void *extradriverdata = 0;

	pos_fond.x = 0;
	pos_fond.y = 0;
	pos_spect.x = 100;
	pos_spect.y = 150;
	pos_play.x = 100;
	pos_play.y = 520;
	pos_pause.x = 100 + CONTROLLER_SIZE;
	pos_pause.y = 520;
	pos_stop.x = 100 + (CONTROLLER_SIZE * 2);
	pos_stop.y = 520;
	pos_volumeup.x = 100 + (CONTROLLER_SIZE * 3);
	pos_volumeup.y = 520;
	pos_volumedown.x = 100 + (CONTROLLER_SIZE * 4);
	pos_volumedown.y = 520;

	//Chargement en mémoire du système d'affichage SDL - Vidéo
	SDL_Init(SDL_INIT_VIDEO);

	if(SDL_Init(SDL_INIT_VIDEO) == -1)
	{
		fprintf(stderr, "Erreur d'initialisation de la SDL");
		exit(EXIT_FAILURE);
	}

	//Paramétrage et ouverture de la fenêtre
	ecran =  SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);

	spectrum = SDL_CreateRGBSurface(SDL_HWSURFACE, 600, 350, 32, 0, 0, 0, 0);
	SDL_FillRect(spectrum, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));

	//Titrage de la fenêtre
	SDL_WM_SetCaption("Freqalyzer", NULL);

	//Chargement des images
	fond = IMG_Load("../pictures/fond.jpg");
	W_GestionErreur(P_IMAGE, 0, fond, "fond.jpg");

	play = IMG_Load("../pictures/play.jpg");
	W_GestionErreur(P_IMAGE, 0, play, "play.jpg");

	pause = IMG_Load("../pictures/pause.jpg");
	W_GestionErreur(P_IMAGE, 0, pause, "pause.jpg");

	stop = IMG_Load("../pictures/stop.jpg");
	W_GestionErreur(P_IMAGE, 0, stop, "stop.jpg");

	volumeup = IMG_Load("../pictures/volume_up.jpg");
	W_GestionErreur(P_IMAGE, 0, volumeup, "volume_up.jpg");

	volumedown = IMG_Load("../pictures/volume_down.jpg");
	W_GestionErreur(P_IMAGE, 0, volumedown, "volume_down.jpg");

	iplay = IMG_Load("../pictures/iplay.jpg");
	W_GestionErreur(P_IMAGE, 0, iplay, "iplay.jpg");

	ipause = IMG_Load("../pictures/ipause.jpg");
	W_GestionErreur(P_IMAGE, 0, ipause, "ipause.jpg");

	istop = IMG_Load("../pictures/istop.jpg");
	W_GestionErreur(P_IMAGE, 0, istop, "istop.jpg");

	ivolup = IMG_Load("../pictures/ivolume_up.jpg");
	W_GestionErreur(P_IMAGE, 0, ivolup, "ivolume_up.jpg");

	ivoldo = IMG_Load("../pictures/ivolume_down.jpg");
	W_GestionErreur(P_IMAGE, 0, ivoldo, "ivolume_down.jpg");

	//Allocation de mémoire à system
	result = FMOD_System_Create(&system);
	W_GestionErreur(P_CREASON, result, NULL, "");

	//Initialisation
	result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, extradriverdata);
	W_GestionErreur(P_CHARGSON, result, NULL, "");

	result = FMOD_System_CreateSound(system, "../sounds/radio_sig.mp3", FMOD_2D | FMOD_CREATESTREAM, 0, &sound);

/*	//Chargement du son
	result = FMOD_System_CreateSound(system, argv[1], FMOD_2D | FMOD_CREATESTREAM, 0, &sound);
	if (result != 0)
	{
		printf("\nErreur de saisie, veuillez taper un chemin correct \n(ex : ./Freqalyser ../sounds/gameofthrones.mp3)\n");
		exit(EXIT_FAILURE);
	}*/

	while(att)
	{
		SDL_WaitEvent(&event);

		if (event.motion.x > 100 && event.motion.x < (100 + CONTROLLER_SIZE * 5) && event.motion.y > 520 && event.motion.y < (520 + CONTROLLER_SIZE))
		{
			motion_state = 1;
			W_event(ecran, iplay, ipause, istop, ivolup, ivoldo);
		}else
			motion_state = 0;

		switch(event.type)
		{
			case SDL_QUIT:
				att = 0;
				break;
			case SDL_MOUSEBUTTONUP:
				if (event.button.x > 100 && event.button.x < (100 + CONTROLLER_SIZE) && event.button.y > 520 && event.button.y < (520 + CONTROLLER_SIZE))
				{
					//jouer le son et mettre en pause le programme le temps de sa lecture
					result=FMOD_System_PlaySound(system, sound, 0, 0, &channel);
					W_GestionErreur(P_LECTURE, result, NULL, "");
					unsigned int length;
					FMOD_Sound_GetLength(sound, &length, FMOD_TIMEUNIT_MS);
					FMOD_Channel_GetVolume(channel, &volume);
					FMOD_Channel_GetVolume(channel, &volume);
					status = PLAY;
				}
				if (event.button.x > (100 + CONTROLLER_SIZE) && event.button.x < (100 + (CONTROLLER_SIZE * 2)) && event.button.y > 520 && event.button.y < (520 + CONTROLLER_SIZE))
				{
					FMOD_System_GetChannel(system, 512, &channel);
					FMOD_Channel_GetPaused(channel, &state);
					if(state)
					{
						FMOD_Channel_SetPaused(channel, 0);
						status = PLAY;
					}
					else
					{
						FMOD_Channel_SetPaused(channel, 1);
						status = PAUSE;
					}
				}
				if (event.button.x > (100 + CONTROLLER_SIZE * 2) && event.button.x < (100 + CONTROLLER_SIZE * 3) && event.button.y > 520 && event.button.y < (520 + CONTROLLER_SIZE))
				{
					FMOD_Channel_Stop(channel);
					status = STOP;
				}
				if (event.button.x > (100 + CONTROLLER_SIZE * 3) && event.button.x < (100 + CONTROLLER_SIZE * 4) && event.button.y > 520 && event.button.y < (520 + CONTROLLER_SIZE))
					result = W_GestionVolume(&volume, channel, UP);
				if (event.button.x > (100 + CONTROLLER_SIZE * 4) && event.button.x < (100 + CONTROLLER_SIZE * 5) && event.button.y > 520 && event.button.y < (520 + CONTROLLER_SIZE))
					result = W_GestionVolume(&volume, channel, DOWN);
				break;
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym)
				{
					case SDLK_ESCAPE:
 						att = 0;
						break;
					case SDLK_SPACE:
						//jouer le son et mettre en pause le programme le temps de sa lecture
						result=FMOD_System_PlaySound(system, sound, 0, 0, &channel);
						unsigned int length;
						FMOD_Sound_GetLength(sound, &length, FMOD_TIMEUNIT_MS);
						FMOD_Channel_GetVolume(channel, &volume);
						FMOD_Channel_GetVolume(channel, &volume);
						status = PLAY;
						break;
					case SDLK_UP:
						result = W_GestionVolume(&volume, channel, UP);
						break;
					case SDLK_DOWN:
						result = W_GestionVolume(&volume, channel, DOWN);
						break;
					case SDLK_p:
						FMOD_System_GetChannel(system, 512, &channel);
						FMOD_Channel_GetPaused(channel, &state);
						if(state)
						{
							FMOD_Channel_SetPaused(channel, 0);
							status = PLAY;
						}
						else
						{
							FMOD_Channel_SetPaused(channel, 1);
							status = PAUSE;
						}
						break;
					case SDLK_s:
						FMOD_Channel_Stop(channel);
						status = STOP;
						break;
					default:
						break;
					}
			default:
				break;
		}

		//Affichage des surfaces
		SDL_BlitSurface(fond, NULL, ecran, &pos_fond);
		SDL_BlitSurface(spectrum, NULL, ecran, &pos_spect);
		switch (status)
		{
			case PLAY:
				SDL_BlitSurface(iplay, NULL, ecran, &pos_play);
				SDL_BlitSurface(pause, NULL, ecran, &pos_pause);
				SDL_BlitSurface(stop, NULL, ecran, &pos_stop);
				break;
			case PAUSE:
				SDL_BlitSurface(play, NULL, ecran, &pos_play);
				SDL_BlitSurface(ipause, NULL, ecran, &pos_pause);
				SDL_BlitSurface(stop, NULL, ecran, &pos_stop);
				break;
			case STOP:
				SDL_BlitSurface(play, NULL, ecran, &pos_play);
				SDL_BlitSurface(pause, NULL, ecran, &pos_pause);
				SDL_BlitSurface(istop, NULL, ecran, &pos_stop);
				break;
			default:
				break;
		}
		SDL_BlitSurface(volumeup, NULL, ecran, &pos_volumeup);
		SDL_BlitSurface(volumedown, NULL, ecran, &pos_volumedown);

		//Rafraîchissement de la fenêtre
		SDL_Flip(ecran);
		FMOD_System_Update(system);
	}

	//Fermeture et libération de l'objet system en mémoire
	FMOD_Sound_Release(sound);
	FMOD_System_Close(system);
	FMOD_System_Release(system);

	SDL_FreeSurface(spectrum);
	SDL_FreeSurface(fond);
	SDL_FreeSurface(play);
	SDL_FreeSurface(pause);
	SDL_FreeSurface(stop);
	SDL_FreeSurface(volumeup);
	SDL_FreeSurface(volumedown);
	SDL_FreeSurface(iplay);
	SDL_FreeSurface(ipause);
	SDL_FreeSurface(istop);
	SDL_FreeSurface(ivolup);
	SDL_FreeSurface(ivoldo);

	SDL_Quit();

	return EXIT_SUCCESS;
}