IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

FMOD Discussion :

Crash lors de la lecture du son


Sujet :

FMOD

  1. #1
    Membre à l'essai
    Inscrit en
    Mai 2013
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2013
    Messages : 26
    Points : 23
    Points
    23
    Par défaut Crash lors de la lecture du son
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    #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; 
    }

  2. #2
    Membre expérimenté Avatar de edgarjacobs
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2011
    Messages
    623
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mai 2011
    Messages : 623
    Points : 1 551
    Points
    1 551
    Par défaut
    Hello,

    Je te conseille de tester le retour de FMOD_System_Create(...), FMOD_System_Init(...) et surtout FMOD_System_CreateSound(....), car chez moi ton programme (modifié pour la norme C89 et sans les display sdl) fonctionne.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    #ifdef __cplusplus 
    #include <cstdlib> 
    #else 
    #include <stdlib.h> 
    #endif 
     
    #include <SDL/SDL.h> 
    #include <FMODex/fmod.h> 
    #include <windows.h> 
     
    #pragma warn -par
    int main ( int argc, char** argv ) 
    { 
        FMOD_SYSTEM *system; 
        FMOD_SOUND *click; 
    	SDL_Surface* screen;
    	int arretM;
    	int arretJ;
     
        // initialize SDL video 
        if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) 
        { 
            puts( "Unable to init SDL"); 
            return 1; 
        } 
     
        // create a new window 
        screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); 
        if ( !screen ) 
        { 
            puts("Unable to set 640x480 video");
            return 1; 
        } 
     
        FMOD_System_Create(&system); 
        FMOD_System_Init(system, 16, FMOD_INIT_NORMAL, NULL); 
     
        FMOD_System_CreateSound(system, "click.wav", FMOD_CREATESAMPLE, 0, &click); 
     
        // program main loop 
        arretM = 0; 
        arretJ = 0; 
     
        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 = 1; 
                        arretJ = 1; 
                        break; 
     
                    // check for keypresses 
                    case SDL_KEYDOWN: 
                    { 
                        // exit if ESCAPE is pressed 
                        if (event.key.keysym.sym == SDLK_ESCAPE) 
                            arretM = 1; 
                        arretJ = 1; 
                        break; 
                    } 
                    case SDL_MOUSEBUTTONUP: 
                    { 
                            FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, click, 0, NULL); 
     
                        break; 
                    } 
     
                } // end switch 
            } // end of message processing 
        } // end main loop 
     
    	SDL_Quit();
     
        // FERMETURE FMOD 
        FMOD_Sound_Release(click); 
        FMOD_System_Close(system); 
        FMOD_System_Release(system); 
     
     
    	return 0; 
    }
    #pragma warn .par
    Edgar.
    On écrit "J'ai tort" ; "tord" est la conjugaison du verbre "tordre" à la 3ème personne de l'indicatif présent

  3. #3
    Membre à l'essai
    Inscrit en
    Mai 2013
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2013
    Messages : 26
    Points : 23
    Points
    23
    Par défaut
    Bonjours et merci de cette réponse rapide !
    Je vais essayer cela et vous tiendrez au courant.
    Peut être en effet que la bibliothèque s'est mal installé...

  4. #4
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 858
    Points : 218 575
    Points
    218 575
    Billets dans le blog
    120
    Par défaut
    Bonjour,

    Je pense surtout que vous avez un crash lors de la lecture du son. Du coup, je vous conseille d'utiliser un débogueur (GDB, ou le débogueur intégré à votre EDI) pour savoir où le programme s'arrête, précisément.

    Notamment :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FMOD_System_CreateSound(system, "click.wav", FMOD_CREATESAMPLE, 0, &click);
    Vous ne vérifiez pas si le fichier est trouvé, ou le son bien chargé.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

Discussions similaires

  1. Réponses: 3
    Dernier message: 09/11/2006, 17h05
  2. Probleme de BIP lors de la lecture d'un fichier
    Par GroRelou dans le forum Entrée/Sortie
    Réponses: 2
    Dernier message: 21/09/2005, 10h12
  3. [socket] Bloqué lors de la lecture
    Par oiffrig dans le forum Réseau/Web
    Réponses: 1
    Dernier message: 01/04/2005, 10h04
  4. Réponses: 14
    Dernier message: 30/03/2005, 21h50
  5. lecture de son à l'ouverture d'un formulaire
    Par cynferdd dans le forum IHM
    Réponses: 4
    Dernier message: 16/06/2003, 15h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo