Jump to content
  • Advertisement
Sign in to follow this  
Ekim_Gram

FSOUND_PlaySound() Problems

This topic is 5001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!