Advertisement

FSOUND_PlaySound() Problems

Started by October 15, 2004 06:26 PM
2 comments, last by Ekim_Gram 19 years, 10 months ago
I'm remaking my Pong game from last year and now I'm up to the sound part of it. Lemme give you my source code first:

"CEngine.h"
class CEngine
{
public:
  ...
  FSOUND_SAMPLE *bounce;		// The bounce sound
  ...
};

"CEngine.cpp"
...
// Load the bounce sound
FSOUND_Sample_Load(0, "data/bounce.wav", FSOUND_LOOP_OFF, 0, 0);
...

"Main.cpp"

...
// Initialize FMOD
FSOUND_Init(44100, 32, 0);
...
if (Engine.keys[SDLK_SPACE])
  {FSOUND_PlaySound(FSOUND_ALL, Engine.bounce);}
...
Whenever I push the spacebar, the game crashes. What's wrong here?
I don't know a lot about OOP but that code looks like it would work to me.
Have you tried debugging it?
Also set up error reporting eg

if(FSOUND_Init(44100, 32, 0) < 0){    printf("Error: %s",FSOUND_GetError() );}

etc...
Advertisement
Quote: Original post by Ekim_Gram
"CEngine.cpp"...// Load the bounce soundFSOUND_Sample_Load(0, "data/bounce.wav", FSOUND_LOOP_OFF, 0, 0);...


Looks like you have a bad pointer problem, since you're not doing this:
bounce = FSOUND_Sample_Load(0, "data/bounce.wav", FSOUND_LOOP_OFF, 0, 0);

Therefore when you call the play function, bounce isn't pointing to a valid sample. Unless you cut out the assignment statement in your above example for some reason...

Drew Sikora
Executive Producer
GameDev.net

*DOH* how could I forget to do that. It's funny too because my font engine and the way I use SDL works exactly like that.

This topic is closed to new replies.

Advertisement