Sign in to follow this  
Ekim_Gram

FSOUND_PlaySound() Problems

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Quote:
Original post by Ekim_Gram

"CEngine.cpp"
...
// Load the bounce sound
FSOUND_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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this