0

I want to listen to a sound by using FMOD in a function.. I want to say before that I can hear all my other sounds but they are not used with a function.

here is an extract of the code :

header.h

void leson(FMOD_SOUND *caisse);

and now the code :

#include <fmod.h>

FMOD_SYSTEM *system;
FMOD_SOUND *caisse;
FMOD_RESULT resultat8;
FMOD_System_Create(&system);
FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);



resultat8 = FMOD_System_CreateSound(system, "sound/caisse.wav", FMOD_CREATESAMPLE, 0, &caisse);
if (resultat8 != FMOD_OK)
{
    fprintf(stderr, "error");
    exit(EXIT_FAILURE);
}

I want to use the key V to call the function leson()

            switch(event.type)
            {

                    case SDL_KEYDOWN:
                    switch(event.key.keysym.sym)
                            {

                                case SDLK_v:
                                leson(&caisse);
                                break;

here is leson()

void leson(FMOD_SOUND *caisse)

{
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, caisse, 0, NULL);
fprintf(stderr, "test");

}

When I press V the file stderr contains the line test so the switch is ok, but why I cant hear this sound ?

caps lock
  • 511
  • 3
  • 7
  • 20
  • The only way I've found to make this thing work is creating a function "leson()" with no arguments with inside all the code I wrote FMOD_SYSTEM ... to resultat8. This code is ugly – caps lock May 16 '12 at 22:48

1 Answers1

0

At first glance, the sound looks like it should be playing. To figure this error out quickly, you need to fix your error checking. Set resultat8 equal to each of the FMOD functions, like you did with FMOD_System_CreateSound, and put

if(resultat8 != FMOD_OK) 
{
  printf("%s", FMOD_ErrorString(resultat8));
}

after each FMOD function call. This will print out the error message that is returned if an error occurred.

SirJames
  • 49
  • 4