Hello SDL Forum,
I’m a new SDL programmer and I’m having a problem with the SDL_mixer. My music is playing but my sound effects are not. I’m using Ubuntu and just trying to work on a simple Galaga clone to learn SDL in my spare time.
My error comes when I try to activate a sound effect when the player shoots a laser. The code is as follows below.
// Create Instance Variable for the sound effect
Mix_Chunk *laserShoot = NULL;
laserShoot = Mix_LoadWAV("assets/laserShoot.wav");
if (laserShoot == NULL)
{
printf("[FAILURE] - Failed to laserShoot sound effect! SDL_mixer Error:%s\n", Mix_GetError());
success = false;
}
The Mix_GetError() prints the error “Mix_PlayChannel: Tried to play a chunk with a bad frame” and I don’t know what that means exactly. I have done some online searches but I haven’t found much information on this specific sound.
I do initialize Mix_OpenAudio() as follows in my start up function
// Initialize SDL_mixer
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
{
printf("[FAILURE] - SDL_mixer could not be initialized! SDL Error: %s\n", Mix_GetError());
success = false;
}
I don’t know what the “Bad frame” means and I don’t see a lot of information on it online. The laserShoot.wav file is very small it’s a 44 byte file, is the file too small to work with? Any help or clarification would be appreciated.