Public Group

# SDL_Mixer - Mix_LoadWAV() does not load sound

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

## 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 on other sites
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 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.

1. 1
2. 2
Rutin
26
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632941
• Total Posts
3009330
• ### Who's Online (See full list)

There are no registered users currently online

×