Lecture de son FMOD

Fermé
D_A_R_K_O_S Messages postés 98 Date d'inscription vendredi 1 février 2013 Statut Membre Dernière intervention 23 juin 2015 - 7 sept. 2013 à 20:55
D_A_R_K_O_S Messages postés 98 Date d'inscription vendredi 1 février 2013 Statut Membre Dernière intervention 23 juin 2015 - 20 oct. 2013 à 16:37
Bonjour, je débute en programmation ( C ) et j'ai commencé un programme en utilisant les bibliothèques SDL et FMOD. Mais quand j'essaye de faire jouer un son (FMOD) ça ne marche pas et ça fait arrêter le programme. Qu'est ce qui ne va pas ?
Merci d'avance pour d'éventuelles réponses.

CODE :

#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif

#include <SDL/SDL.h>
#include <FMOD/fmod.h>
#include <windows.h>

int main ( int argc, char** argv )
{
// initialize SDL video
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "Unable to init SDL: %s\n", SDL_GetError() );
return 1;
}

// make sure SDL cleans up before exit
atexit(SDL_Quit);

// create a new window
SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
if ( !screen )
{
printf("Unable to set 640x480 video: %s\n", SDL_GetError());
return 1;
}

// CHARGEMENT DES IMAGES
SDL_Surface* arp = SDL_LoadBMP("ARP.bmp");
if (!arp)
{
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}

// CREATION DES POSITIONS
SDL_Rect posARP;
posARP.x = 0;
posARP.y = 0;

SDL_Rect posB1;
posB1.x = 167;
posB1.y = 252;

SDL_Rect posB2;
posB2.x = 163;
posB2.y = 353;

//FMOD INITIALISATION

FMOD_SYSTEM *system;
FMOD_System_Create(&system);
FMOD_System_Init(system, 16, FMOD_INIT_NORMAL, NULL);

FMOD_SOUND *click = NULL;

FMOD_System_CreateSound(system, "click.wav", FMOD_CREATESAMPLE, 0, &click);


// program main loop
bool arretM = false;
bool arretJ = false;

while (!arretM)
{
// message processing loop
SDL_Event event;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
arretM = true;
arretJ = true;
break;

// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_ESCAPE)
arretM = true;
arretJ = true;
break;
}
case SDL_MOUSEBUTTONUP:
{
if(event.button.x /300 == posB1.x/300 && event.button.y /55 == posB1.y/55)
{

FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, click, 0, NULL);

}
break;
}

} // end switch
} // end of message processing

// DRAWING STARTS HERE

// clear screen
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));

// draw bitmap
SDL_BlitSurface(arp, 0, screen, &posARP);

// DRAWING ENDS HERE

// finally, update the screen :)
SDL_Flip(screen);
} // end main loop

// FERMETURE SDL
SDL_FreeSurface(arp);

// FERMETURE FMOD
FMOD_Sound_Release(click);
FMOD_System_Close(system);
FMOD_System_Release(system);

return 0;
}




3 réponses

D_A_R_K_O_S Messages postés 98 Date d'inscription vendredi 1 février 2013 Statut Membre Dernière intervention 23 juin 2015 7
7 sept. 2013 à 22:57
UP
0
D_A_R_K_O_S Messages postés 98 Date d'inscription vendredi 1 février 2013 Statut Membre Dernière intervention 23 juin 2015 7
8 sept. 2013 à 19:37
Personne ?
0
D_A_R_K_O_S Messages postés 98 Date d'inscription vendredi 1 février 2013 Statut Membre Dernière intervention 23 juin 2015 7
20 oct. 2013 à 16:37
???
0