Jump to content
  • Advertisement
Sign in to follow this  
SomeoneX

SDL_Mixer - Mix_LoadWAV() does not load sound

This topic is 3666 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 trying to get a sound effect to play when a player collides with an object. I know that the collision detection works already, because hits are counted and the objects are dealt with accordingly. The problem is with trying to load a file into a Mix_Chunk*. Essentially the only calls I'm doing are:
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

Mix_Music* backgroundMusic = Mix_LoadMUS("02.mp3");
Mix_Chunk* hitSound = Mix_LoadWAV("hit.wav");

Mix_PlayMusic(backgroundMusic, -1);

//Event handling and whatnot

if(player.checkCollision(hitCount, eShots) == true)
{
    Mix_PlayChannel(-1, hitSound, 0);
}

When it is run, the music plays fine, but the hitSound is never played. At one point I tried messing with the volume and it segfaulted (Added a Mix_VolumeChunk call). I also tried making 3 channels but nothing played. When I debug, it says that hitSound doesn't exist (yes, I put the breakpoint after hitSound is defined). And yes, hit.wav is in the right folder, and just in case I copied it over to the /bin/debug folder (Code::Blocks)

Share this post


Link to post
Share on other sites
Advertisement
Most of the SDL_mixer functions return error codes; I think there's also a Mix_Error() function (or something similar) that you can use to query for more information when an error occurs. (This may not solve your problem, but you should at least be able to gather a little more information about what's going wrong.)

Share this post


Link to post
Share on other sites
OK I have an error. Guess I'm not doing anything wrong, it's in a bad format for SDL. The error was "Uknown WAVE data format: 0x0003"

I'll try doing some conversions or something. I don't have too much of an idea of what I'm doing, so help would be great.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!